Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

input: try to refocus a focusable window when seat grabs are reset #7669

Merged
merged 1 commit into from
Sep 7, 2024
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
7 changes: 7 additions & 0 deletions src/desktop/Popup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,13 @@ void CPopup::reposition() {
m_pResource->applyPositioning(box, COORDS);
}

SP<CWLSurface> CPopup::getT1Owner() {
if (m_pWindowOwner)
return m_pWindowOwner->m_pWLSurface;
else
return m_pLayerOwner->surface;
}

Vector2D CPopup::coordsRelativeToParent() {
Vector2D offset;

Expand Down
23 changes: 12 additions & 11 deletions src/desktop/Popup.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,22 @@ class CPopup {

~CPopup();

Vector2D coordsRelativeToParent();
Vector2D coordsGlobal();
SP<CWLSurface> getT1Owner();
Vector2D coordsRelativeToParent();
Vector2D coordsGlobal();

Vector2D size();
Vector2D size();

void onNewPopup(SP<CXDGPopupResource> popup);
void onDestroy();
void onMap();
void onUnmap();
void onCommit(bool ignoreSiblings = false);
void onReposition();
void onNewPopup(SP<CXDGPopupResource> popup);
void onDestroy();
void onMap();
void onUnmap();
void onCommit(bool ignoreSiblings = false);
void onReposition();

void recheckTree();
void recheckTree();

bool visible();
bool visible();

// will also loop over this node
void breadthfirst(std::function<void(CPopup*, void*)> fn, void* data);
Expand Down
31 changes: 31 additions & 0 deletions src/managers/SeatManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "../protocols/core/Compositor.hpp"
#include "../Compositor.hpp"
#include "../devices/IKeyboard.hpp"
#include "wlr-layer-shell-unstable-v1.hpp"
#include <algorithm>
#include <ranges>

Expand Down Expand Up @@ -584,6 +585,36 @@ void CSeatManager::setGrab(SP<CSeatGrab> grab) {
auto oldGrab = seatGrab;
seatGrab.reset();
g_pInputManager->refocus();

auto currentFocus = state.keyboardFocus.lock();
auto refocus = !currentFocus;

SP<CWLSurface> surf;
PHLLS layer;

if (!refocus) {
surf = CWLSurface::fromResource(currentFocus);
layer = surf->getLayer();
}

if (!refocus && !layer) {
auto popup = surf->getPopup();
if (popup) {
auto parent = popup->getT1Owner();
layer = parent->getLayer();
}
}

if (!refocus && layer)
refocus = layer->interactivity == ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_NONE;

if (refocus) {
auto candidate = g_pCompositor->m_pLastWindow.lock();

if (candidate)
g_pCompositor->focusWindow(candidate);
}

if (oldGrab->onEnd)
oldGrab->onEnd();
}
Expand Down
Loading