mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-11-19 19:45:15 +00:00
Fix buffer overflow on X11 error bug
Skip descendant checking if cursor over desktop in query_x11_window_at_pos. Simplify and correct check for whether cursor is over conky. Signed-off-by: Tin Švagelj <tin.svagelj@live.com>
This commit is contained in:
parent
56a81ef4fd
commit
27d64fe834
@ -411,15 +411,16 @@ bool display_output_x11::main_loop_wait(double t) {
|
|||||||
query_x11_window_at_pos(display, data->root_x, data->root_y);
|
query_x11_window_at_pos(display, data->root_x, data->root_y);
|
||||||
|
|
||||||
static bool cursor_inside = false;
|
static bool cursor_inside = false;
|
||||||
if ((query_result != 0 && query_result == window.window) ||
|
|
||||||
((query_result == window.desktop || query_result == window.root ||
|
|
||||||
query_result == 0) &&
|
|
||||||
data->root_x >= window.x &&
|
|
||||||
data->root_x < (window.x + window.width) &&
|
|
||||||
data->root_y >= window.y &&
|
|
||||||
data->root_y < (window.y + window.height))) {
|
|
||||||
// cursor is inside conky
|
|
||||||
|
|
||||||
|
// - over conky window
|
||||||
|
// - conky has now window, over desktop and within conky region
|
||||||
|
bool cursor_over_conky = query_result == window.window &&
|
||||||
|
(window.window != 0u ||
|
||||||
|
(data->root_x >= window.x &&
|
||||||
|
data->root_x < (window.x + window.width) &&
|
||||||
|
data->root_y >= window.y &&
|
||||||
|
data->root_y < (window.y + window.height)));
|
||||||
|
if (cursor_over_conky) {
|
||||||
if (!cursor_inside) {
|
if (!cursor_inside) {
|
||||||
llua_mouse_hook(mouse_crossing_event(
|
llua_mouse_hook(mouse_crossing_event(
|
||||||
mouse_event_t::AREA_ENTER, data->root_x - window.x,
|
mouse_event_t::AREA_ENTER, data->root_x - window.x,
|
||||||
|
@ -258,7 +258,7 @@ static int x11_error_handler(Display *d, XErrorEvent *err) {
|
|||||||
const char *minor = xcb_errors_get_name_for_minor_code(
|
const char *minor = xcb_errors_get_name_for_minor_code(
|
||||||
xcb_errors_ctx, err->request_code, err->minor_code);
|
xcb_errors_ctx, err->request_code, err->minor_code);
|
||||||
if (minor != nullptr) {
|
if (minor != nullptr) {
|
||||||
const std::size_t size = strlen(base_name) + strlen(extension) + 4;
|
const std::size_t size = strlen(major) + strlen(minor) + 4;
|
||||||
code_description = new char[size];
|
code_description = new char[size];
|
||||||
snprintf(code_description, size, "%s - %s", major, minor);
|
snprintf(code_description, size, "%s - %s", major, minor);
|
||||||
code_allocated = true;
|
code_allocated = true;
|
||||||
@ -1403,6 +1403,9 @@ Window query_x11_window_at_pos(Display *display, int x, int y) {
|
|||||||
XQueryPointer(display, window.root, &root_return, &last, &root_x_return,
|
XQueryPointer(display, window.root, &root_return, &last, &root_x_return,
|
||||||
&root_y_return, &win_x_return, &win_y_return, &mask_return);
|
&root_y_return, &win_x_return, &win_y_return, &mask_return);
|
||||||
|
|
||||||
|
// If root, last descendant will be wrong
|
||||||
|
if (last == 0) return 0;
|
||||||
|
|
||||||
// X11 correctly returns a window which covers conky area, but returned
|
// X11 correctly returns a window which covers conky area, but returned
|
||||||
// window is not window.window, but instead a parent node in some cases and
|
// window is not window.window, but instead a parent node in some cases and
|
||||||
// the window.window we want to check for is a 1x1 child of that window.
|
// the window.window we want to check for is a 1x1 child of that window.
|
||||||
|
Loading…
Reference in New Issue
Block a user