From a591228b7115db0efe2cfc33a2d8f801db690dab Mon Sep 17 00:00:00 2001 From: Tin Date: Thu, 9 Nov 2023 14:05:27 +0100 Subject: [PATCH] Modify CI and Nix flake Code tweaks Signed-off-by: Tin --- .github/workflows/build-and-test-macos.yaml | 1 + flake.nix | 3 +++ src/display-x11.cc | 6 ------ src/main.cc | 7 +++++-- src/x11.cc | 22 ++++++++++++--------- 5 files changed, 22 insertions(+), 17 deletions(-) diff --git a/.github/workflows/build-and-test-macos.yaml b/.github/workflows/build-and-test-macos.yaml index ce3e6962..bee686d9 100644 --- a/.github/workflows/build-and-test-macos.yaml +++ b/.github/workflows/build-and-test-macos.yaml @@ -37,6 +37,7 @@ jobs: libxft \ libxinerama \ libxfixes \ + libxi \ lua \ ninja \ pkg-config diff --git a/flake.nix b/flake.nix index 51dad51a..836f1c9b 100644 --- a/flake.nix +++ b/flake.nix @@ -77,6 +77,9 @@ xorg.libXfixes xorg.libXft xorg.libXinerama + xorg.libXi + xorg.libxcb + xorg.xcbutilerrors ] ++ lib.optional stdenv.isDarwin darwin.libobjc; }; diff --git a/src/display-x11.cc b/src/display-x11.cc index 8e63c1eb..3558608d 100644 --- a/src/display-x11.cc +++ b/src/display-x11.cc @@ -391,13 +391,10 @@ bool display_output_x11::main_loop_wait(double t) { // 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); - //printf("over: %#x w:%#x d:%#x r:%#x\n", query_result, window.window, window.desktop, window.root); - 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))) { - //puts("over self"); if (!cursor_inside) { llua_mouse_hook(mouse_crossing_event( mouse_event_t::AREA_ENTER, @@ -407,15 +404,12 @@ bool display_output_x11::main_loop_wait(double t) { } cursor_inside = true; } else if (cursor_inside) { - //puts("left"); llua_mouse_hook(mouse_crossing_event( mouse_event_t::AREA_LEAVE, data->root_x - window.x, data->root_y - window.x, data->root_x, data->root_y )); cursor_inside = false; - } else { - //printf("not over self\n"); } } XFreeEventData(display, &ev.xcookie); diff --git a/src/main.cc b/src/main.cc index 78e4368d..9c67c94f 100644 --- a/src/main.cc +++ b/src/main.cc @@ -172,6 +172,9 @@ static void print_version() { #ifdef BUILD_XFT << _(" * Xft\n") #endif /* BUILD_XFT */ +#ifdef BUILD_XINPUT + << _(" * Xinput\n") +#endif /* BUILD_XINPUT */ #ifdef BUILD_ARGB << _(" * ARGB visual\n") #endif /* BUILD_ARGB */ @@ -180,13 +183,13 @@ static void print_version() { #endif #ifdef BUILD_MOUSE_EVENTS << _(" * Mouse events\n") -#endif +#endif /* BUILD_MOUSE_EVENTS */ #endif /* BUILD_X11 */ #ifdef BUILD_WAYLAND << _(" Wayland:\n") #ifdef BUILD_MOUSE_EVENTS << _(" * Mouse events\n") -#endif +#endif /* BUILD_MOUSE_EVENTS */ #endif /* BUILD_WAYLAND */ #if defined BUILD_AUDACIOUS || defined BUILD_CMUS || defined BUILD_MPD || \ defined BUILD_MOC || defined BUILD_XMMS2 diff --git a/src/x11.cc b/src/x11.cc index b7985f85..8d6c2e11 100644 --- a/src/x11.cc +++ b/src/x11.cc @@ -38,8 +38,9 @@ #include #include #include -#include #include +#include +#include #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wvariadic-macros" @@ -250,8 +251,9 @@ x11_error_handler(Display *d, XErrorEvent *err) { const char *extension; const char *base_name = xcb_errors_get_name_for_error(xcb_errors_ctx, err->error_code, &extension); if (extension != nullptr) { - error_name = new char(strlen(base_name) + strlen(extension) + 4); - sprintf(error_name, "%s (%s)", base_name, extension); + const size_t size = strlen(base_name) + strlen(extension) + 4; + error_name = new char(size); + snprintf(error_name, size, "%s (%s)", base_name, extension); name_allocated = true; } else { error_name = const_cast(base_name); @@ -260,8 +262,9 @@ x11_error_handler(Display *d, XErrorEvent *err) { const char *major = xcb_errors_get_name_for_major_code(xcb_errors_ctx, err->request_code); const char *minor = xcb_errors_get_name_for_minor_code(xcb_errors_ctx, err->request_code, err->minor_code); if (minor != nullptr) { - code_description = new char(strlen(base_name) + strlen(extension) + 4); - sprintf(code_description, "%s - %s", major, minor); + const size_t size = strlen(base_name) + strlen(extension) + 4; + code_description = new char(size); + snprintf(code_description, size, "%s - %s", major, minor); code_allocated = true; } else { code_description = const_cast(major); @@ -280,16 +283,17 @@ x11_error_handler(Display *d, XErrorEvent *err) { } else { static char code_name_buffer[3]; error_name = reinterpret_cast(&code_name_buffer); - sprintf(error_name, "%d", err->error_code); + snprintf(error_name, 3, "%d", err->error_code); } } if (code_description == nullptr) { - code_description = new char(30 + 6 + 1); - sprintf(code_description, "error code: [major: %i, minor: %i]", err->request_code, err->minor_code); + const size_t size = 37; + code_description = new char(size); + snprintf(code_description, size, "error code: [major: %i, minor: %i]", err->request_code, err->minor_code); code_allocated = true; } - NORM_ERR( + DBGP( "X %s Error:\n" "Display: %lx, XID: %li, Serial: %lu\n" "%s",