File tree Expand file tree Collapse file tree 4 files changed +13
-24
lines changed
src/wayland/shortcuts_inhibit Expand file tree Collapse file tree 4 files changed +13
-24
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,10 @@ ShortcutsInhibitor::ShortcutsInhibitor() {
1515 this ->bBoundWindow .setBinding ([this ] {
1616 return this ->bEnabled ? this ->bWindowObject .value () : nullptr ;
1717 });
18+
19+ this ->bActive .setBinding ([this ]() {
20+ return this ->inhibitor ? this ->inhibitor ->bindableActive ().value () : false ;
21+ });
1822}
1923
2024ShortcutsInhibitor::~ShortcutsInhibitor () {
@@ -87,7 +91,10 @@ void ShortcutsInhibitor::onWindowVisibilityChanged() {
8791 if (!window->handle ()) window->create ();
8892
8993 auto * waylandWindow = dynamic_cast <QWaylandWindow*>(window->handle ());
90- if (!waylandWindow) return ;
94+ if (!waylandWindow) {
95+ qCCritical (impl::logShortcutsInhibit ()) << " Window handle is not a QWaylandWindow" ;
96+ return ;
97+ }
9198 if (waylandWindow == this ->mWaylandWindow ) return ;
9299 this ->mWaylandWindow = waylandWindow;
93100
@@ -132,12 +139,6 @@ void ShortcutsInhibitor::onWaylandSurfaceCreated() {
132139 }
133140
134141 this ->inhibitor = manager->createShortcutsInhibitor (this ->mWaylandWindow );
135-
136- if (this ->inhibitor ) {
137- this ->bActive .setBinding ([this ]() {
138- return this ->inhibitor ? this ->inhibitor ->bindableActive ().value () : false ;
139- });
140- }
141142}
142143
143144void ShortcutsInhibitor::onWaylandSurfaceDestroyed () {
Original file line number Diff line number Diff line change @@ -50,7 +50,7 @@ class ShortcutsInhibitor: public QObject {
5050 void setWindow (QObject* window);
5151
5252 [[nodiscard]] QBindable<bool > bindableEnabled () { return &this ->bEnabled ; }
53- [[nodiscard]] QBindable<bool > bindableActive () { return &this ->bActive ; }
53+ [[nodiscard]] QBindable<bool > bindableActive () const { return &this ->bActive ; }
5454
5555signals:
5656 void enabledChanged ();
Original file line number Diff line number Diff line change 1313
1414namespace qs ::wayland::shortcuts_inhibit::impl {
1515
16- namespace {
1716QS_LOGGING_CATEGORY (logShortcutsInhibit, " quickshell.wayland.shortcuts_inhibit" , QtWarningMsg);
18- }
1917
2018ShortcutsInhibitManager::ShortcutsInhibitManager (): QWaylandClientExtensionTemplate(1 ) {
2119 this ->initialize ();
@@ -54,18 +52,6 @@ ShortcutsInhibitManager::createShortcutsInhibitor(QtWaylandClient::QWaylandWindo
5452 return inhibitor;
5553}
5654
57- void ShortcutsInhibitManager::refShortcutsInhibitor (ShortcutsInhibitor* inhibitor) {
58- if (!inhibitor) return ;
59-
60- auto * surface = inhibitor->surface ();
61- if (!this ->inhibitors .contains (surface)) return ;
62-
63- auto & pair = this ->inhibitors [surface];
64- pair.second ++;
65- qCDebug (logShortcutsInhibit) << " Incremented refcount for inhibitor" << inhibitor
66- << " - refcount:" << pair.second ;
67- }
68-
6955void ShortcutsInhibitManager::unrefShortcutsInhibitor (ShortcutsInhibitor* inhibitor) {
7056 if (!inhibitor) return ;
7157
Original file line number Diff line number Diff line change 77#include < qwayland-keyboard-shortcuts-inhibit-unstable-v1.h>
88#include < qwaylandclientextension.h>
99
10+ #include " ../../core/logcat.hpp"
1011#include " wayland-keyboard-shortcuts-inhibit-unstable-v1-client-protocol.h"
1112
1213namespace qs ::wayland::shortcuts_inhibit::impl {
1314
15+ QS_DECLARE_LOGGING_CATEGORY (logShortcutsInhibit);
16+
1417class ShortcutsInhibitor ;
1518
1619class ShortcutsInhibitManager
@@ -20,7 +23,6 @@ class ShortcutsInhibitManager
2023 explicit ShortcutsInhibitManager ();
2124
2225 ShortcutsInhibitor* createShortcutsInhibitor (QtWaylandClient::QWaylandWindow* surface);
23- void refShortcutsInhibitor (ShortcutsInhibitor* inhibitor);
2426 void unrefShortcutsInhibitor (ShortcutsInhibitor* inhibitor);
2527
2628 static ShortcutsInhibitManager* instance ();
@@ -42,7 +44,7 @@ class ShortcutsInhibitor
4244 ~ShortcutsInhibitor () override ;
4345 Q_DISABLE_COPY_MOVE (ShortcutsInhibitor);
4446
45- [[nodiscard]] QBindable<bool > bindableActive () { return &this ->bActive ; }
47+ [[nodiscard]] QBindable<bool > bindableActive () const { return &this ->bActive ; }
4648 [[nodiscard]] bool isActive () const { return this ->bActive ; }
4749 [[nodiscard]] wl_surface* surface () const { return this ->mSurface ; }
4850
You can’t perform that action at this time.
0 commit comments