From 8f6ceece10dd548fae88793b43b25b535d221e51 Mon Sep 17 00:00:00 2001 From: Menotdan Date: Thu, 18 May 2023 19:40:39 -0400 Subject: [PATCH] Change XGrabPointer call a bit. --- .../ScreenUtilities/ScreenUtilitiesLinux.cpp | 17 +++++++++++------ Source/Engine/Platform/Linux/LinuxPlatform.cpp | 3 ++- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/Source/Editor/Utilities/ScreenUtilities/ScreenUtilitiesLinux.cpp b/Source/Editor/Utilities/ScreenUtilities/ScreenUtilitiesLinux.cpp index 15077f4f2..d4734b12d 100644 --- a/Source/Editor/Utilities/ScreenUtilities/ScreenUtilitiesLinux.cpp +++ b/Source/Editor/Utilities/ScreenUtilities/ScreenUtilitiesLinux.cpp @@ -67,14 +67,18 @@ void ScreenUtilitiesLinux::xEventHandler(void* eventPtr) { X11::XEvent* event = (X11::XEvent*) eventPtr; LOG(Warning, "Got event. {0}", event->type); + X11::Display* display = X11::XOpenDisplay(NULL); - if (0) { + if (event->type == ButtonPress) { LOG(Warning, "Got MOUSE CLICK event."); - X11::Display* display = X11::XOpenDisplay(NULL); - LOG(Warning, "Tried to ungrab pointer. {0}", X11::XUngrabPointer(display, CurrentTime)); - X11::XCloseDisplay(display); - LinuxPlatform::xEventRecieved.Unbind(xEventHandler); // Unbind the event, we only want to handle one click event. + + X11::XUngrabPointer(display, CurrentTime); + X11::XCloseDisplay(display); + } else + { + LOG(Warning, "Got a different event.."); + X11::XCloseDisplay(display); } } @@ -83,7 +87,8 @@ void ScreenUtilitiesLinux::BlockAndReadMouse() X11::Display* display = X11::XOpenDisplay(NULL); X11::Window rootWindow = X11::XRootWindow(display, X11::XDefaultScreen(display)); - int grabbedPointer = X11::XGrabPointer(display, rootWindow, 1, Button1Mask, GrabModeAsync, GrabModeAsync, rootWindow, NULL, CurrentTime); + X11::Cursor cursor = XCreateFontCursor(display, 130); + int grabbedPointer = X11::XGrabPointer(display, rootWindow, 0, ButtonPressMask, GrabModeAsync, GrabModeAsync, rootWindow, cursor, CurrentTime); if (grabbedPointer != GrabSuccess) { LOG(Error, "Failed to grab cursor for events."); return; diff --git a/Source/Engine/Platform/Linux/LinuxPlatform.cpp b/Source/Engine/Platform/Linux/LinuxPlatform.cpp index 6de848180..631b8d017 100644 --- a/Source/Engine/Platform/Linux/LinuxPlatform.cpp +++ b/Source/Engine/Platform/Linux/LinuxPlatform.cpp @@ -2237,7 +2237,8 @@ void LinuxPlatform::Tick() if (X11::XFilterEvent(&event, 0)) continue; - xEventRecieved(&event); // Fire the event, since we recieved an event. + xEventRecieved(&event); // Fire this event, since we recieved an event. + LinuxWindow* window; switch (event.type) {