1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
diff --git a/conky.cc b/conky.cc
index f099221..32b1cdb 100644
--- a/src/conky.cc
+++ b/src/conky.cc
@@ -10,7 +10,7 @@
*
* Copyright (c) 2004, Hannu Saransaari and Lauri Hakkarainen
* Copyright (c) 2005-2019 Brenden Matthews, Philip Kovacs, et. al.
- * (see AUTHORS)
+ * (see AUTHORS)
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
@@ -66,6 +66,9 @@
#ifdef BUILD_IMLIB2
#include "imlib2.h"
#endif /* BUILD_IMLIB2 */
+#ifdef BUILD_XSHAPE
+#include <X11/extensions/shape.h>
+#endif /* BUILD_XSHAPE */
#endif /* BUILD_X11 */
#ifdef BUILD_NCURSES
#include <ncurses.h>
@@ -1820,6 +1823,24 @@ static void update_text() {
int inotify_fd = -1;
#endif
+#ifdef BUILD_XSHAPE
+static bool need_null_shape = true;
+ /* allow only decorated windows to be given mouse input */
+void set_null_shape(void){
+ int major_version, minor_version;
+ if (!XShapeQueryVersion(display, &major_version, &minor_version)) {
+ NORM_ERR("Input shapes are not supported");
+ } else {
+ if (own_window.get(*state) &&
+ (own_window_type.get(*state) != TYPE_NORMAL ||
+ (TEST_HINT(own_window_hints.get(*state), HINT_UNDECORATED)))) {
+ XShapeCombineRectangles(display, window.window, ShapeInput, 0, 0,
+ NULL, 0, ShapeSet, Unsorted);
+ }
+ }
+}
+#endif /* BUILD_XSHAPE */
+
template <typename Out>
void split(const std::string &s, char delim, Out result) {
std::stringstream ss(s);
@@ -1868,6 +1889,10 @@ void main_loop() {
sigaddset(&newmask, SIGUSR1);
#endif
+#ifdef BUILD_XSHAPE
+ set_null_shape();
+#endif /* BUILD_XSHAPE */
+
last_update_time = 0.0;
next_update_time = get_time() - fmod(get_time(), active_update_interval());
info.looped = 0;
@@ -2125,6 +2150,11 @@ void main_loop() {
/* allow conky to hold input focus. */
break;
}
+#ifdef BUILD_XSHAPE
+ else if (need_null_shape)
+ set_null_shape();
+#endif /* BUILD_XSHAPE */
+ else {
/* forward the click to the desktop window */
XUngrabPointer(display, ev.xbutton.time);
ev.xbutton.window = window.desktop;
@@ -2135,6 +2165,7 @@ void main_loop() {
XSetInputFocus(display, ev.xbutton.window, RevertToParent,
ev.xbutton.time);
}
+ }
break;
case ButtonRelease:
@@ -2146,6 +2177,11 @@ void main_loop() {
/* allow conky to hold input focus. */
break;
}
+#ifdef BUILD_XSHAPE
+ else if (need_null_shape)
+ set_null_shape();
+#endif /* BUILD_XSHAPE */
+ else {
/* forward the release to the desktop window */
ev.xbutton.window = window.desktop;
ev.xbutton.x = ev.xbutton.x_root;
@@ -2153,6 +2189,7 @@ void main_loop() {
XSendEvent(display, ev.xbutton.window, False, ButtonReleaseMask,
&ev);
}
+ }
break;
#endif
|