aboutsummarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorym5552020-06-20 22:45:43 +0200
committerMistyhands2023-06-16 00:48:17 +0100
commit13a8b9aeff5a696a21f185778cb46963e4440e9b (patch)
tree21c5188250a8626d93460cabb1e9f742e20e4c1a
parente9bd616df2f54c5ca4ebe1cddd1045b8b7d75dbd (diff)
downloadaur-13a8b9aeff5a696a21f185778cb46963e4440e9b.tar.gz
Improvements
-rw-r--r--Makefile3
-rw-r--r--main.c6
2 files changed, 4 insertions, 5 deletions
diff --git a/Makefile b/Makefile
index 382933f288b3..0a2021a3a85f 100644
--- a/Makefile
+++ b/Makefile
@@ -5,7 +5,8 @@ colorpicker: main.c
install: colorpicker
mkdir -p $(DESTDIR)$(PREFIX)/bin/
- cp -f colorpicker $(DESTDIR)$(PREFIX)/bin/
+ mv colorpicker $(DESTDIR)$(PREFIX)/bin/
+ chmod +x $(DESTDIR)$(PREFIX)/bin/colorpicker
uninstall:
rm -f $(DESTDIR)$(PREFIX)/bin/colorpicker
diff --git a/main.c b/main.c
index 3c5774e46301..ab9366a43139 100644
--- a/main.c
+++ b/main.c
@@ -67,12 +67,12 @@ int main(int argc, char *argv[]) {
XWindowAttributes gwa;
XGetWindowAttributes(display, root, &gwa);
- XImage *image = XGetImage(display, root, 0, 0, gwa.width, gwa.height, AllPlanes, ZPixmap);
XGrabKeyboard(display, root, 0, GrabModeAsync, GrabModeAsync, CurrentTime);
for(;;) {
XEvent e;
XNextEvent(display, &e);
+ XImage *image = XGetImage(display, root, 0, 0, gwa.width, gwa.height, AllPlanes, ZPixmap);
if (e.type == ButtonPress && e.xbutton.button == Button1) {
unsigned long pixel = XGetPixel(image, e.xbutton.x_root, e.xbutton.y_root);
if (output_format & 0x1) {
@@ -89,6 +89,7 @@ int main(int argc, char *argv[]) {
(e.type == KeyPress && (e.xkey.keycode == 53 || quit_on_keypress))) {
break;
}
+ XDestroyImage(image);
}
/* will be done on connection close anw */
@@ -96,9 +97,6 @@ int main(int argc, char *argv[]) {
XUngrabKeyboard(display, CurrentTime);
XFreeCursor(display, cursor);
-
XDestroyWindow(display, root);
- XDestroyImage(image);
-
XCloseDisplay(display);
}