steamcompmgr: Add GAMESCOPE_CURSOR_VISIBLE_FEEDBACK

This commit is contained in:
Joshua Ashton 2022-09-23 20:44:51 +00:00
parent 122ba3dda9
commit 7f2db65c00
3 changed files with 35 additions and 2 deletions

View file

@ -900,6 +900,7 @@ MouseCursor::MouseCursor(xwayland_ctx_t *ctx)
{
m_lastX = g_nNestedWidth / 2;
m_lastY = g_nNestedHeight / 2;
updateCursorFeedback( true );
}
void MouseCursor::queryPositions(int &rootX, int &rootY, int &winX, int &winY)
@ -973,6 +974,8 @@ void MouseCursor::checkSuspension()
nudge_steamcompmgr();
}
}
updateCursorFeedback();
}
void MouseCursor::warp(int x, int y)
@ -1162,6 +1165,7 @@ void MouseCursor::move(int x, int y)
XWarpPointer(m_ctx->dpy, None, x11_win(m_ctx->focus.inputFocusWindow), 0, 0, 0, 0, m_lastX, m_lastY);
}
m_hideForMovement = false;
updateCursorFeedback();
}
void MouseCursor::updatePosition()
@ -1235,8 +1239,10 @@ bool MouseCursor::getTexture()
}
m_dirty = false;
updateCursorFeedback();
if (m_imageEmpty) {
return false;
}
@ -1257,7 +1263,7 @@ bool MouseCursor::getTexture()
void MouseCursor::paint(win *window, win *fit, struct FrameInfo_t *frameInfo)
{
if (m_hideForMovement || m_imageEmpty) {
if ( m_hideForMovement || m_imageEmpty ) {
return;
}
@ -1334,6 +1340,25 @@ void MouseCursor::paint(win *window, win *fit, struct FrameInfo_t *frameInfo)
layer->blackBorder = false;
}
void MouseCursor::updateCursorFeedback( bool bForce )
{
// Can't resolve this until cursor is un-dirtied.
if ( m_dirty && !bForce )
return;
bool bVisible = !isHidden();
if ( m_bCursorVisibleFeedback == bVisible && !bForce )
return;
uint32_t value = bVisible ? 1 : 0;
XChangeProperty(m_ctx->dpy, m_ctx->root, m_ctx->atoms.gamescopeCursorVisibleFeedback, XA_CARDINAL, 32, PropModeReplace,
(unsigned char *)&value, 1 );
m_bCursorVisibleFeedback = bVisible;
}
struct BaseLayerInfo_t
{
float scale[2];
@ -5158,6 +5183,8 @@ void init_xwayland_ctx(gamescope_xwayland_server_t *xwayland_server)
ctx->atoms.gamescopeDisplayIsExternal = XInternAtom( ctx->dpy, "GAMESCOPE_DISPLAY_IS_EXTERNAL", false );
ctx->atoms.gamescopeDisplayModeListExternal = XInternAtom( ctx->dpy, "GAMESCOPE_DISPLAY_MODE_LIST_EXTERNAL", false );
ctx->atoms.gamescopeCursorVisibleFeedback = XInternAtom( ctx->dpy, "GAMESCOPE_CURSOR_VISIBLE_FEEDBACK", false );
ctx->atoms.wineHwndStyle = XInternAtom( ctx->dpy, "_WINE_HWND_STYLE", false );
ctx->atoms.wineHwndStyleEx = XInternAtom( ctx->dpy, "_WINE_HWND_EXSTYLE", false );

View file

@ -58,7 +58,7 @@ public:
void hide() { m_lastMovedTime = 0; checkSuspension(); }
bool isHidden() { return m_hideForMovement; }
bool isHidden() { return m_hideForMovement || m_imageEmpty; }
void forcePosition(int x, int y)
{
@ -77,6 +77,8 @@ private:
bool getTexture();
void updateCursorFeedback( bool bForce = false );
int m_x = 0, m_y = 0;
int m_hotspotX = 0, m_hotspotY = 0;
@ -93,6 +95,8 @@ private:
int m_lastX = 0;
int m_lastY = 0;
bool m_bCursorVisibleFeedback = false;
};
extern std::vector< wlr_surface * > wayland_surfaces_deleted;

View file

@ -153,6 +153,8 @@ struct xwayland_ctx_t
Atom gamescopeDisplayIsExternal;
Atom gamescopeDisplayModeListExternal;
Atom gamescopeCursorVisibleFeedback;
Atom wineHwndStyle;
Atom wineHwndStyleEx;
} atoms;