tabbox: move global to Workspace
This commit is contained in:
parent
43b78e40d8
commit
497a78b7cf
11 changed files with 66 additions and 70 deletions
|
@ -93,9 +93,9 @@ void TabBoxTest::testCapsLock()
|
|||
QVERIFY(c3->isActive());
|
||||
|
||||
// Setup tabbox signal spies
|
||||
QSignalSpy tabboxAddedSpy(TabBox::TabBox::self(), &TabBox::TabBox::tabBoxAdded);
|
||||
QSignalSpy tabboxAddedSpy(workspace()->tabbox(), &TabBox::TabBox::tabBoxAdded);
|
||||
QVERIFY(tabboxAddedSpy.isValid());
|
||||
QSignalSpy tabboxClosedSpy(TabBox::TabBox::self(), &TabBox::TabBox::tabBoxClosed);
|
||||
QSignalSpy tabboxClosedSpy(workspace()->tabbox(), &TabBox::TabBox::tabBoxClosed);
|
||||
QVERIFY(tabboxClosedSpy.isValid());
|
||||
|
||||
// enable capslock
|
||||
|
@ -111,19 +111,19 @@ void TabBoxTest::testCapsLock()
|
|||
Test::keyboardKeyReleased(KEY_TAB, timestamp++);
|
||||
|
||||
QVERIFY(tabboxAddedSpy.wait());
|
||||
QVERIFY(TabBox::TabBox::self()->isGrabbed());
|
||||
QVERIFY(workspace()->tabbox()->isGrabbed());
|
||||
|
||||
// release alt
|
||||
Test::keyboardKeyReleased(KEY_LEFTALT, timestamp++);
|
||||
QCOMPARE(tabboxClosedSpy.count(), 1);
|
||||
QCOMPARE(TabBox::TabBox::self()->isGrabbed(), false);
|
||||
QCOMPARE(workspace()->tabbox()->isGrabbed(), false);
|
||||
|
||||
// release caps lock
|
||||
Test::keyboardKeyPressed(KEY_CAPSLOCK, timestamp++);
|
||||
Test::keyboardKeyReleased(KEY_CAPSLOCK, timestamp++);
|
||||
QCOMPARE(input()->keyboardModifiers(), Qt::NoModifier);
|
||||
QCOMPARE(tabboxClosedSpy.count(), 1);
|
||||
QCOMPARE(TabBox::TabBox::self()->isGrabbed(), false);
|
||||
QCOMPARE(workspace()->tabbox()->isGrabbed(), false);
|
||||
QCOMPARE(workspace()->activeWindow(), c2);
|
||||
|
||||
surface3.reset();
|
||||
|
@ -156,9 +156,9 @@ void TabBoxTest::testMoveForward()
|
|||
QVERIFY(c3->isActive());
|
||||
|
||||
// Setup tabbox signal spies
|
||||
QSignalSpy tabboxAddedSpy(TabBox::TabBox::self(), &TabBox::TabBox::tabBoxAdded);
|
||||
QSignalSpy tabboxAddedSpy(workspace()->tabbox(), &TabBox::TabBox::tabBoxAdded);
|
||||
QVERIFY(tabboxAddedSpy.isValid());
|
||||
QSignalSpy tabboxClosedSpy(TabBox::TabBox::self(), &TabBox::TabBox::tabBoxClosed);
|
||||
QSignalSpy tabboxClosedSpy(workspace()->tabbox(), &TabBox::TabBox::tabBoxClosed);
|
||||
QVERIFY(tabboxClosedSpy.isValid());
|
||||
|
||||
// press alt+tab
|
||||
|
@ -169,12 +169,12 @@ void TabBoxTest::testMoveForward()
|
|||
Test::keyboardKeyReleased(KEY_TAB, timestamp++);
|
||||
|
||||
QVERIFY(tabboxAddedSpy.wait());
|
||||
QVERIFY(TabBox::TabBox::self()->isGrabbed());
|
||||
QVERIFY(workspace()->tabbox()->isGrabbed());
|
||||
|
||||
// release alt
|
||||
Test::keyboardKeyReleased(KEY_LEFTALT, timestamp++);
|
||||
QCOMPARE(tabboxClosedSpy.count(), 1);
|
||||
QCOMPARE(TabBox::TabBox::self()->isGrabbed(), false);
|
||||
QCOMPARE(workspace()->tabbox()->isGrabbed(), false);
|
||||
QCOMPARE(workspace()->activeWindow(), c2);
|
||||
|
||||
surface3.reset();
|
||||
|
@ -207,9 +207,9 @@ void TabBoxTest::testMoveBackward()
|
|||
QVERIFY(c3->isActive());
|
||||
|
||||
// Setup tabbox signal spies
|
||||
QSignalSpy tabboxAddedSpy(TabBox::TabBox::self(), &TabBox::TabBox::tabBoxAdded);
|
||||
QSignalSpy tabboxAddedSpy(workspace()->tabbox(), &TabBox::TabBox::tabBoxAdded);
|
||||
QVERIFY(tabboxAddedSpy.isValid());
|
||||
QSignalSpy tabboxClosedSpy(TabBox::TabBox::self(), &TabBox::TabBox::tabBoxClosed);
|
||||
QSignalSpy tabboxClosedSpy(workspace()->tabbox(), &TabBox::TabBox::tabBoxClosed);
|
||||
QVERIFY(tabboxClosedSpy.isValid());
|
||||
|
||||
// press alt+shift+tab
|
||||
|
@ -222,14 +222,14 @@ void TabBoxTest::testMoveBackward()
|
|||
Test::keyboardKeyReleased(KEY_TAB, timestamp++);
|
||||
|
||||
QVERIFY(tabboxAddedSpy.wait());
|
||||
QVERIFY(TabBox::TabBox::self()->isGrabbed());
|
||||
QVERIFY(workspace()->tabbox()->isGrabbed());
|
||||
|
||||
// release alt
|
||||
Test::keyboardKeyReleased(KEY_LEFTSHIFT, timestamp++);
|
||||
QCOMPARE(tabboxClosedSpy.count(), 0);
|
||||
Test::keyboardKeyReleased(KEY_LEFTALT, timestamp++);
|
||||
QCOMPARE(tabboxClosedSpy.count(), 1);
|
||||
QCOMPARE(TabBox::TabBox::self()->isGrabbed(), false);
|
||||
QCOMPARE(workspace()->tabbox()->isGrabbed(), false);
|
||||
QCOMPARE(workspace()->activeWindow(), c1);
|
||||
|
||||
surface3.reset();
|
||||
|
|
|
@ -206,7 +206,7 @@ EffectsHandlerImpl::EffectsHandlerImpl(Compositor *compositor, Scene *scene)
|
|||
#endif
|
||||
connect(ws, &Workspace::stackingOrderChanged, this, &EffectsHandler::stackingOrderChanged);
|
||||
#if KWIN_BUILD_TABBOX
|
||||
TabBox::TabBox *tabBox = TabBox::TabBox::self();
|
||||
TabBox::TabBox *tabBox = workspace()->tabbox();
|
||||
connect(tabBox, &TabBox::TabBox::tabBoxAdded, this, &EffectsHandler::tabBoxAdded);
|
||||
connect(tabBox, &TabBox::TabBox::tabBoxUpdated, this, &EffectsHandler::tabBoxUpdated);
|
||||
connect(tabBox, &TabBox::TabBox::tabBoxClosed, this, &EffectsHandler::tabBoxClosed);
|
||||
|
@ -1157,7 +1157,7 @@ void EffectsHandlerImpl::setTabBoxWindow(EffectWindow *w)
|
|||
#if KWIN_BUILD_TABBOX
|
||||
auto window = static_cast<EffectWindowImpl *>(w)->window();
|
||||
if (window->isClient()) {
|
||||
TabBox::TabBox::self()->setCurrentClient(window);
|
||||
workspace()->tabbox()->setCurrentClient(window);
|
||||
}
|
||||
#else
|
||||
Q_UNUSED(w)
|
||||
|
@ -1167,7 +1167,7 @@ void EffectsHandlerImpl::setTabBoxWindow(EffectWindow *w)
|
|||
void EffectsHandlerImpl::setTabBoxDesktop(int desktop)
|
||||
{
|
||||
#if KWIN_BUILD_TABBOX
|
||||
TabBox::TabBox::self()->setCurrentDesktop(desktop);
|
||||
workspace()->tabbox()->setCurrentDesktop(desktop);
|
||||
#else
|
||||
Q_UNUSED(desktop)
|
||||
#endif
|
||||
|
@ -1176,7 +1176,7 @@ void EffectsHandlerImpl::setTabBoxDesktop(int desktop)
|
|||
EffectWindowList EffectsHandlerImpl::currentTabBoxWindowList() const
|
||||
{
|
||||
#if KWIN_BUILD_TABBOX
|
||||
const auto clients = TabBox::TabBox::self()->currentClientList();
|
||||
const auto clients = workspace()->tabbox()->currentClientList();
|
||||
EffectWindowList ret;
|
||||
ret.reserve(clients.size());
|
||||
std::transform(std::cbegin(clients), std::cend(clients),
|
||||
|
@ -1193,28 +1193,28 @@ EffectWindowList EffectsHandlerImpl::currentTabBoxWindowList() const
|
|||
void EffectsHandlerImpl::refTabBox()
|
||||
{
|
||||
#if KWIN_BUILD_TABBOX
|
||||
TabBox::TabBox::self()->reference();
|
||||
workspace()->tabbox()->reference();
|
||||
#endif
|
||||
}
|
||||
|
||||
void EffectsHandlerImpl::unrefTabBox()
|
||||
{
|
||||
#if KWIN_BUILD_TABBOX
|
||||
TabBox::TabBox::self()->unreference();
|
||||
workspace()->tabbox()->unreference();
|
||||
#endif
|
||||
}
|
||||
|
||||
void EffectsHandlerImpl::closeTabBox()
|
||||
{
|
||||
#if KWIN_BUILD_TABBOX
|
||||
TabBox::TabBox::self()->close();
|
||||
workspace()->tabbox()->close();
|
||||
#endif
|
||||
}
|
||||
|
||||
QList<int> EffectsHandlerImpl::currentTabBoxDesktopList() const
|
||||
{
|
||||
#if KWIN_BUILD_TABBOX
|
||||
return TabBox::TabBox::self()->currentDesktopList();
|
||||
return workspace()->tabbox()->currentDesktopList();
|
||||
#else
|
||||
return QList<int>();
|
||||
#endif
|
||||
|
@ -1223,7 +1223,7 @@ QList<int> EffectsHandlerImpl::currentTabBoxDesktopList() const
|
|||
int EffectsHandlerImpl::currentTabBoxDesktop() const
|
||||
{
|
||||
#if KWIN_BUILD_TABBOX
|
||||
return TabBox::TabBox::self()->currentDesktop();
|
||||
return workspace()->tabbox()->currentDesktop();
|
||||
#else
|
||||
return -1;
|
||||
#endif
|
||||
|
@ -1232,7 +1232,7 @@ int EffectsHandlerImpl::currentTabBoxDesktop() const
|
|||
EffectWindow *EffectsHandlerImpl::currentTabBoxWindow() const
|
||||
{
|
||||
#if KWIN_BUILD_TABBOX
|
||||
if (auto c = TabBox::TabBox::self()->currentClient()) {
|
||||
if (auto c = workspace()->tabbox()->currentClient()) {
|
||||
return c->effectWindow();
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -825,7 +825,7 @@ void X11Window::updateMouseGrab()
|
|||
xcb_ungrab_button(kwinApp()->x11Connection(), XCB_BUTTON_INDEX_ANY, m_wrapper, XCB_MOD_MASK_ANY);
|
||||
|
||||
#if KWIN_BUILD_TABBOX
|
||||
if (TabBox::TabBox::self()->forcedGlobalMouseGrab()) { // see TabBox::establishTabBoxGrab()
|
||||
if (workspace()->tabbox()->forcedGlobalMouseGrab()) { // see TabBox::establishTabBoxGrab()
|
||||
m_wrapper.grabButton(XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1646,14 +1646,14 @@ public:
|
|||
bool pointerEvent(QMouseEvent *event, quint32 button) override
|
||||
{
|
||||
Q_UNUSED(button)
|
||||
if (!TabBox::TabBox::self() || !TabBox::TabBox::self()->isGrabbed()) {
|
||||
if (!workspace()->tabbox() || !workspace()->tabbox()->isGrabbed()) {
|
||||
return false;
|
||||
}
|
||||
return TabBox::TabBox::self()->handleMouseEvent(event);
|
||||
return workspace()->tabbox()->handleMouseEvent(event);
|
||||
}
|
||||
bool keyEvent(QKeyEvent *event) override
|
||||
{
|
||||
if (!TabBox::TabBox::self() || !TabBox::TabBox::self()->isGrabbed()) {
|
||||
if (!workspace()->tabbox() || !workspace()->tabbox()->isGrabbed()) {
|
||||
return false;
|
||||
}
|
||||
auto seat = waylandServer()->seat();
|
||||
|
@ -1664,18 +1664,18 @@ public:
|
|||
passToWaylandServer(event);
|
||||
|
||||
if (event->type() == QEvent::KeyPress) {
|
||||
TabBox::TabBox::self()->keyPress(event->modifiers() | event->key());
|
||||
workspace()->tabbox()->keyPress(event->modifiers() | event->key());
|
||||
} else if (static_cast<KeyEvent *>(event)->modifiersRelevantForGlobalShortcuts() == Qt::NoModifier) {
|
||||
TabBox::TabBox::self()->modifiersReleased();
|
||||
workspace()->tabbox()->modifiersReleased();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool wheelEvent(QWheelEvent *event) override
|
||||
{
|
||||
if (!TabBox::TabBox::self() || !TabBox::TabBox::self()->isGrabbed()) {
|
||||
if (!workspace()->tabbox() || !workspace()->tabbox()->isGrabbed()) {
|
||||
return false;
|
||||
}
|
||||
return TabBox::TabBox::self()->handleWheelEvent(event);
|
||||
return workspace()->tabbox()->handleWheelEvent(event);
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
|
|
@ -440,18 +440,9 @@ QUuid TabBoxClientImpl::internalId() const
|
|||
/*********************************************************
|
||||
* TabBox
|
||||
*********************************************************/
|
||||
TabBox *TabBox::s_self = nullptr;
|
||||
|
||||
TabBox *TabBox::create(QObject *parent)
|
||||
{
|
||||
Q_ASSERT(!s_self);
|
||||
s_self = new TabBox(parent);
|
||||
return s_self;
|
||||
}
|
||||
|
||||
TabBox::TabBox(QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_displayRefcount(0)
|
||||
TabBox::TabBox()
|
||||
: m_displayRefcount(0)
|
||||
, m_desktopGrab(false)
|
||||
, m_tabGrab(false)
|
||||
, m_noModifierGrab(false)
|
||||
|
@ -506,10 +497,7 @@ TabBox::TabBox(QObject *parent)
|
|||
connect(Workspace::self(), &Workspace::configChanged, this, &TabBox::reconfigure);
|
||||
}
|
||||
|
||||
TabBox::~TabBox()
|
||||
{
|
||||
s_self = nullptr;
|
||||
}
|
||||
TabBox::~TabBox() = default;
|
||||
|
||||
void TabBox::handlerReady()
|
||||
{
|
||||
|
@ -526,7 +514,7 @@ void TabBox::key(const KLazyLocalizedString &actionName, Slot slot, const QKeySe
|
|||
a->setObjectName(QString::fromUtf8(actionName.untranslatedText()));
|
||||
a->setText(actionName.toString());
|
||||
KGlobalAccel::self()->setGlobalShortcut(a, QList<QKeySequence>() << shortcut);
|
||||
input()->registerShortcut(shortcut, a, TabBox::self(), slot);
|
||||
input()->registerShortcut(shortcut, a, this, slot);
|
||||
auto cuts = KGlobalAccel::self()->shortcut(a);
|
||||
globalShortcutChanged(a, cuts.isEmpty() ? QKeySequence() : cuts.first());
|
||||
}
|
||||
|
|
|
@ -106,7 +106,8 @@ class KWIN_EXPORT TabBox : public QObject
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
~TabBox() override;
|
||||
explicit TabBox();
|
||||
~TabBox();
|
||||
|
||||
/**
|
||||
* Returns the currently displayed client ( only works in TabBoxWindowsMode ).
|
||||
|
@ -261,9 +262,6 @@ public:
|
|||
}
|
||||
void setCurrentIndex(QModelIndex index, bool notifyEffects = true);
|
||||
|
||||
static TabBox *self();
|
||||
static TabBox *create(QObject *parent);
|
||||
|
||||
public Q_SLOTS:
|
||||
/**
|
||||
* Notify effects that the tab box is being shown, and only display the
|
||||
|
@ -357,16 +355,9 @@ private:
|
|||
QList<ElectricBorder> m_borderActivate, m_borderAlternativeActivate;
|
||||
QHash<ElectricBorder, QAction *> m_touchActivate;
|
||||
QHash<ElectricBorder, QAction *> m_touchAlternativeActivate;
|
||||
QScopedPointer<X11EventFilter> m_x11EventFilter;
|
||||
|
||||
static TabBox *s_self;
|
||||
std::unique_ptr<X11EventFilter> m_x11EventFilter;
|
||||
};
|
||||
|
||||
inline TabBox *TabBox::self()
|
||||
{
|
||||
return s_self;
|
||||
}
|
||||
|
||||
} // namespace TabBox
|
||||
} // namespace
|
||||
#endif
|
||||
|
|
|
@ -29,7 +29,8 @@ X11Filter::X11Filter()
|
|||
|
||||
bool X11Filter::event(xcb_generic_event_t *event)
|
||||
{
|
||||
if (!TabBox::TabBox::self()->isGrabbed()) {
|
||||
const auto tab = workspace()->tabbox();
|
||||
if (!tab->isGrabbed()) {
|
||||
return false;
|
||||
}
|
||||
const uint8_t eventType = event->response_type & ~0x80;
|
||||
|
@ -38,7 +39,6 @@ bool X11Filter::event(xcb_generic_event_t *event)
|
|||
case XCB_BUTTON_RELEASE: {
|
||||
auto e = reinterpret_cast<xcb_button_press_event_t *>(event);
|
||||
xcb_allow_events(connection(), XCB_ALLOW_ASYNC_POINTER, XCB_CURRENT_TIME);
|
||||
const auto tab = TabBox::TabBox::self();
|
||||
if (!tab->isShown() && tab->isDisplayed()) {
|
||||
if (effects && static_cast<EffectsHandlerImpl *>(effects)->isMouseInterception()) {
|
||||
// pass on to effects, effects will filter out the event
|
||||
|
@ -67,7 +67,7 @@ bool X11Filter::event(xcb_generic_event_t *event)
|
|||
bool X11Filter::buttonPress(xcb_button_press_event_t *event)
|
||||
{
|
||||
// press outside Tabbox?
|
||||
const auto tab = TabBox::TabBox::self();
|
||||
const auto tab = workspace()->tabbox();
|
||||
QPoint pos(event->root_x, event->root_y);
|
||||
if ((!tab->isShown() && tab->isDisplayed())
|
||||
|| (!tabBox->containsPos(pos) && (event->detail == XCB_BUTTON_INDEX_1 || event->detail == XCB_BUTTON_INDEX_2 || event->detail == XCB_BUTTON_INDEX_3))) {
|
||||
|
@ -99,7 +99,7 @@ void X11Filter::keyPress(xcb_generic_event_t *event)
|
|||
int keyQt;
|
||||
xcb_key_press_event_t *keyEvent = reinterpret_cast<xcb_key_press_event_t *>(event);
|
||||
KKeyServer::xcbKeyPressEventToQt(keyEvent, &keyQt);
|
||||
TabBox::TabBox::self()->keyPress(keyQt);
|
||||
workspace()->tabbox()->keyPress(keyQt);
|
||||
}
|
||||
|
||||
void X11Filter::keyRelease(xcb_generic_event_t *event)
|
||||
|
@ -141,7 +141,7 @@ void X11Filter::keyRelease(xcb_generic_event_t *event)
|
|||
}
|
||||
}
|
||||
if (release) {
|
||||
TabBox::TabBox::self()->modifiersReleased();
|
||||
workspace()->tabbox()->modifiersReleased();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1103,7 +1103,7 @@ void Workspace::initShortcuts()
|
|||
initShortcut("Invert Screen Colors", i18n("Invert Screen Colors"), 0, kwinApp()->platform(), &Platform::invertScreen);
|
||||
|
||||
#if KWIN_BUILD_TABBOX
|
||||
TabBox::TabBox::self()->initShortcuts();
|
||||
m_tabbox->initShortcuts();
|
||||
#endif
|
||||
vds->initShortcuts();
|
||||
m_userActionsMenu->discard(); // so that it's recreated next time
|
||||
|
|
|
@ -4432,7 +4432,7 @@ void Window::setFullscreenGeometryRestore(const QRectF &geom)
|
|||
void Window::cleanTabBox()
|
||||
{
|
||||
#if KWIN_BUILD_TABBOX
|
||||
TabBox::TabBox *tabBox = TabBox::TabBox::self();
|
||||
TabBox::TabBox *tabBox = workspace()->tabbox();
|
||||
if (tabBox && tabBox->isDisplayed() && tabBox->currentClient() == this) {
|
||||
tabBox->nextPrev(true);
|
||||
}
|
||||
|
|
|
@ -169,7 +169,7 @@ Workspace::Workspace()
|
|||
|
||||
#if KWIN_BUILD_TABBOX
|
||||
// need to create the tabbox before compositing scene is setup
|
||||
TabBox::TabBox::create(this);
|
||||
m_tabbox = std::make_unique<TabBox::TabBox>();
|
||||
#endif
|
||||
|
||||
if (!Compositor::self()) {
|
||||
|
@ -1874,9 +1874,8 @@ void Workspace::setWasUserInteraction()
|
|||
void Workspace::updateTabbox()
|
||||
{
|
||||
#if KWIN_BUILD_TABBOX
|
||||
TabBox::TabBox *tabBox = TabBox::TabBox::self();
|
||||
if (tabBox->isDisplayed()) {
|
||||
tabBox->reset(true);
|
||||
if (m_tabbox->isDisplayed()) {
|
||||
m_tabbox->reset(true);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -2866,6 +2865,13 @@ Screens *Workspace::screens() const
|
|||
return m_screens.get();
|
||||
}
|
||||
|
||||
#if KWIN_BUILD_TABBOX
|
||||
TabBox::TabBox *Workspace::tabbox() const
|
||||
{
|
||||
return m_tabbox.get();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if KWIN_BUILD_ACTIVITIES
|
||||
Activities *Workspace::activities() const
|
||||
{
|
||||
|
|
|
@ -45,6 +45,11 @@ class Tree;
|
|||
class Window;
|
||||
}
|
||||
|
||||
namespace TabBox
|
||||
{
|
||||
class TabBox;
|
||||
}
|
||||
|
||||
class Window;
|
||||
class Output;
|
||||
class ColorMapper;
|
||||
|
@ -445,6 +450,9 @@ public:
|
|||
RuleBook *rulebook() const;
|
||||
ScreenEdges *screenEdges() const;
|
||||
Screens *screens() const;
|
||||
#if KWIN_BUILD_TABBOX
|
||||
TabBox::TabBox *tabbox() const;
|
||||
#endif
|
||||
#if KWIN_BUILD_ACTIVITIES
|
||||
Activities *activities() const;
|
||||
#endif
|
||||
|
@ -724,6 +732,9 @@ private:
|
|||
std::unique_ptr<RuleBook> m_rulebook;
|
||||
std::unique_ptr<ScreenEdges> m_screenEdges;
|
||||
std::unique_ptr<Screens> m_screens;
|
||||
#if KWIN_BUILD_TABBOX
|
||||
std::unique_ptr<TabBox::TabBox> m_tabbox;
|
||||
#endif
|
||||
#if KWIN_BUILD_ACTIVITIES
|
||||
std::unique_ptr<Activities> m_activities;
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue