Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 30 additions & 10 deletions src/steamcompmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1920,8 +1920,8 @@ void MouseCursor::paint(steamcompmgr_win_t *window, steamcompmgr_win_t *fit, str
if ( fit )
{
// If we have an override window, try to fit it in as long as it won't make our scale go below 1.0.
sourceWidth = std::max<int32_t>( sourceWidth, clamp<int>( fit->GetGeometry().nX + fit->GetGeometry().nWidth, 0, currentOutputWidth ) );
sourceHeight = std::max<int32_t>( sourceHeight, clamp<int>( fit->GetGeometry().nY + fit->GetGeometry().nHeight, 0, currentOutputHeight ) );
sourceWidth = std::max<int32_t>( sourceWidth, clamp<int>( fit->GetGeometry().nX - window->GetGeometry().nX + fit->GetGeometry().nWidth, 0, currentOutputWidth ) );
sourceHeight = std::max<int32_t>( sourceHeight, clamp<int>( fit->GetGeometry().nY - window->GetGeometry().nY + fit->GetGeometry().nHeight, 0, currentOutputHeight ) );
}

float cursor_scale = 1.0f;
Expand Down Expand Up @@ -2145,15 +2145,21 @@ paint_window_commit( const gamescope::Rc<commit_t> &lastCommit, steamcompmgr_win
if ( fit )
{
// If we have an override window, try to fit it in as long as it won't make our scale go below 1.0.
sourceWidth = std::max<uint32_t>( sourceWidth, clamp<int>( fit->GetGeometry().nX + fit->GetGeometry().nWidth, 0, currentOutputWidth ) );
sourceHeight = std::max<uint32_t>( sourceHeight, clamp<int>( fit->GetGeometry().nY + fit->GetGeometry().nHeight, 0, currentOutputHeight ) );
int32_t fitX = fit->GetGeometry().nX - scaleW->GetGeometry().nX;
int32_t fitY = fit->GetGeometry().nY - scaleW->GetGeometry().nY;
sourceWidth = std::max<uint32_t>( sourceWidth, clamp<int>( fitX + fit->GetGeometry().nWidth, 0, currentOutputWidth ) );
sourceHeight = std::max<uint32_t>( sourceHeight, clamp<int>( fitY + fit->GetGeometry().nHeight, 0, currentOutputHeight ) );

baseWidth = std::max<uint32_t>( baseWidth, clamp<int>( fit->GetGeometry().nX + fit->GetGeometry().nWidth, 0, currentOutputWidth ) );
baseHeight = std::max<uint32_t>( baseHeight, clamp<int>( fit->GetGeometry().nY + fit->GetGeometry().nHeight, 0, currentOutputHeight ) );
baseWidth = std::max<uint32_t>( baseWidth, clamp<int>( fitX + fit->GetGeometry().nWidth, 0, currentOutputWidth ) );
baseHeight = std::max<uint32_t>( baseHeight, clamp<int>( fitY + fit->GetGeometry().nHeight, 0, currentOutputHeight ) );
}
}

bool offset = ( ( w->GetGeometry().nX || w->GetGeometry().nY ) && w != scaleW );
// Compositing ignores the base window's origin, so position overrides relative to it.
int32_t winOffsetX = w->GetGeometry().nX - scaleW->GetGeometry().nX;
int32_t winOffsetY = w->GetGeometry().nY - scaleW->GetGeometry().nY;

bool offset = ( ( winOffsetX || winOffsetY ) && w != scaleW );

if (sourceWidth != (int32_t)currentOutputWidth || sourceHeight != (int32_t)currentOutputHeight || offset || globalScaleRatio != 1.0f)
{
Expand All @@ -2164,8 +2170,8 @@ paint_window_commit( const gamescope::Rc<commit_t> &lastCommit, steamcompmgr_win

if ( w != scaleW )
{
drawXOffset += w->GetGeometry().nX * currentScaleRatio_x;
drawYOffset += w->GetGeometry().nY * currentScaleRatio_y;
drawXOffset += winOffsetX * currentScaleRatio_x;
drawYOffset += winOffsetY * currentScaleRatio_y;
}

calc_scale_factor(baseScaleRatio_x, baseScaleRatio_y, baseWidth, baseHeight);
Expand Down Expand Up @@ -3912,8 +3918,15 @@ void xwayland_ctx_t::DetermineAndApplyFocus( const std::vector< steamcompmgr_win
}

if ( !ctx->focus.overrideWindow || ctx->focus.overrideWindow != keyboardFocusWin )
{
XSetInputFocus(ctx->dpy, keyboardFocusWin->xwayland().id, RevertToNone, CurrentTime);

// wine >= 10.0 treats _NET_ACTIVE_WINDOW as foreground, so it must track real keyboard focus.
Window activeWindow = keyboardFocusWin->xwayland().id;
XChangeProperty(ctx->dpy, ctx->root, ctx->atoms.netActiveWindowAtom,
XA_WINDOW, 32, PropModeReplace, (unsigned char *)&activeWindow, 1);
}

if ( ctx->focus.inputFocusWindow != inputFocus ||
ctx->focus.inputFocusMode != inputFocus->inputFocusMode )
{
Expand Down Expand Up @@ -4311,7 +4324,14 @@ determine_and_apply_focus( global_focus_t *pFocus )

wlserver_clear_dropdowns();
if ( win_surface( pFocus->overrideWindow ) != nullptr )
wlserver_notify_dropdown( pFocus->overrideWindow->main_surface(), pFocus->overrideWindow->xwayland().a.x, pFocus->overrideWindow->xwayland().a.y );
{
// Relative to the focus window's origin, matching the cursor's coordinate space.
int32_t nBaseX = pFocus->focusWindow ? pFocus->focusWindow->GetGeometry().nX : 0;
int32_t nBaseY = pFocus->focusWindow ? pFocus->focusWindow->GetGeometry().nY : 0;
wlserver_notify_dropdown( pFocus->overrideWindow->main_surface(),
pFocus->overrideWindow->xwayland().a.x - nBaseX,
pFocus->overrideWindow->xwayland().a.y - nBaseY );
}

if ( gamescope::VirtualConnectorInSteamPerAppState() && pFocus->inputFocusWindow )
{
Expand Down
7 changes: 1 addition & 6 deletions src/steamcompmgr_shared.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,7 @@ struct steamcompmgr_win_t {
if (type != steamcompmgr_win_type_t::XWAYLAND)
return;

xwayland_ctx_t *ctx = xwayland().ctx;
Window id = xwayland().id;

XRaiseWindow(ctx->dpy, id);
XChangeProperty(ctx->dpy, ctx->root, ctx->atoms.netActiveWindowAtom,
XA_WINDOW, 32, PropModeReplace, (unsigned char *) &id, 1);
XRaiseWindow(xwayland().ctx->dpy, xwayland().id);
}

Rect GetGeometry() const
Expand Down