Skip to content

Commit d97f4df

Browse files
akoropbrndnmtthws
authored andcommitted
Make mouse-through workable (#213)
1 parent e219a0f commit d97f4df

File tree

2 files changed

+18
-22
lines changed

2 files changed

+18
-22
lines changed

src/conky.cc

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@
6060
#ifdef BUILD_IMLIB2
6161
#include "imlib2.h"
6262
#endif /* BUILD_IMLIB2 */
63+
#ifdef BUILD_XSHAPE
64+
#include <X11/extensions/shape.h>
65+
#endif /* BUILD_XSHAPE */
6366
#endif /* BUILD_X11 */
6467
#ifdef BUILD_NCURSES
6568
#include <ncurses.h>
@@ -2070,6 +2073,21 @@ static void main_loop(void)
20702073
sigaddset(&newmask, SIGUSR1);
20712074
#endif
20722075

2076+
#ifdef BUILD_XSHAPE
2077+
/* allow only decorated windows to be given mouse input */
2078+
int major_version, minor_version;
2079+
if (!XShapeQueryVersion(display, &major_version, &minor_version)) {
2080+
NORM_ERR("Input shapes are not supported");
2081+
} else {
2082+
if (own_window.get(*state) &&
2083+
(own_window_type.get(*state) != TYPE_NORMAL ||
2084+
(TEST_HINT(own_window_hints.get(*state), HINT_UNDECORATED)))) {
2085+
XShapeCombineRectangles(display, window.window, ShapeInput, 0, 0,
2086+
NULL, 0, ShapeSet, Unsorted);
2087+
}
2088+
}
2089+
#endif /* BUILD_XSHAPE */
2090+
20732091
last_update_time = 0.0;
20742092
next_update_time = get_time() - fmod(get_time(), active_update_interval());
20752093
info.looped = 0;

src/x11.cc

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,6 @@
4747
#ifdef BUILD_XFT
4848
#include <X11/Xft/Xft.h>
4949
#endif
50-
#ifdef BUILD_XSHAPE
51-
#include <X11/extensions/shape.h>
52-
#include <X11/extensions/shapeconst.h>
53-
#endif
5450
#ifdef BUILD_XINERAMA
5551
#include <X11/extensions/Xinerama.h>
5652
#endif
@@ -771,24 +767,6 @@ static void init_window(lua::state &l __attribute__((unused)), bool own)
771767
/* allow decorated windows to be given input focus by WM */
772768
wmHint.input =
773769
TEST_HINT(hints, HINT_UNDECORATED) ? False : True;
774-
#ifdef BUILD_XSHAPE
775-
if (!wmHint.input) {
776-
int event_base, error_base;
777-
if (XShapeQueryExtension(display, &event_base, &error_base)) {
778-
int major_version = 0, minor_version = 0;
779-
XShapeQueryVersion(display, &major_version, &minor_version);
780-
if ((major_version > 1) || ((major_version == 1) && (minor_version >=1))) {
781-
Region empty_region = XCreateRegion();
782-
XShapeCombineRegion(display, window.window, ShapeInput, 0, 0, empty_region, ShapeSet);
783-
XDestroyRegion(empty_region);
784-
} else {
785-
NORM_ERR("Input shapes are not supported");
786-
}
787-
} else {
788-
NORM_ERR("No shape extension found");
789-
}
790-
}
791-
#endif
792770
if (own_window_type.get(l) == TYPE_DOCK || own_window_type.get(l) == TYPE_PANEL) {
793771
wmHint.initial_state = WithdrawnState;
794772
} else {

0 commit comments

Comments
 (0)