From 8c9ae90753f651578d92e8bda5eb809754f33e7a Mon Sep 17 00:00:00 2001 From: Linus Heckemann Date: Wed, 4 May 2022 08:24:47 +0200 Subject: [PATCH] Wayland fixes (#5979) * Linux/PAD: only attempt to reset X screensaver on X11 This would previously crash PCSX2 after 4096 frames on Wayland. * Linux: only grab pointer on X11 This silently disables the functionality on Wayland, but that's one step better than the previous behaviour: PCSX2 would crash when Shift-F12 was pressed. --- pcsx2/PAD/Linux/PAD.cpp | 4 ++-- pcsx2/PAD/Linux/keyboard.cpp | 2 +- pcsx2/USB/USB.cpp | 2 +- pcsx2/USB/usb-hid/evdev/evdev.cpp | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pcsx2/PAD/Linux/PAD.cpp b/pcsx2/PAD/Linux/PAD.cpp index f050a03df4..8abfad95cd 100644 --- a/pcsx2/PAD/Linux/PAD.cpp +++ b/pcsx2/PAD/Linux/PAD.cpp @@ -37,7 +37,7 @@ #include "wx_dialog/dialog.h" #ifndef __APPLE__ -Display* GSdsp; +Display* GSdsp = nullptr; Window GSwin; #endif @@ -263,7 +263,7 @@ void PADupdate(int pad) // Emulate an user activity static int count = 0; count++; - if ((count & 0xFFF) == 0) + if (GSdsp && (count & 0xFFF) == 0) { // 1 call every 4096 Vsync is enough XResetScreenSaver(GSdsp); diff --git a/pcsx2/PAD/Linux/keyboard.cpp b/pcsx2/PAD/Linux/keyboard.cpp index 30acc2ee4b..ce3c4baf15 100644 --- a/pcsx2/PAD/Linux/keyboard.cpp +++ b/pcsx2/PAD/Linux/keyboard.cpp @@ -194,7 +194,7 @@ void AnalyzeKeyEvent(HostKeyEvent& evt) #ifdef __unix__ if (evt.key == XK_Shift_R || evt.key == XK_Shift_L) s_Shift = true; - if (evt.key == XK_F12 && s_Shift) + if (evt.key == XK_F12 && s_Shift && GSdsp) { if (!s_grab_input) { diff --git a/pcsx2/USB/USB.cpp b/pcsx2/USB/USB.cpp index 4888ff5a15..d9e1bd787e 100644 --- a/pcsx2/USB/USB.cpp +++ b/pcsx2/USB/USB.cpp @@ -73,7 +73,7 @@ HWND gsWnd = nullptr; #include "gtk.h" #include #include -Display* g_GSdsp; +Display* g_GSdsp = nullptr; Window g_GSwin; #endif diff --git a/pcsx2/USB/usb-hid/evdev/evdev.cpp b/pcsx2/USB/usb-hid/evdev/evdev.cpp index d6aaaccb39..b151eade8a 100644 --- a/pcsx2/USB/usb-hid/evdev/evdev.cpp +++ b/pcsx2/USB/usb-hid/evdev/evdev.cpp @@ -206,7 +206,7 @@ namespace usb_hid if (event.code == KEY_LEFTSHIFT || event.code == KEY_RIGHTSHIFT) shift = (event.value > 0); - if (event.code == KEY_F12 && (event.value == 1) && shift) + if (event.code == KEY_F12 && (event.value == 1) && shift && g_GSdsp) { if (!grabbed) {