summaryrefslogtreecommitdiff
path: root/plugins
diff options
authorMarco Trevisan (Treviño) <mail@3v1n0.net>2014-02-17 05:05:06 +0100
committerMarco Trevisan (Treviño) <mail@3v1n0.net>2014-02-17 05:05:06 +0100
commit83108e16d857ccaf8230693be15d7566f3cabf1d (patch)
tree438b025ef9da6321241614f99e6ec73c448fa157 /plugins
parentd88a9c6ab2ca9a429af88c895807b0f1b58cddf5 (diff)
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)
Diffstat (limited to 'plugins')
-rw-r--r--plugins/unityshell/src/unityshell.cpp89
-rw-r--r--plugins/unityshell/src/unityshell.h3
2 files changed, 62 insertions, 30 deletions
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<menu::Manager>(std::make_shared<indicator::DBusIndicators>(), std::make_shared<key::GnomeGrabber>()))
, deco_manager_(std::make_shared<decoration::Manager>())
, 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>();
+ 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<UnityScreen, UnityWindow>::handleEvent (event);
+ compiz::CompizMinimizedWindowHandler<UnityScreen, UnityWindow>::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> bghash_;
+ spread::Filter::Ptr spread_filter_;
/* Subscription for gestures that manipulate Unity launcher */
std::unique_ptr<nux::GesturesSubscription> gestures_sub_launcher_;