mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-22 06:15:58 +00:00
Merge remote-tracking branch 'origin/main' into feat/flatpak-support
This commit is contained in:
commit
58ec3609b6
24 files changed
+2141
-67
No files matched your search
@@ -30,6 +30,14 @@ library list, before anything is published.
|
||||
down moves nothing - so in the app's touchpad mode the Steam client saw no hover and a click landed
|
||||
wherever the pointer had last been. The motion now always warps the real pointer as well
|
||||
(`bAlwaysWarpCursor`), which the other touch modes did already.
|
||||
- `0112-restore-iconified-game-on-resume.patch` - this app: the Steam menu is an overlay that
|
||||
takes input without changing the focus window, and a fullscreen wine game minimizes itself when
|
||||
it loses input. gamescope only takes a window out of iconic when the focus window changes, and
|
||||
wine will not activate a window it believes iconic, so after Resume the game stayed minimized: a
|
||||
black screen with its small caption in the top-left corner (Titanfall 2, GE-Proton 11). The
|
||||
iconify request is remembered and the window goes back to NormalState before input returns to it,
|
||||
then focus is handed over again. `GAMESCOPE_RESTORE_FOCUS_WINDOW` on the root window asks for the
|
||||
same restore from outside (the session script's resume watcher).
|
||||
|
||||
Sixteen more of Armada's patches are DRM/lease/HDR-on-KMS work for a native display, which this
|
||||
app's Wayland-hosted gamescope never reaches, or need a newer gamescope than the runtime has.
|
||||
@@ -0,0 +1,108 @@
|
||||
From: DroidDeck
|
||||
Subject: [PATCH] steamcompmgr: restore a game that minimized itself behind the Steam menu
|
||||
|
||||
The Steam menu is an overlay that takes input without changing the focus window. A fullscreen
|
||||
wine game minimizes itself when it loses input (WM_CHANGE_STATE IconicState, which gamescope
|
||||
fakes by setting WM_STATE). gamescope only puts a window back to NormalState when the focus
|
||||
window changes, which never happens here, and wine will not activate a window it believes
|
||||
iconic - so after Resume the game stayed minimized: a black screen with its 160x24 caption in
|
||||
the top-left corner, 0 fps (seen with Titanfall 2 on GE-Proton 11).
|
||||
|
||||
Remember the iconify request, restore NormalState before input returns to that window, and hand
|
||||
focus over again so wine sees the restore before the activation. GAMESCOPE_RESTORE_FOCUS_WINDOW
|
||||
on the root window asks for the same thing from outside.
|
||||
|
||||
diff --git a/src/steamcompmgr.cpp b/src/steamcompmgr.cpp
|
||||
index 08afbc4..372a82c 100644
|
||||
--- a/src/steamcompmgr.cpp
|
||||
+++ b/src/steamcompmgr.cpp
|
||||
@@ -4708,6 +4708,7 @@ void xwayland_ctx_t::DetermineAndApplyFocus( const std::vector< steamcompmgr_win
|
||||
/* Some games (e.g. DOOM Eternal) don't react well to being put back as
|
||||
* iconic, so never do that. Only take them out of iconic. */
|
||||
set_wm_state( ctx, id, ICCCM_NORMAL_STATE );
|
||||
+ ctx->focus.focusWindow->iconifyRequested = false;
|
||||
|
||||
gpuvis_trace_printf( "determine_and_apply_focus focus %lu", id );
|
||||
|
||||
@@ -4795,6 +4796,19 @@ void xwayland_ctx_t::DetermineAndApplyFocus( const std::vector< steamcompmgr_win
|
||||
if ( keyboardFocusWindow && ctx->currentKeyboardFocusWindow && find_win( ctx, ctx->currentKeyboardFocusWindow ) == keyboardFocusWin )
|
||||
keyboardFocusWindow = ctx->currentKeyboardFocusWindow;
|
||||
|
||||
+ // An overlay that takes input (the Steam menu) moves input away without changing the focus window, and a
|
||||
+ // fullscreen game iconifies itself when it loses input. The focus window never changed, so it is never taken
|
||||
+ // out of iconic above, and wine will not activate a window it believes iconic: the game stays minimized
|
||||
+ // (its 160x24 caption in the corner) after Resume. Put it back to NormalState before input returns to it,
|
||||
+ // then hand focus over again so wine sees the restore first and the activation after it.
|
||||
+ if ( inputFocus == ctx->focus.focusWindow && ctx->focus.focusWindow->iconifyRequested )
|
||||
+ {
|
||||
+ ctx->focus.focusWindow->iconifyRequested = false;
|
||||
+ xwm_log.infof( "restoring iconified focus window 0x%lx as input returns to it", ctx->focus.focusWindow->xwayland().id );
|
||||
+ set_wm_state( ctx, ctx->focus.focusWindow->xwayland().id, ICCCM_NORMAL_STATE );
|
||||
+ ctx->currentKeyboardFocusWindow = None;
|
||||
+ }
|
||||
+
|
||||
if ( ctx->focus.inputFocusWindow != inputFocus ||
|
||||
ctx->focus.inputFocusMode != inputFocus->inputFocusMode ||
|
||||
ctx->currentKeyboardFocusWindow != keyboardFocusWindow )
|
||||
@@ -6559,6 +6573,8 @@ handle_wm_change_state(xwayland_ctx_t *ctx, steamcompmgr_win_t *w, XClientMessag
|
||||
if (state == ICCCM_ICONIC_STATE) {
|
||||
xwm_log.debugf("Faking WM_CHANGE_STATE to ICONIC for window 0x%lx", w->xwayland().id);
|
||||
set_wm_state( ctx, w->xwayland().id, ICCCM_ICONIC_STATE );
|
||||
+ w->iconifyRequested = true;
|
||||
+ MakeFocusDirty();
|
||||
} else {
|
||||
xwm_log.debugf("Unhandled WM_CHANGE_STATE to %ld for window 0x%lx", state, w->xwayland().id);
|
||||
}
|
||||
@@ -7539,6 +7555,19 @@ handle_property_notify(xwayland_ctx_t *ctx, XPropertyEvent *ev)
|
||||
if ( set_sdr_input_gain( bit_cast<float>(val) ) )
|
||||
hasRepaint = true;
|
||||
}
|
||||
+ if ( ev->atom == ctx->atoms.gamescopeRestoreFocusWindow )
|
||||
+ {
|
||||
+ // Anything outside (the session's watcher) can ask for the same restore: NormalState on the focus
|
||||
+ // window and focus handed to it again. Harmless on a window that is not iconic.
|
||||
+ if ( ctx->focus.focusWindow && get_prop( ctx, ctx->root, ctx->atoms.gamescopeRestoreFocusWindow, 0 ) )
|
||||
+ {
|
||||
+ xwm_log.infof( "restore requested for focus window 0x%lx", ctx->focus.focusWindow->xwayland().id );
|
||||
+ ctx->focus.focusWindow->iconifyRequested = false;
|
||||
+ set_wm_state( ctx, ctx->focus.focusWindow->xwayland().id, ICCCM_NORMAL_STATE );
|
||||
+ ctx->currentKeyboardFocusWindow = None;
|
||||
+ MakeFocusDirty();
|
||||
+ }
|
||||
+ }
|
||||
if ( ev->atom == ctx->atoms.gamescopeForceWindowsFullscreen )
|
||||
{
|
||||
ctx->force_windows_fullscreen = !!get_prop( ctx, ctx->root, ctx->atoms.gamescopeForceWindowsFullscreen, 0 );
|
||||
@@ -9056,6 +9085,7 @@ void init_xwayland_ctx(uint32_t serverId, gamescope_xwayland_server_t *xwayland_
|
||||
ctx->atoms.gamescopeHDRTonemapOperator = XInternAtom( ctx->dpy, "GAMESCOPE_HDR_TONEMAP_OPERATOR", false );
|
||||
|
||||
ctx->atoms.gamescopeForceWindowsFullscreen = XInternAtom( ctx->dpy, "GAMESCOPE_FORCE_WINDOWS_FULLSCREEN", false );
|
||||
+ ctx->atoms.gamescopeRestoreFocusWindow = XInternAtom( ctx->dpy, "GAMESCOPE_RESTORE_FOCUS_WINDOW", false );
|
||||
|
||||
ctx->atoms.gamescopeColorLut3DOverride = XInternAtom( ctx->dpy, "GAMESCOPE_COLOR_3DLUT_OVERRIDE", false );
|
||||
ctx->atoms.gamescopeColorShaperLutOverride = XInternAtom( ctx->dpy, "GAMESCOPE_COLOR_SHAPERLUT_OVERRIDE", false );
|
||||
diff --git a/src/steamcompmgr_shared.hpp b/src/steamcompmgr_shared.hpp
|
||||
index 66022d7..af93a23 100644
|
||||
--- a/src/steamcompmgr_shared.hpp
|
||||
+++ b/src/steamcompmgr_shared.hpp
|
||||
@@ -134,6 +134,8 @@ struct steamcompmgr_win_t {
|
||||
|
||||
bool isFullscreen = false;
|
||||
bool isSysTrayIcon = false;
|
||||
+ // The client asked to be iconified (WM_CHANGE_STATE) and has not been put back to NormalState since.
|
||||
+ bool iconifyRequested = false;
|
||||
bool sizeHintsSpecified = false;
|
||||
bool skipTaskbar = false;
|
||||
bool skipPager = false;
|
||||
diff --git a/src/xwayland_ctx.hpp b/src/xwayland_ctx.hpp
|
||||
index 7b39ecb..81910a1 100644
|
||||
--- a/src/xwayland_ctx.hpp
|
||||
+++ b/src/xwayland_ctx.hpp
|
||||
@@ -228,6 +228,7 @@ struct xwayland_ctx_t final : public gamescope::IWaitable
|
||||
Atom gamescopeHDRTonemapOperator;
|
||||
|
||||
Atom gamescopeForceWindowsFullscreen;
|
||||
+ Atom gamescopeRestoreFocusWindow;
|
||||
|
||||
Atom gamescopeColorLut3DOverride;
|
||||
Atom gamescopeColorShaperLutOverride;
|
||||
@@ -1,2 +1,2 @@
|
||||
GAMESCOPE_TAG=gamescope-3.16.29-p3
|
||||
GAMESCOPE_SHA256=566e3b93931f37c30375d440d15ee76452892b842d2dc854cd3c06b926c8451b
|
||||
GAMESCOPE_TAG=gamescope-3.16.29-p4
|
||||
GAMESCOPE_SHA256=e750fb34864bc2eb1160aeed29593e402bf9c8153fafd9fd18c77450bdd50574
|
||||
@@ -400,6 +400,26 @@ case $mode in
|
||||
fi
|
||||
done
|
||||
) &
|
||||
# Resume from the Steam menu. The menu is an overlay that takes input, and a fullscreen game that
|
||||
# loses input minimizes itself; gamescope only takes a window out of that state when the focused
|
||||
# window changes, which the menu never does, so the game stayed minimized after Resume (a black
|
||||
# screen with its small caption in the top-left corner). gamescope-3.16.29-p4 restores it itself;
|
||||
# this asks it again a moment after input comes back from the client (app 769) to anything else,
|
||||
# which covers a game that minimizes late. Harmless when nothing is minimized.
|
||||
# BL_RESTORE_ON_RESUME=0 turns it off.
|
||||
[ -z "${BL_DESKTOP:-}" ] && [ "${BL_RESTORE_ON_RESUME:-1}" = 1 ] && (
|
||||
prev=
|
||||
xprop -spy -root GAMESCOPE_FOCUSED_APP 2>/dev/null | while read -r line; do
|
||||
app=${line##*= }
|
||||
case $app in ''|*[!0-9]*) prev=; continue ;; esac
|
||||
if [ "$prev" = 769 ] && [ "$app" != 769 ]; then
|
||||
nap 1
|
||||
xprop -root -f GAMESCOPE_RESTORE_FOCUS_WINDOW 32c -set GAMESCOPE_RESTORE_FOCUS_WINDOW 1 2>/dev/null \
|
||||
&& echo "== resume: asked gamescope to restore the game window (app $app)"
|
||||
fi
|
||||
prev=$app
|
||||
done
|
||||
) &
|
||||
(
|
||||
beat=0
|
||||
for _ in $(seq 1 720); do
|
||||
|
||||
@@ -20,6 +20,14 @@
|
||||
* Only Wine's device host is answered, and only for the session's own nodes: the Steam client
|
||||
* enumerates the same nodes for itself and would take a pad wearing Steam Input's identity for one
|
||||
* of its own and ignore it. Every other caller, path and device object goes straight through.
|
||||
*
|
||||
* With libfakeinput's /dev/uinput stand-in (FAKE_EVDEV_UINPUT=1) Steam Input's own virtual pads
|
||||
* exist too, as event16 and up, and those are what Wine is meant to read: each is described with
|
||||
* the identity the client gave it, from the .uevent file libfakeinput writes beside the node.
|
||||
* While one exists the app's pads are described as what they are, an Xbox 360 controller, which
|
||||
* Wine's HID bus leaves alone - the game reads Steam Input's output, not the pad under it, as on
|
||||
* a Steam Deck. With none (Steam Input off for the game) they keep the virtual identity, so the
|
||||
* game still has a controller.
|
||||
*/
|
||||
#define _GNU_SOURCE
|
||||
#include <dlfcn.h>
|
||||
@@ -31,8 +39,11 @@
|
||||
#include <sys/sysmacros.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
/* The app opens one ring per configured controller; four is what its launcher offers. */
|
||||
#define PAD_MAX 4
|
||||
/* The app opens one ring per configured controller; four is what its launcher offers. Nodes from
|
||||
* UINPUT_BASE up are the virtual pads made through libfakeinput's /dev/uinput stand-in. */
|
||||
#define RING_MAX 4
|
||||
#define UINPUT_BASE 16
|
||||
#define PAD_MAX 64
|
||||
#define EVENT_MINOR_BASE 64
|
||||
|
||||
/* BUS_VIRTUAL, and the identity Steam Input gives the gamepad it presents to a game. */
|
||||
@@ -41,16 +52,23 @@
|
||||
"NAME=\"Generic HID Gamepad %d\"\n" \
|
||||
"PHYS=\"usb-fakeinput/input%d\"\n"
|
||||
|
||||
/* The identity libfakeinput gives the pad itself (FAKE_EVDEV_IDENTITY=xbox360). */
|
||||
#define PAD_PHYSICAL_UEVENT_FORMAT \
|
||||
"PRODUCT=3/45e/28e/110\n" \
|
||||
"NAME=\"Xbox 360 Controller (%d)\"\n" \
|
||||
"PHYS=\"usb-fakeinput/input%d\"\n"
|
||||
|
||||
struct pad {
|
||||
char syspath[64];
|
||||
char devnode[32];
|
||||
char sysname[16];
|
||||
char uevent[128];
|
||||
char uevent[256];
|
||||
dev_t devnum;
|
||||
};
|
||||
|
||||
static struct pad pads[PAD_MAX];
|
||||
static int pad_count;
|
||||
static pthread_mutex_t virtual_lock = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
/*
|
||||
* The slots the app published rings for, named in FAKE_EVDEV_MEMFD_PATHS as "<slot>=<path>"
|
||||
@@ -66,7 +84,7 @@ static void discover_pads(void) {
|
||||
char *end;
|
||||
long slot = strtol(entry, &end, 10);
|
||||
|
||||
if (end != entry && *end == '=' && slot >= 0 && slot < PAD_MAX) {
|
||||
if (end != entry && *end == '=' && slot >= 0 && slot < RING_MAX) {
|
||||
struct pad *pad = &pads[slot];
|
||||
|
||||
if (pad->devnode[0] == '\0') {
|
||||
@@ -90,6 +108,66 @@ static void ensure_pads(void) {
|
||||
pthread_once(&once, discover_pads);
|
||||
}
|
||||
|
||||
static int uinput_enabled(void) {
|
||||
const char *enabled = getenv("FAKE_EVDEV_UINPUT");
|
||||
return enabled != NULL && atoi(enabled) != 0;
|
||||
}
|
||||
|
||||
/* Reads the .uevent libfakeinput wrote for virtual pad <node> into buf; 0 when there is none. */
|
||||
static int read_virtual_uevent(int node, char *buf, size_t size) {
|
||||
const char *dir = getenv("FAKE_EVDEV_DIR");
|
||||
char path[PATH_MAX];
|
||||
FILE *file;
|
||||
size_t length;
|
||||
|
||||
if (dir == NULL) return 0;
|
||||
snprintf(path, sizeof(path), "%s/.uinput-event%d.uevent", dir, node);
|
||||
if ((file = fopen(path, "re")) == NULL) return 0;
|
||||
length = fread(buf, 1, size - 1, file);
|
||||
fclose(file);
|
||||
buf[length] = '\0';
|
||||
return length > 0;
|
||||
}
|
||||
|
||||
static int any_virtual_pad(void) {
|
||||
char uevent[256];
|
||||
int node;
|
||||
|
||||
for (node = UINPUT_BASE; node < PAD_MAX; node++)
|
||||
if (read_virtual_uevent(node, uevent, sizeof(uevent))) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Brings the entry for event<node> up to date before Wine resolves it: a virtual pad comes and
|
||||
* goes with the client, and the app's pads change identity with it.
|
||||
*/
|
||||
static void refresh_pad(int node) {
|
||||
struct pad *pad;
|
||||
|
||||
if (node < 0 || node >= PAD_MAX) return;
|
||||
pad = &pads[node];
|
||||
pthread_mutex_lock(&virtual_lock);
|
||||
if (node >= UINPUT_BASE) {
|
||||
char uevent[sizeof(pad->uevent)];
|
||||
|
||||
if (read_virtual_uevent(node, uevent, sizeof(uevent))) {
|
||||
snprintf(pad->sysname, sizeof(pad->sysname), "event%d", node);
|
||||
snprintf(pad->syspath, sizeof(pad->syspath), "/sys/devices/virtual/input/bannerlator%d", node);
|
||||
memcpy(pad->uevent, uevent, sizeof(uevent));
|
||||
pad->devnum = makedev(13, EVENT_MINOR_BASE + (unsigned int)node);
|
||||
snprintf(pad->devnode, sizeof(pad->devnode), "/dev/input/event%d", node);
|
||||
if (node >= pad_count) pad_count = node + 1;
|
||||
} else {
|
||||
pad->devnode[0] = '\0';
|
||||
}
|
||||
} else if (pad->devnode[0] != '\0' && uinput_enabled()) {
|
||||
snprintf(pad->uevent, sizeof(pad->uevent),
|
||||
any_virtual_pad() ? PAD_PHYSICAL_UEVENT_FORMAT : PAD_UEVENT_FORMAT, node, node);
|
||||
}
|
||||
pthread_mutex_unlock(&virtual_lock);
|
||||
}
|
||||
|
||||
/* The pad a synthetic syspath names, or NULL when the path is not one of ours. */
|
||||
static struct pad *pad_for_syspath(const char *syspath) {
|
||||
int i;
|
||||
@@ -123,6 +201,7 @@ static struct pad *pad_for_syslink(const char *path) {
|
||||
if (path == NULL || strncmp(path, prefix, sizeof(prefix) - 1) != 0) return NULL;
|
||||
name = path + sizeof(prefix) - 1;
|
||||
ensure_pads();
|
||||
if (strncmp(name, "event", 5) == 0 && name[5] >= '0' && name[5] <= '9') refresh_pad(atoi(name + 5));
|
||||
for (i = 0; i < pad_count; i++) {
|
||||
if (pads[i].devnode[0] != '\0' && strcmp(pads[i].sysname, name) == 0) return &pads[i];
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user