|
1 | 1 | #include <X11/Xlib.h> |
2 | 2 | #include <X11/Xft/Xft.h> |
| 3 | +#include <X11/extensions/Xrandr.h> |
3 | 4 | #include <stdio.h> |
4 | 5 | #include <stdlib.h> |
5 | 6 | #include <signal.h> |
@@ -111,8 +112,22 @@ int main(int argc, char *argv[]) |
111 | 112 | Visual *visual = DefaultVisual(display, screen); |
112 | 113 | Colormap colormap = DefaultColormap(display, screen); |
113 | 114 |
|
| 115 | + int screen_x = 0; |
| 116 | + int screen_y = 0; |
114 | 117 | int screen_width = DisplayWidth(display, screen); |
115 | 118 | int screen_height = DisplayHeight(display, screen); |
| 119 | + if(use_primary_monitor) { |
| 120 | + int nMonitors; |
| 121 | + XRRMonitorInfo* info = XRRGetMonitors(display, RootWindow(display, screen), 1, &nMonitors); |
| 122 | + for(int i = 0; i < nMonitors; i++) { |
| 123 | + if(info[i].primary) { |
| 124 | + screen_x = info[i].x; |
| 125 | + screen_y = info[i].y; |
| 126 | + screen_width = info[i].width; |
| 127 | + screen_height = info[i].height; |
| 128 | + } |
| 129 | + } |
| 130 | + } |
116 | 131 |
|
117 | 132 | XSetWindowAttributes attributes; |
118 | 133 | attributes.override_redirect = True; |
@@ -151,16 +166,16 @@ int main(int argc, char *argv[]) |
151 | 166 | } |
152 | 167 | } |
153 | 168 |
|
154 | | - unsigned int x = pos_x; |
155 | | - unsigned int y = pos_y; |
| 169 | + unsigned int x = screen_x + pos_x; |
| 170 | + unsigned int y = screen_y + pos_y; |
156 | 171 | unsigned int text_height = font->ascent - font->descent; |
157 | 172 | unsigned int height = (num_of_lines - 1) * line_spacing + num_of_lines * text_height + 2 * padding; |
158 | 173 |
|
159 | 174 | if (corner == TOP_RIGHT || corner == BOTTOM_RIGHT) |
160 | | - x = screen_width - width - border_size * 2 - pos_x; |
| 175 | + x = screen_x + screen_width - width - border_size * 2 - pos_x; |
161 | 176 |
|
162 | 177 | if (corner == BOTTOM_LEFT || corner == BOTTOM_RIGHT) |
163 | | - y = screen_height - height - border_size * 2 - pos_y; |
| 178 | + y = screen_y + screen_height - height - border_size * 2 - pos_y; |
164 | 179 |
|
165 | 180 | window = XCreateWindow(display, RootWindow(display, screen), x, y, width, height, border_size, DefaultDepth(display, screen), |
166 | 181 | CopyFromParent, visual, CWOverrideRedirect | CWBackPixel | CWBorderPixel, &attributes); |
|
0 commit comments