From 83108e16d857ccaf8230693be15d7566f3cabf1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Mon, 17 Feb 2014 05:05:06 +0100 Subject: UnityScreen: add a SpreadFilter when in Scale mode, when updated it relayouts the scale plugin Thanks to this we can finally filter the windows by name in the unity spread! (bzr r3656.5.4) --- plugins/unityshell/src/unityshell.cpp | 89 +++++++++++++++++++++++------------ plugins/unityshell/src/unityshell.h | 3 ++ 2 files changed, 62 insertions(+), 30 deletions(-) (limited to 'plugins') diff --git a/plugins/unityshell/src/unityshell.cpp b/plugins/unityshell/src/unityshell.cpp index cdaa6dcd9..5b49e76b7 100644 --- a/plugins/unityshell/src/unityshell.cpp +++ b/plugins/unityshell/src/unityshell.cpp @@ -137,10 +137,8 @@ const unsigned int SCROLL_DOWN_BUTTON = 6; const unsigned int SCROLL_UP_BUTTON = 7; const int MAX_BUFFER_AGE = 11; const int FRAMES_TO_REDRAW_ON_RESUME = 10; - const std::string RELAYOUT_TIMEOUT = "relayout-timeout"; } // namespace local - } // anon namespace UnityScreen::UnityScreen(CompScreen* screen) @@ -149,6 +147,7 @@ UnityScreen::UnityScreen(CompScreen* screen) , screen(screen) , cScreen(CompositeScreen::get(screen)) , gScreen(GLScreen::get(screen)) + , sScreen(ScaleScreen::get(screen)) , menus_(std::make_shared(std::make_shared(), std::make_shared())) , deco_manager_(std::make_shared()) , debugger_(this) @@ -511,13 +510,28 @@ void UnityScreen::initAltTabNextWindow() void UnityScreen::OnInitiateSpread() { - for (auto const& swin : ScaleScreen::get(screen)->getWindows()) + spread_filter_ = std::make_shared(); + spread_filter_->text.changed.connect([this] (std::string const& filter) { + if (filter.empty()) + { + sScreen->relayoutSlots(CompMatch::emptyMatch); + } + else + { + auto match = sScreen->getCustomMatch(); + sScreen->relayoutSlots(match & ("ititle="+filter)); + } + }); + + for (auto const& swin : sScreen->getWindows()) UnityWindow::get(swin->window)->OnInitiateSpread(); } void UnityScreen::OnTerminateSpread() { - for (auto const& swin : ScaleScreen::get(screen)->getWindows()) + spread_filter_.reset(); + + for (auto const& swin : sScreen->getWindows()) UnityWindow::get(swin->window)->OnTerminateSpread(); } @@ -1680,8 +1694,7 @@ void UnityScreen::handleEvent(XEvent* event) case MotionNotify: if (wm.IsScaleActive()) { - ScaleScreen* ss = ScaleScreen::get(screen); - if (CompWindow *w = screen->findWindow(ss->getSelectedWindow())) + if (CompWindow *w = screen->findWindow(sScreen->getSelectedWindow())) skip_other_plugins = UnityWindow::get(w)->handleEvent(event); } else if (switcher_controller_->IsDetailViewShown()) @@ -1706,9 +1719,14 @@ void UnityScreen::handleEvent(XEvent* event) } if (wm.IsScaleActive()) { - ScaleScreen* ss = ScaleScreen::get(screen); - if (CompWindow *w = screen->findWindow(ss->getSelectedWindow())) - skip_other_plugins = UnityWindow::get(w)->handleEvent(event); + if (spread_filter_ && spread_filter_->Visible()) + skip_other_plugins = spread_filter_->GetAbsoluteGeometry().IsPointInside(event->xbutton.x_root, event->xbutton.y_root); + + if (!skip_other_plugins) + { + if (CompWindow *w = screen->findWindow(sScreen->getSelectedWindow())) + skip_other_plugins = UnityWindow::get(w)->handleEvent(event); + } } else if (switcher_controller_->IsDetailViewShown()) { @@ -1782,9 +1800,14 @@ void UnityScreen::handleEvent(XEvent* event) } else if (wm.IsScaleActive()) { - ScaleScreen* ss = ScaleScreen::get(screen); - if (CompWindow *w = screen->findWindow(ss->getSelectedWindow())) - skip_other_plugins = UnityWindow::get(w)->handleEvent(event); + if (spread_filter_ && spread_filter_->Visible()) + skip_other_plugins = spread_filter_->GetAbsoluteGeometry().IsPointInside(event->xbutton.x_root, event->xbutton.y_root); + + if (!skip_other_plugins) + { + if (CompWindow *w = screen->findWindow(sScreen->getSelectedWindow())) + skip_other_plugins = skip_other_plugins || UnityWindow::get(w)->handleEvent(event); + } } break; case KeyPress: @@ -1853,6 +1876,16 @@ void UnityScreen::handleEvent(XEvent* event) EnableCancelAction(CancelActionTarget::LAUNCHER_SWITCHER, false); } } + + if (spread_filter_ && spread_filter_->Visible()) + { + if (key_sym == XK_Escape) + { + skip_other_plugins = true; + spread_filter_->text = ""; + } + } + break; } case MapRequest: @@ -1866,22 +1899,21 @@ void UnityScreen::handleEvent(XEvent* event) } break; default: - if (screen->shapeEvent () + ShapeNotify == event->type) + if (screen->shapeEvent() + ShapeNotify == event->type) { Window xid = event->xany.window; CompWindow *w = screen->findWindow(xid); if (w) { - UnityWindow *uw = UnityWindow::get (w); - + UnityWindow *uw = UnityWindow::get(w); uw->handleEvent(event); } } break; } - compiz::CompizMinimizedWindowHandler::handleEvent (event); + compiz::CompizMinimizedWindowHandler::handleEvent(event); // avoid further propagation (key conflict for instance) if (!skip_other_plugins) @@ -1890,19 +1922,18 @@ void UnityScreen::handleEvent(XEvent* event) if (deco_manager_->HandleEventAfter(event)) return; - switch (event->type) - { - case MapRequest: - ShowdesktopHandler::AllowLeaveShowdesktopMode(event->xmaprequest.window); - break; - } + if (event->type == MapRequest) + ShowdesktopHandler::AllowLeaveShowdesktopMode(event->xmaprequest.window); - if ((event->type == MotionNotify || event->type == ButtonPress || event->type == ButtonRelease) && - switcher_controller_->IsMouseDisabled() && switcher_controller_->Visible()) + if (switcher_controller_->IsMouseDisabled() && switcher_controller_->Visible() && + (event->type == MotionNotify || event->type == ButtonPress || event->type == ButtonRelease)) { skip_other_plugins = true; } + if (spread_filter_ && spread_filter_->Visible()) + skip_other_plugins = false; + if (!skip_other_plugins && screen->otherGrabExist("deco", "move", "switcher", "resize", nullptr)) { @@ -2785,8 +2816,7 @@ bool UnityWindow::glPaint(const GLWindowPaintAttrib& attrib, } } - if (WindowManager::Default().IsScaleActive() && - ScaleScreen::get(screen)->getSelectedWindow() == window->id()) + if (uScreen->sScreen->getSelectedWindow() == window->id()) { nux::Geometry const& scaled_geo = GetScaledGeometry(); paintInnerGlow(scaled_geo, matrix, attrib, mask); @@ -3737,7 +3767,7 @@ UnityWindow::UnityWindow(CompWindow* window) void UnityWindow::AddProperties(debug::IntrospectionData& introspection) { Window xid = window->id(); - auto const& swins = ScaleScreen::get(screen)->getWindows(); + auto const& swins = uScreen->sScreen->getWindows(); bool scaled = std::find(swins.begin(), swins.end(), ScaleWindow::get(window)) != swins.end(); WindowManager& wm = WindowManager::Default(); @@ -3942,8 +3972,7 @@ void UnityWindow::scalePaintDecoration(GLWindowPaintAttrib const& attrib, if (!scale_win->hasSlot()) // animation not finished return; - ScaleScreen* ss = ScaleScreen::get(screen); - auto state = ss->getState(); + auto state = uScreen->sScreen->getState(); if (state != ScaleScreen::Wait && state != ScaleScreen::Out) return; @@ -3953,7 +3982,7 @@ void UnityWindow::scalePaintDecoration(GLWindowPaintAttrib const& attrib, auto deco_attrib = attrib; deco_attrib.opacity = COMPIZ_COMPOSITE_OPAQUE; - bool highlighted = (ss->getSelectedWindow() == window->id()); + bool highlighted = (uScreen->sScreen->getSelectedWindow() == window->id()); paintFakeDecoration(scale_geo, deco_attrib, transform, mask, highlighted, pos.scale); } diff --git a/plugins/unityshell/src/unityshell.h b/plugins/unityshell/src/unityshell.h index bbb94ece4..651b5d63e 100644 --- a/plugins/unityshell/src/unityshell.h +++ b/plugins/unityshell/src/unityshell.h @@ -65,6 +65,7 @@ #include "ScreenIntrospection.h" #include "SwitcherController.h" #include "SessionController.h" +#include "SpreadFilter.h" #include "UBusWrapper.h" #include "UnityshellPrivate.h" #include "UnityShowdesktopHandler.h" @@ -118,6 +119,7 @@ public: CompScreen* screen; CompositeScreen* cScreen; GLScreen* gScreen; + ScaleScreen* sScreen; /* prepares nux for drawing */ void nuxPrologue(); @@ -327,6 +329,7 @@ private: session::Controller::Ptr session_controller_; debug::DebugDBusInterface debugger_; std::unique_ptr bghash_; + spread::Filter::Ptr spread_filter_; /* Subscription for gestures that manipulate Unity launcher */ std::unique_ptr gestures_sub_launcher_; -- cgit v1.2.3 From 9e51c47e778fb308159fb04237a15ce787f4865d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Mon, 17 Feb 2014 05:11:02 +0100 Subject: UnityShell: set scalefilter as a conflicting plugin (bzr r3656.5.5) --- plugins/unityshell/unityshell_xml.in | 1 + 1 file changed, 1 insertion(+) (limited to 'plugins') diff --git a/plugins/unityshell/unityshell_xml.in b/plugins/unityshell/unityshell_xml.in index ac484f319..87e8d618e 100644 --- a/plugins/unityshell/unityshell_xml.in +++ b/plugins/unityshell/unityshell_xml.in @@ -43,6 +43,7 @@ decor + scalefilter -- cgit v1.2.3 From d3349ac4a9f8a893e3b1a094ca4a4c3a7a832772 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Mon, 17 Feb 2014 13:44:03 +0100 Subject: UnityScreen: check for spread selected window only if in spread mode (bzr r3656.5.6) --- plugins/unityshell/src/unityshell.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/unityshell/src/unityshell.cpp b/plugins/unityshell/src/unityshell.cpp index 5b49e76b7..13c410a9c 100644 --- a/plugins/unityshell/src/unityshell.cpp +++ b/plugins/unityshell/src/unityshell.cpp @@ -2816,7 +2816,8 @@ bool UnityWindow::glPaint(const GLWindowPaintAttrib& attrib, } } - if (uScreen->sScreen->getSelectedWindow() == window->id()) + if (WindowManager::Default().IsScaleActive() && + uScreen->sScreen->getSelectedWindow() == window->id()) { nux::Geometry const& scaled_geo = GetScaledGeometry(); paintInnerGlow(scaled_geo, matrix, attrib, mask); -- cgit v1.2.3 From 8fc8355acde288130d39d702f4ef311aa7884793 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 18 Feb 2014 00:31:02 +0100 Subject: UnityScreen: introspect spread::Filter (bzr r3656.5.15) --- plugins/unityshell/src/unityshell.cpp | 2 +- plugins/unityshell/src/unityshell.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/unityshell/src/unityshell.cpp b/plugins/unityshell/src/unityshell.cpp index 13c410a9c..340844006 100644 --- a/plugins/unityshell/src/unityshell.cpp +++ b/plugins/unityshell/src/unityshell.cpp @@ -4160,7 +4160,7 @@ void ScreenIntrospection::AddProperties(debug::IntrospectionData& introspection) Introspectable::IntrospectableList ScreenIntrospection::GetIntrospectableChildren() { - IntrospectableList children; + IntrospectableList children({uScreen->spread_filter_.get()}); for (auto const& win : screen_->windows()) children.push_back(UnityWindow::get(win)); diff --git a/plugins/unityshell/src/unityshell.h b/plugins/unityshell/src/unityshell.h index 651b5d63e..a9594f7c2 100644 --- a/plugins/unityshell/src/unityshell.h +++ b/plugins/unityshell/src/unityshell.h @@ -410,6 +410,7 @@ private: bool is_desktop_active_; friend class UnityWindow; + friend class debug::ScreenIntrospection; friend class decoration::Manager; }; -- cgit v1.2.3