summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorvaxerski <43317083+vaxerski@users.noreply.github.com>2022-10-22 16:43:47 +0100
committervaxerski <43317083+vaxerski@users.noreply.github.com>2022-10-22 16:43:47 +0100
commit2c714eace5bc903e5e9ef9e2c3048cb65a2ca9b4 (patch)
tree86bfdb5bee027986ec410d1d2caf85217ca57a3f /src
parent0d7d7a970dc047517ed4d3922c1da3638cb51aed (diff)
handle activate requests
Diffstat (limited to 'src')
-rw-r--r--src/Compositor.cpp3
-rw-r--r--src/Compositor.hpp1
-rw-r--r--src/config/ConfigManager.cpp1
-rw-r--r--src/events/Events.hpp2
-rw-r--r--src/events/Windows.cpp35
5 files changed, 35 insertions, 7 deletions
diff --git a/src/Compositor.cpp b/src/Compositor.cpp
index 9e9dc258..37e579cb 100644
--- a/src/Compositor.cpp
+++ b/src/Compositor.cpp
@@ -170,6 +170,8 @@ CCompositor::CCompositor() {
m_sWLRTextInputMgr = wlr_text_input_manager_v3_create(m_sWLDisplay);
m_sWLRIMEMgr = wlr_input_method_manager_v2_create(m_sWLDisplay);
+
+ m_sWLRActivation = wlr_xdg_activation_v1_create(m_sWLDisplay);
}
CCompositor::~CCompositor() {
@@ -226,6 +228,7 @@ void CCompositor::initAllSignals() {
addWLSignal(&m_sWLROutputPowerMgr->events.set_mode, &Events::listen_powerMgrSetMode, m_sWLROutputPowerMgr, "PowerMgr");
addWLSignal(&m_sWLRIMEMgr->events.input_method, &Events::listen_newIME, m_sWLRIMEMgr, "IMEMgr");
addWLSignal(&m_sWLRTextInputMgr->events.text_input, &Events::listen_newTextInput, m_sWLRTextInputMgr, "TextInputMgr");
+ addWLSignal(&m_sWLRActivation->events.request_activate, &Events::listen_activateXDG, m_sWLRActivation, "ActivationV1");
if(m_sWRLDRMLeaseMgr)
addWLSignal(&m_sWRLDRMLeaseMgr->events.request, &Events::listen_leaseRequest, &m_sWRLDRMLeaseMgr, "DRM");
diff --git a/src/Compositor.hpp b/src/Compositor.hpp
index aa4cd878..284eb464 100644
--- a/src/Compositor.hpp
+++ b/src/Compositor.hpp
@@ -69,6 +69,7 @@ public:
wlr_output_power_manager_v1* m_sWLROutputPowerMgr;
wlr_input_method_manager_v2* m_sWLRIMEMgr;
wlr_text_input_manager_v3* m_sWLRTextInputMgr;
+ wlr_xdg_activation_v1* m_sWLRActivation;
// ------------------------------------------------- //
diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp
index fd19931e..bb856995 100644
--- a/src/config/ConfigManager.cpp
+++ b/src/config/ConfigManager.cpp
@@ -60,6 +60,7 @@ void CConfigManager::setDefaultVars() {
configValues["misc:disable_autoreload"].intValue = 0;
configValues["misc:enable_swallow"].intValue = 0;
configValues["misc:swallow_regex"].strValue = STRVAL_EMPTY;
+ configValues["misc:focus_on_activate"].intValue = 1;
configValues["debug:int"].intValue = 0;
configValues["debug:log_damage"].intValue = 0;
diff --git a/src/events/Events.hpp b/src/events/Events.hpp
index 77de4ed5..4b6d8f76 100644
--- a/src/events/Events.hpp
+++ b/src/events/Events.hpp
@@ -42,6 +42,7 @@ namespace Events {
// Surface XDG (window)
LISTENER(newXDGSurface);
+ LISTENER(activateXDG);
// Window events
DYNLISTENFUNC(commitWindow);
@@ -87,7 +88,6 @@ namespace Events {
LISTENER(requestMouse);
LISTENER(requestSetSel);
LISTENER(requestSetPrimarySel);
- DYNLISTENFUNC(activate);
// outputMgr
LISTENER(outputMgrApply);
diff --git a/src/events/Windows.cpp b/src/events/Windows.cpp
index 8519716f..c0b5ff80 100644
--- a/src/events/Windows.cpp
+++ b/src/events/Windows.cpp
@@ -688,16 +688,39 @@ void Events::listener_fullscreenWindow(void* owner, void* data) {
g_pXWaylandManager->setWindowFullscreen(PWINDOW, PWINDOW->m_bIsFullscreen);
}
-void Events::listener_activate(void* owner, void* data) {
- // TODO
+void Events::listener_activateXDG(wl_listener* listener, void* data) {
+ const auto E = (wlr_xdg_activation_v1_request_activate_event*)data;
+
+ static auto *const PFOCUSONACTIVATE = &g_pConfigManager->getConfigValuePtr("misc:focus_on_activate")->intValue;
+
+ Debug::log(LOG, "Activate request for surface at %x", E->surface);
+
+ if (!*PFOCUSONACTIVATE || !wlr_surface_is_xdg_surface(E->surface))
+ return;
+
+ const auto PWINDOW = g_pCompositor->getWindowFromSurface(E->surface);
+
+ if (!PWINDOW)
+ return;
+
+ g_pCompositor->focusWindow(PWINDOW);
+ Vector2D middle = PWINDOW->m_vRealPosition.goalv() + PWINDOW->m_vRealSize.goalv() / 2.f;
+ g_pCompositor->warpCursorTo(middle);
}
void Events::listener_activateX11(void* owner, void* data) {
- CWindow* PWINDOW = (CWindow*)owner;
+ const auto PWINDOW = (CWindow*)owner;
- if (PWINDOW->m_iX11Type == 1 /* Managed */) {
- wlr_xwayland_surface_activate(PWINDOW->m_uSurface.xwayland, 1);
- }
+ static auto *const PFOCUSONACTIVATE = &g_pConfigManager->getConfigValuePtr("misc:focus_on_activate")->intValue;
+
+ Debug::log(LOG, "X11 Activate request for window %x", PWINDOW);
+
+ if (!*PFOCUSONACTIVATE || PWINDOW->m_iX11Type != 1)
+ return;
+
+ g_pCompositor->focusWindow(PWINDOW);
+ Vector2D middle = PWINDOW->m_vRealPosition.goalv() + PWINDOW->m_vRealSize.goalv() / 2.f;
+ g_pCompositor->warpCursorTo(middle);
}
void Events::listener_configureX11(void* owner, void* data) {