Skip to content

Commit

Permalink
Make mouse-through workable (#213)
Browse files Browse the repository at this point in the history
  • Loading branch information
akorop authored and brndnmtthws committed Jan 19, 2018
1 parent e219a0f commit d97f4df
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 22 deletions.
18 changes: 18 additions & 0 deletions src/conky.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,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>
Expand Down Expand Up @@ -2070,6 +2073,21 @@ static void main_loop(void)
sigaddset(&newmask, SIGUSR1);
#endif

#ifdef BUILD_XSHAPE
/* allow only decorated windows to be given mouse input */
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 */

last_update_time = 0.0;
next_update_time = get_time() - fmod(get_time(), active_update_interval());
info.looped = 0;
Expand Down
22 changes: 0 additions & 22 deletions src/x11.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@
#ifdef BUILD_XFT
#include <X11/Xft/Xft.h>
#endif
#ifdef BUILD_XSHAPE
#include <X11/extensions/shape.h>
#include <X11/extensions/shapeconst.h>
#endif
#ifdef BUILD_XINERAMA
#include <X11/extensions/Xinerama.h>
#endif
Expand Down Expand Up @@ -771,24 +767,6 @@ static void init_window(lua::state &l __attribute__((unused)), bool own)
/* allow decorated windows to be given input focus by WM */
wmHint.input =
TEST_HINT(hints, HINT_UNDECORATED) ? False : True;
#ifdef BUILD_XSHAPE
if (!wmHint.input) {
int event_base, error_base;
if (XShapeQueryExtension(display, &event_base, &error_base)) {
int major_version = 0, minor_version = 0;
XShapeQueryVersion(display, &major_version, &minor_version);
if ((major_version > 1) || ((major_version == 1) && (minor_version >=1))) {
Region empty_region = XCreateRegion();
XShapeCombineRegion(display, window.window, ShapeInput, 0, 0, empty_region, ShapeSet);
XDestroyRegion(empty_region);
} else {
NORM_ERR("Input shapes are not supported");
}
} else {
NORM_ERR("No shape extension found");
}
}
#endif
if (own_window_type.get(l) == TYPE_DOCK || own_window_type.get(l) == TYPE_PANEL) {
wmHint.initial_state = WithdrawnState;
} else {
Expand Down

0 comments on commit d97f4df

Please sign in to comment.