From 3180ad2104501d3f60fc03a74e411f27ed0f5c27 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Thu, 25 Nov 2021 17:57:50 +0100 Subject: [PATCH] Root window now has a cursor --- CMakeLists.txt | 1 + README.md | 2 +- src/defines.hpp | 1 + src/windowManager.cpp | 22 +++++++++++++++++----- src/windowManager.hpp | 4 ++++ 5 files changed, 24 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 34a347c..1bc23c6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,5 +25,6 @@ target_link_libraries(Hypr xcb-keysyms xcb-randr xcb-xinerama + xcb-cursor ${CMAKE_THREAD_LIBS_INIT} ) \ No newline at end of file diff --git a/README.md b/README.md index ce1c613..f4a8404 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ Hypr is a Linux tiling window manager for Xorg. It's written in XCB with modern - [ ] Upgrade the status bar rendering to Cairo - [ ] Better status bar configability - [ ] Rounded corners -- [ ] Replace default X11 cursor with the pointer +- [x] Replace default X11 cursor with the pointer - [x] Fix ghost windows once and for all - [ ] Fix windows minimizing themselves to tray not being able to come back without pkill - [x] Moving windows between workspaces without floating diff --git a/src/defines.hpp b/src/defines.hpp index 5c7f965..36bfb10 100644 --- a/src/defines.hpp +++ b/src/defines.hpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include diff --git a/src/windowManager.cpp b/src/windowManager.cpp index 1a5840b..eac1ed3 100644 --- a/src/windowManager.cpp +++ b/src/windowManager.cpp @@ -15,13 +15,23 @@ xcb_visualtype_t* CWindowManager::setupColors() { return nullptr; } +void CWindowManager::updateRootCursor() { + if (xcb_cursor_context_new(DisplayConnection, Screen, &pointerContext) < 0) { + Debug::log(ERR, "Creating a cursor context failed!"); + return; + } + + pointerCursor = xcb_cursor_load_cursor(pointerContext, "left_ptr"); + + Debug::log(LOG, "Cursor created with ID " + std::to_string(pointerCursor)); + + // Set the cursor + uint32_t values[1] = { pointerCursor }; + xcb_change_window_attributes(DisplayConnection, Screen->root, XCB_CW_CURSOR, values); +} + void CWindowManager::setupRandrMonitors() { - // TODO: this stopped working on my machine for some reason. - // i3 works though...? - - // finds 0 monitors - XCBQUERYCHECK(RANDRVER, xcb_randr_query_version_reply( DisplayConnection, xcb_randr_query_version(DisplayConnection, XCB_RANDR_MAJOR_VERSION, XCB_RANDR_MINOR_VERSION), &errorRANDRVER), "RandR query failed!" ); @@ -160,6 +170,8 @@ void CWindowManager::setupManager() { ConfigManager::loadConfigLoadVars(); + updateRootCursor(); + Debug::log(LOG, "Finished setup!"); // TODO: EWMH diff --git a/src/windowManager.hpp b/src/windowManager.hpp index 16b7aed..b9d5c71 100644 --- a/src/windowManager.hpp +++ b/src/windowManager.hpp @@ -46,6 +46,9 @@ public: std::atomic mainThreadBusy = false; std::atomic animationUtilBusy = false; + xcb_cursor_t pointerCursor; + xcb_cursor_context_t* pointerContext; + CWindow* getWindowFromDrawable(int64_t); void addWindowToVectorSafe(CWindow); void removeWindowFromVectorSafe(int64_t); @@ -100,6 +103,7 @@ public: void cleanupUnusedWorkspaces(); xcb_visualtype_t* setupColors(); void updateBarInfo(); + void updateRootCursor(); };