XGrabPointer doesn't seem to be doing what I want.
This commit is contained in:
@@ -5,6 +5,7 @@
|
|||||||
#include "Engine/Core/Math/Vector2.h"
|
#include "Engine/Core/Math/Vector2.h"
|
||||||
#include "Engine/Core/Delegate.h"
|
#include "Engine/Core/Delegate.h"
|
||||||
#include "Engine/Core/Log.h"
|
#include "Engine/Core/Log.h"
|
||||||
|
#include "Engine/Platform/Linux/LinuxPlatform.h"
|
||||||
|
|
||||||
#include "Engine/Platform/Linux/IncludeX11.h"
|
#include "Engine/Platform/Linux/IncludeX11.h"
|
||||||
|
|
||||||
@@ -40,7 +41,7 @@ Int2 ScreenUtilities::GetScreenCursorPosition()
|
|||||||
X11::Window rootWindowBuffer;
|
X11::Window rootWindowBuffer;
|
||||||
int rootX, rootY;
|
int rootX, rootY;
|
||||||
int winXBuffer, winYBuffer;
|
int winXBuffer, winYBuffer;
|
||||||
uint maskBuffer;
|
unsigned int maskBuffer;
|
||||||
|
|
||||||
int gotPointer = X11::XQueryPointer(display, rootWindow, &rootWindowBuffer, &rootWindowBuffer, &rootX, &rootY, &winXBuffer, &winYBuffer, &maskBuffer);
|
int gotPointer = X11::XQueryPointer(display, rootWindow, &rootWindowBuffer, &rootWindowBuffer, &rootX, &rootY, &winXBuffer, &winYBuffer, &maskBuffer);
|
||||||
if (!gotPointer) {
|
if (!gotPointer) {
|
||||||
@@ -59,28 +60,43 @@ class ScreenUtilitiesLinux
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static void BlockAndReadMouse();
|
static void BlockAndReadMouse();
|
||||||
|
static void xEventHandler(void* event);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void ScreenUtilitiesLinux::xEventHandler(void* eventPtr) {
|
||||||
|
X11::XEvent* event = (X11::XEvent*) eventPtr;
|
||||||
|
|
||||||
|
LOG(Warning, "Got event. {0}", event->type);
|
||||||
|
|
||||||
|
if (0) {
|
||||||
|
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.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ScreenUtilitiesLinux::BlockAndReadMouse()
|
void ScreenUtilitiesLinux::BlockAndReadMouse()
|
||||||
{
|
{
|
||||||
X11::Display* display = X11::XOpenDisplay(NULL);
|
X11::Display* display = X11::XOpenDisplay(NULL);
|
||||||
X11::Window rootWindow = X11::XRootWindow(display, X11::XDefaultScreen(display));
|
X11::Window rootWindow = X11::XRootWindow(display, X11::XDefaultScreen(display));
|
||||||
|
|
||||||
int grabbedPointer = X11::XGrabPointer(display, rootWindow, 0, Button1Mask, GrabModeAsync, GrabModeAsync, rootWindow, NULL, CurrentTime);
|
int grabbedPointer = X11::XGrabPointer(display, rootWindow, 1, Button1Mask, GrabModeAsync, GrabModeAsync, rootWindow, NULL, CurrentTime);
|
||||||
if (grabbedPointer != GrabSuccess) {
|
if (grabbedPointer != GrabSuccess) {
|
||||||
LOG(Error, "Failed to grab cursor for events.");
|
LOG(Error, "Failed to grab cursor for events.");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// No idea how to proceed from here for events.
|
LinuxPlatform::xEventRecieved.Bind(xEventHandler);
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Delegate<Color32> ScreenUtilities::PickColorDone;
|
Delegate<Color32> ScreenUtilities::PickColorDone;
|
||||||
|
|
||||||
void ScreenUtilities::PickColor()
|
void ScreenUtilities::PickColor()
|
||||||
{
|
{
|
||||||
return;
|
ScreenUtilitiesLinux::BlockAndReadMouse();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -5,6 +5,7 @@
|
|||||||
#include "LinuxPlatform.h"
|
#include "LinuxPlatform.h"
|
||||||
#include "LinuxWindow.h"
|
#include "LinuxWindow.h"
|
||||||
#include "LinuxInput.h"
|
#include "LinuxInput.h"
|
||||||
|
#include "IncludeX11.h"
|
||||||
#include "Engine/Core/Log.h"
|
#include "Engine/Core/Log.h"
|
||||||
#include "Engine/Core/Types/Guid.h"
|
#include "Engine/Core/Types/Guid.h"
|
||||||
#include "Engine/Core/Types/String.h"
|
#include "Engine/Core/Types/String.h"
|
||||||
@@ -30,7 +31,6 @@
|
|||||||
#include "Engine/Input/Input.h"
|
#include "Engine/Input/Input.h"
|
||||||
#include "Engine/Input/Mouse.h"
|
#include "Engine/Input/Mouse.h"
|
||||||
#include "Engine/Input/Keyboard.h"
|
#include "Engine/Input/Keyboard.h"
|
||||||
#include "IncludeX11.h"
|
|
||||||
#include <sys/resource.h>
|
#include <sys/resource.h>
|
||||||
#include <sys/sysinfo.h>
|
#include <sys/sysinfo.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
@@ -2217,6 +2217,8 @@ void LinuxPlatform::BeforeRun()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Delegate<void*> LinuxPlatform::xEventRecieved;
|
||||||
|
|
||||||
void LinuxPlatform::Tick()
|
void LinuxPlatform::Tick()
|
||||||
{
|
{
|
||||||
UnixPlatform::Tick();
|
UnixPlatform::Tick();
|
||||||
@@ -2234,7 +2236,8 @@ void LinuxPlatform::Tick()
|
|||||||
|
|
||||||
if (X11::XFilterEvent(&event, 0))
|
if (X11::XFilterEvent(&event, 0))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
xEventRecieved(&event); // Fire the event, since we recieved an event.
|
||||||
LinuxWindow* window;
|
LinuxWindow* window;
|
||||||
switch (event.type)
|
switch (event.type)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -33,6 +33,11 @@ public:
|
|||||||
/// <returns>The user home directory.</returns>
|
/// <returns>The user home directory.</returns>
|
||||||
static const String& GetHomeDirectory();
|
static const String& GetHomeDirectory();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// An event that is fired when an XEvent is recieved by Flax.
|
||||||
|
/// </summary>
|
||||||
|
static Delegate<void*> xEventRecieved;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// [UnixPlatform]
|
// [UnixPlatform]
|
||||||
|
|||||||
Reference in New Issue
Block a user