|
diff --git a/main.c b/main.c
|
| ... |
| 79 |
|
79 |
|
| 80 |
void create_zoom_window() { |
80 |
void create_zoom_window() { |
| 81 |
zoom_window = XCreateSimpleWindow( |
81 |
zoom_window = XCreateSimpleWindow( |
| 82 |
display, |
82 |
display, |
| 83 |
RootWindow(display, screen), |
83 |
RootWindow(display, screen), |
| 84 |
0, 0, |
84 |
0, 0, |
| 85 |
window_size, window_size, |
85 |
window_size, window_size, |
| 86 |
1, |
86 |
1, |
| 87 |
BlackPixel(display, screen), |
87 |
BlackPixel(display, screen), |
| 88 |
WhitePixel(display, screen) |
88 |
WhitePixel(display, screen) |
| 89 |
); |
89 |
); |
| 90 |
XStoreName(display, zoom_window, "X11 Zoom Tool"); |
90 |
XStoreName(display, zoom_window, "Xmagnify"); |
| 91 |
XSelectInput(display, zoom_window, KeyPressMask); |
91 |
XSelectInput(display, zoom_window, KeyPressMask); |
| 92 |
XMapWindow(display, zoom_window); |
92 |
XMapWindow(display, zoom_window); |
| 93 |
} |
93 |
} |
| ... |
| 121 |
clamp_coordinates(&capture_x, &capture_y, capture_width, capture_height); |
121 |
clamp_coordinates(&capture_x, &capture_y, capture_width, capture_height); |
| 122 |
|
122 |
|
| 123 |
XImage *src_image = XGetImage( |
123 |
XImage *src_image = XGetImage( |
| 124 |
display, |
124 |
display, |
| 125 |
RootWindow(display, screen), |
125 |
RootWindow(display, screen), |
| 126 |
capture_x, capture_y, |
126 |
capture_x, capture_y, |
| 127 |
capture_width, capture_height, |
127 |
capture_width, capture_height, |
| 128 |
AllPlanes, |
128 |
AllPlanes, |
| 129 |
ZPixmap |
129 |
ZPixmap |
| 130 |
); |
130 |
); |
| 131 |
|
131 |
|
| 132 |
if (!src_image) { |
132 |
if (!src_image) { |
| 133 |
fprintf(stderr, "XGetImage failed\n"); |
133 |
fprintf(stderr, "XGetImage failed\n"); |
| ... |
| 136 |
} |
136 |
} |
| 137 |
|
137 |
|
| 138 |
XImage *dest_image = XCreateImage( |
138 |
XImage *dest_image = XCreateImage( |
| 139 |
display, |
139 |
display, |
| 140 |
DefaultVisual(display, screen), |
140 |
DefaultVisual(display, screen), |
| 141 |
DefaultDepth(display, screen), |
141 |
DefaultDepth(display, screen), |
| 142 |
ZPixmap, |
142 |
ZPixmap, |
| 143 |
0, |
143 |
0, |
| 144 |
malloc(window_size * window_size * 4), |
144 |
malloc(window_size * window_size * 4), |
| 145 |
window_size, window_size, |
145 |
window_size, window_size, |
| 146 |
32, |
146 |
32, |
| 147 |
0 |
147 |
0 |
| 148 |
); |
148 |
); |
| 149 |
|
149 |
|
| 150 |
for (int y = 0; y < window_size; y++) { |
150 |
for (int y = 0; y < window_size; y++) { |
| 151 |
for (int x = 0; x < window_size; x++) { |
151 |
for (int x = 0; x < window_size; x++) { |
| ... |
| 156 |
} |
156 |
} |
| 157 |
|
157 |
|
| 158 |
GC gc = XCreateGC(display, zoom_window, 0, NULL); |
158 |
GC gc = XCreateGC(display, zoom_window, 0, NULL); |
| 159 |
XPutImage( |
159 |
XPutImage(display, zoom_window, gc, dest_image, 0, 0, 0, 0, window_size, window_size); |
| 160 |
display, |
|
|
| 161 |
zoom_window, |
|
|
| 162 |
gc, |
|
|
| 163 |
dest_image, |
|
|
| 164 |
0, 0, |
|
|
| 165 |
0, 0, |
|
|
| 166 |
window_size, window_size |
|
|
| 167 |
); |
|
|
| 168 |
|
160 |
|
| 169 |
XFreeGC(display, gc); |
161 |
XFreeGC(display, gc); |
| 170 |
XDestroyImage(src_image); |
162 |
XDestroyImage(src_image); |
| ... |