mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-11-16 01:57:09 +00:00
Simplify cursor checking
Additional tweaks and docs improvements Signed-off-by: Tin <tin.svagelj@live.com>
This commit is contained in:
parent
a591228b71
commit
965d7dc0a4
@ -369,7 +369,7 @@ values:
|
|||||||
- name: overwrite_file
|
- name: overwrite_file
|
||||||
desc: Overwrite the file given as argument.
|
desc: Overwrite the file given as argument.
|
||||||
- name: own_window
|
- name: own_window
|
||||||
desc: Boolean, create own window to draw.
|
desc: Boolean, draw conky in own window instead of drawing on root window.
|
||||||
- name: own_window_argb_value
|
- name: own_window_argb_value
|
||||||
desc: |-
|
desc: |-
|
||||||
When ARGB visuals are enabled, this use this to modify the
|
When ARGB visuals are enabled, this use this to modify the
|
||||||
@ -388,7 +388,7 @@ values:
|
|||||||
desc: |-
|
desc: |-
|
||||||
If own_window_transparent no, set a specified background
|
If own_window_transparent no, set a specified background
|
||||||
colour. Takes either a hex value (e.g. '#ffffff'),
|
colour. Takes either a hex value (e.g. '#ffffff'),
|
||||||
a shorthand hex value (e.g. '#fff'), or a valid RGB nam
|
a shorthand hex value (e.g. '#fff'), or a valid RGB name
|
||||||
(see `/usr/lib/X11/rgb.txt`).
|
(see `/usr/lib/X11/rgb.txt`).
|
||||||
default: black
|
default: black
|
||||||
args:
|
args:
|
||||||
|
@ -382,13 +382,12 @@ bool display_output_x11::main_loop_wait(double t) {
|
|||||||
|
|
||||||
XNextEvent(display, &ev);
|
XNextEvent(display, &ev);
|
||||||
|
|
||||||
#ifdef BUILD_XINPUT
|
#if defined(BUILD_MOUSE_EVENTS) && defined(BUILD_XINPUT)
|
||||||
if (ev.type == GenericEvent && ev.xcookie.extension == window.xi_opcode) {
|
if (ev.type == GenericEvent && ev.xcookie.extension == window.xi_opcode) {
|
||||||
XGetEventData(display, &ev.xcookie);
|
XGetEventData(display, &ev.xcookie);
|
||||||
if (ev.xcookie.evtype == XI_Motion) {
|
if (ev.xcookie.evtype == XI_Motion) {
|
||||||
auto *data = reinterpret_cast<XIDeviceEvent*>(ev.xcookie.data);
|
auto *data = reinterpret_cast<XIDeviceEvent*>(ev.xcookie.data);
|
||||||
|
|
||||||
// XQueryPointer returns wrong results because conky is a weird window
|
|
||||||
Window query_result = query_x11_window_at_pos(display, data->root_x, data->root_y);
|
Window query_result = query_x11_window_at_pos(display, data->root_x, data->root_y);
|
||||||
|
|
||||||
static bool cursor_inside = false;
|
static bool cursor_inside = false;
|
||||||
@ -415,7 +414,7 @@ bool display_output_x11::main_loop_wait(double t) {
|
|||||||
XFreeEventData(display, &ev.xcookie);
|
XFreeEventData(display, &ev.xcookie);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
#endif /* BUILD_XINPUT */
|
#endif /* BUILD_MOUSE_EVENTS && BUILD_XINPUT */
|
||||||
|
|
||||||
// Any of the remaining events apply to conky window
|
// Any of the remaining events apply to conky window
|
||||||
if (ev.xany.window != window.window) continue;
|
if (ev.xany.window != window.window) continue;
|
||||||
|
31
src/x11.cc
31
src/x11.cc
@ -1381,7 +1381,9 @@ void propagate_x11_event(XEvent &ev) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef BUILD_MOUSE_EVENTS
|
#ifdef BUILD_MOUSE_EVENTS
|
||||||
Window last_descendant(Display* display, Window parent) {
|
// Assuming parent has a simple linear stack of descendants, this function
|
||||||
|
// returns the last leaf on the graph.
|
||||||
|
inline Window last_descendant(Display* display, Window parent) {
|
||||||
Window ignored, *children;
|
Window ignored, *children;
|
||||||
uint32_t count;
|
uint32_t count;
|
||||||
|
|
||||||
@ -1398,26 +1400,19 @@ Window last_descendant(Display* display, Window parent) {
|
|||||||
Window query_x11_window_at_pos(Display* display, int x, int y) {
|
Window query_x11_window_at_pos(Display* display, int x, int y) {
|
||||||
Window root = DefaultRootWindow(display);
|
Window root = DefaultRootWindow(display);
|
||||||
|
|
||||||
Window root_return, parent_return, *windows;
|
// these values are ignored but NULL can't be passed
|
||||||
unsigned int count;
|
Window root_return;
|
||||||
|
int root_x_return, root_y_return, win_x_return, win_y_return;
|
||||||
|
unsigned int mask_return;
|
||||||
|
|
||||||
Window last = None;
|
Window last = None;
|
||||||
|
XQueryPointer(display, window.root, &root_return, &last,
|
||||||
|
&root_x_return, &root_y_return, &win_x_return, &win_y_return, &mask_return
|
||||||
|
);
|
||||||
|
|
||||||
XWindowAttributes attrs;
|
// X11 correctly returns a window which covers conky area, but returned window
|
||||||
if (XQueryTree(display, root, &root_return, &parent_return, &windows, &count) != 0) {
|
// is not window.window, but instead a parent node in some cases and the
|
||||||
for (unsigned int i = 0; i < count; i++) {
|
// window.window we want to check for is a 1x1 child of that window.
|
||||||
if (XGetWindowAttributes(display, windows[i], &attrs)) {
|
|
||||||
if (attrs.map_state == IsViewable && x >= attrs.x && x < (attrs.x + attrs.width) && y >= attrs.y && y < (attrs.y + attrs.height)) {
|
|
||||||
last = windows[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (count != 0) {
|
|
||||||
XFree(windows);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return last_descendant(display, last);
|
return last_descendant(display, last);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,7 +150,6 @@ InputEvent *xev_as_input_event(XEvent &ev);
|
|||||||
void propagate_x11_event(XEvent &ev);
|
void propagate_x11_event(XEvent &ev);
|
||||||
|
|
||||||
#ifdef BUILD_MOUSE_EVENTS
|
#ifdef BUILD_MOUSE_EVENTS
|
||||||
|
|
||||||
Window query_x11_window_at_pos(Display* display, int x, int y);
|
Window query_x11_window_at_pos(Display* display, int x, int y);
|
||||||
#endif /* BUILD_MOUSE_EVENTS */
|
#endif /* BUILD_MOUSE_EVENTS */
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user