From 23399d2388918320cebbda7576da02d50c3507d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Sat, 28 Jan 2012 18:12:50 +0100 Subject: WindowManager (PluginAdapter): support methods to (right/left)-maximize and check the status They allow to maximize a window, or to vertically maximize it and put on a side of the screen. (bzr r1820.4.1) --- plugins/unityshell/src/PluginAdapter.cpp | 146 ++++++++++++++++++++++++++++++- plugins/unityshell/src/PluginAdapter.h | 14 ++- plugins/unityshell/src/WindowManager.cpp | 30 +++++++ plugins/unityshell/src/WindowManager.h | 7 ++ 4 files changed, 195 insertions(+), 2 deletions(-) (limited to 'plugins/unityshell') diff --git a/plugins/unityshell/src/PluginAdapter.cpp b/plugins/unityshell/src/PluginAdapter.cpp index 82e18fd92..ed064c795 100644 --- a/plugins/unityshell/src/PluginAdapter.cpp +++ b/plugins/unityshell/src/PluginAdapter.cpp @@ -293,6 +293,12 @@ MultiActionList::TerminateAll(CompOption::Vector& extraArgs) } } +guint32 +PluginAdapter::GetActiveWindow() +{ + return m_Screen->activeWindow(); +} + unsigned long long PluginAdapter::GetWindowActiveNumber (guint32 xid) { @@ -399,6 +405,33 @@ PluginAdapter::IsWindowMaximized(guint xid) return false; } +bool +PluginAdapter::IsWindowVerticallyMaximized(guint32 xid) +{ + Window win = (Window)xid; + CompWindow* window; + + window = m_Screen->findWindow(win); + if (window) + return (window->state() & CompWindowStateMaximizedVertMask); + + return false; +} + +bool +PluginAdapter::IsWindowHorizontallyMaximized(guint32 xid) +{ + Window win = (Window)xid; + CompWindow* window; + + window = m_Screen->findWindow(win); + if (window) + return (window->state() & CompWindowStateMaximizedHorzMask); + + return false; +} + + bool PluginAdapter::IsWindowDecorated(guint32 xid) { @@ -505,6 +538,81 @@ PluginAdapter::IsWindowVisible(guint32 xid) return true; } +void +PluginAdapter::Maximize(guint32 xid) +{ + Window win = (Window)xid; + CompWindow* window; + + window = m_Screen->findWindow(win); + if (window && ((window->type() & CompWindowTypeNormalMask) || + (window->actions() & MAXIMIZABLE))) + { + window->maximize(MAXIMIZE_STATE); + } +} + +void +PluginAdapter::VerticallyMaximizeWindowAt(CompWindow* window, nux::Geometry const& geo) +{ + if (window && ((window->type() & CompWindowTypeNormalMask) || + ((window->actions() & CompWindowActionMaximizeVertMask) && + window->actions() & CompWindowActionResizeMask))) + { + /* First we unmaximize the Window */ + if (window->state() & MAXIMIZE_STATE) + window->maximize(0); + + /* Then we vertically maximize the it so it can be unminimized correctly */ + if (!(window->state() & CompWindowStateMaximizedVertMask)) + window->maximize(CompWindowStateMaximizedVertMask); + + /* Then we resize and move it on the requested place */ + MoveResizeWindow(window->id(), geo); + } +} + + +void +PluginAdapter::LeftMaximize(guint32 xid) +{ + Window win = (Window)xid; + CompWindow* window; + + window = m_Screen->findWindow(win); + if (!window) + return; + + /* Let's compute the area where the window should be put */ + CompRect workarea = m_Screen->getWorkareaForOutput(window->outputDevice()); + nux::Geometry win_geo(workarea.x() + window->border().left, + workarea.y() + window->border().top, + workarea.width() / 2 - (window->border().left + window->border().right), + workarea.height() - (window->border().top + window->border().bottom)); + + VerticallyMaximizeWindowAt(window, win_geo); +} + +void +PluginAdapter::RightMaximize(guint32 xid) +{ + Window win = (Window)xid; + CompWindow* window; + + window = m_Screen->findWindow(win); + if (!window) + return; + + /* Let's compute the area where the window should be put */ + CompRect workarea = m_Screen->getWorkareaForOutput(window->outputDevice()); + nux::Geometry win_geo(workarea.x() + workarea.width() / 2 + window->border().left, + workarea.y() + window->border().top, + workarea.width() / 2 - (window->border().left + window->border().right), + workarea.height() - (window->border().top + window->border().bottom)); + + VerticallyMaximizeWindowAt(window, win_geo); +} + void PluginAdapter::Restore(guint32 xid) { @@ -523,7 +631,7 @@ PluginAdapter::Minimize(guint32 xid) CompWindow* window; window = m_Screen->findWindow(win); - if (window) + if (window && (window->actions() & CompWindowActionMinimizeMask)) window->minimize(); } @@ -1049,6 +1157,42 @@ PluginAdapter::restoreInputFocus() return false; } +void +PluginAdapter::MoveResizeWindow(guint32 xid, nux::Geometry geometry) +{ + int w, h; + CompWindow* window = m_Screen->findWindow(xid); + + if (!window) + return; + + if (window->constrainNewWindowSize(geometry.width, geometry.height, &w, &h)) + { + CompRect workarea = m_Screen->getWorkareaForOutput(window->outputDevice()); + int dx = geometry.x + w - workarea.right() + window->border().right; + int dy = geometry.y + h - workarea.bottom() + window->border().bottom; + + if (dx > 0) + geometry.x -= dx; + if (dy > 0) + geometry.y -= dy; + + geometry.SetWidth(w); + geometry.SetHeight(h); + } + + XWindowChanges xwc; + xwc.x = geometry.x; + xwc.y = geometry.y; + xwc.width = geometry.width; + xwc.height = geometry.height; + + if (window->mapNum()) + window->sendSyncRequest(); + + window->configureXWindow(CWX | CWY | CWWidth | CWHeight, &xwc); +} + void PluginAdapter::OnWindowClosed(CompWindow *w) { diff --git a/plugins/unityshell/src/PluginAdapter.h b/plugins/unityshell/src/PluginAdapter.h index 8071a3a4a..1b75c3dde 100644 --- a/plugins/unityshell/src/PluginAdapter.h +++ b/plugins/unityshell/src/PluginAdapter.h @@ -108,19 +108,27 @@ public: void NotifyCompizEvent(const char* plugin, const char* event, CompOption::Vector& option); void NotifyNewDecorationState(guint32 xid); + guint32 GetActiveWindow(); + void Decorate(guint32 xid); void Undecorate(guint32 xid); // WindowManager implementation bool IsWindowMaximized(guint xid); + bool IsWindowVerticallyMaximized(guint32 xid); + bool IsWindowHorizontallyMaximized(guint32 xid); bool IsWindowDecorated(guint xid); bool IsWindowOnCurrentDesktop(guint xid); bool IsWindowObscured(guint xid); bool IsWindowMapped(guint xid); bool IsWindowVisible(guint32 xid); + + void Maximize(guint32 xid); void Restore(guint32 xid); void Minimize(guint32 xid); void Close(guint32 xid); + void LeftMaximize(guint32 xid); + void RightMaximize(guint32 xid); void Activate(guint32 xid); void Raise(guint32 xid); void Lower(guint32 xid); @@ -140,7 +148,7 @@ public: nux::Geometry GetWindowGeometry(guint32 xid); nux::Geometry GetScreenGeometry(); - + void CheckWindowIntersections(nux::Geometry const& region, bool &active, bool &any); int WorkspaceCount(); @@ -150,6 +158,8 @@ public: bool saveInputFocus (); bool restoreInputFocus (); + void MoveResizeWindow(guint32 xid, nux::Geometry geometry); + protected: PluginAdapter(CompScreen* screen); @@ -160,6 +170,8 @@ private: bool CheckWindowIntersection(nux::Geometry const& region, CompWindow* window); void SetMwmWindowHints(Window xid, MotifWmHints* new_hints); + void VerticallyMaximizeWindowAt(CompWindow* window, nux::Geometry const& geo); + CompScreen* m_Screen; MultiActionList m_ExpoActionList; MultiActionList m_ScaleActionList; diff --git a/plugins/unityshell/src/WindowManager.cpp b/plugins/unityshell/src/WindowManager.cpp index 39c66de6a..6abac6670 100644 --- a/plugins/unityshell/src/WindowManager.cpp +++ b/plugins/unityshell/src/WindowManager.cpp @@ -23,6 +23,11 @@ static WindowManager* window_manager = NULL; class WindowManagerDummy : public WindowManager { + guint32 GetActiveWindow() + { + return 0; + } + unsigned long long GetWindowActiveNumber (guint32 xid) { return 0; @@ -48,6 +53,16 @@ class WindowManagerDummy : public WindowManager return false; } + bool IsWindowVerticallyMaximized(guint32 xid) + { + return false; + } + + bool IsWindowHorizontallyMaximized(guint32 xid) + { + return false; + } + bool IsWindowDecorated(guint32 xid) { return true; @@ -73,6 +88,11 @@ class WindowManagerDummy : public WindowManager return true; } + void Maximize(guint32 xid) + { + g_debug("%s", G_STRFUNC); + } + void Restore(guint32 xid) { g_debug("%s", G_STRFUNC); @@ -88,6 +108,16 @@ class WindowManagerDummy : public WindowManager g_debug("%s", G_STRFUNC); } + void RightMaximize(guint32 xid) + { + g_debug("%s", G_STRFUNC); + } + + void LeftMaximize(guint32 xid) + { + g_debug("%s", G_STRFUNC); + } + void Activate(guint32 xid) { g_debug("%s", G_STRFUNC); diff --git a/plugins/unityshell/src/WindowManager.h b/plugins/unityshell/src/WindowManager.h index 5663483b7..df20c9dea 100644 --- a/plugins/unityshell/src/WindowManager.h +++ b/plugins/unityshell/src/WindowManager.h @@ -55,7 +55,11 @@ public: static WindowManager* Default(); static void SetDefault(WindowManager* manager); + virtual guint32 GetActiveWindow() = 0; + virtual bool IsWindowMaximized(guint32 xid) = 0; + virtual bool IsWindowVerticallyMaximized(guint32 xid) = 0; + virtual bool IsWindowHorizontallyMaximized(guint32 xid) = 0; virtual bool IsWindowDecorated(guint32 xid) = 0; virtual bool IsWindowOnCurrentDesktop(guint32 xid) = 0; virtual bool IsWindowObscured(guint32 xid) = 0; @@ -64,9 +68,12 @@ public: virtual void ShowDesktop() = 0; + virtual void Maximize(guint32 xid) = 0; virtual void Restore(guint32 xid) = 0; virtual void Minimize(guint32 xid) = 0; virtual void Close(guint32 xid) = 0; + virtual void RightMaximize(guint32 xid) = 0; + virtual void LeftMaximize(guint32 xid) = 0; virtual void Activate(guint32 xid) = 0; virtual void Raise(guint32 xid) = 0; -- cgit v1.2.3 From d69c5d74da29c7d28a91aee902c5c67f05e9c17c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Sat, 28 Jan 2012 18:13:52 +0100 Subject: UnityScreen: add support for Super+Arrows shortcuts to manage the focused window Super+Arrows shortcut allows to move and maximize / restore / minimize the focused window on the screen. (bzr r1820.4.2) --- plugins/unityshell/src/unityshell.cpp | 49 +++++++++++++++++++++++++++++++++++ plugins/unityshell/src/unityshell.h | 5 ++++ plugins/unityshell/unityshell_xml.in | 20 ++++++++++++++ 3 files changed, 74 insertions(+) (limited to 'plugins/unityshell') diff --git a/plugins/unityshell/src/unityshell.cpp b/plugins/unityshell/src/unityshell.cpp index de1c5a629..c86800af9 100644 --- a/plugins/unityshell/src/unityshell.cpp +++ b/plugins/unityshell/src/unityshell.cpp @@ -307,6 +307,11 @@ UnityScreen::UnityScreen(CompScreen* screen) optionSetLauncherSwitcherPrevInitiate(boost::bind(&UnityScreen::launcherSwitcherPrevInitiate, this, _1, _2, _3)); optionSetLauncherSwitcherForwardTerminate(boost::bind(&UnityScreen::launcherSwitcherTerminate, this, _1, _2, _3)); + optionSetWindowMaximizeInitiate(boost::bind(&UnityScreen::maximizeKeyInitate, this, _1, _2, _3)); + optionSetWindowRestoreMinimizeInitiate(boost::bind(&UnityScreen::restoreMinimizeKeyInitiate, this, _1, _2, _3)); + optionSetWindowRightMaximizeInitiate(boost::bind(&UnityScreen::rightMaximizeKeyInitiate, this, _1, _2, _3)); + optionSetWindowLeftMaximizeInitiate(boost::bind(&UnityScreen::leftMaximizeKeyInitiate, this, _1, _2, _3)); + optionSetStopVelocityNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2)); optionSetRevealPressureNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2)); optionSetOvercomePressureNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2)); @@ -1712,12 +1717,14 @@ bool UnityScreen::launcherSwitcherForwardInitiate(CompAction* action, CompAction action->setState(action->state() | CompAction::StateTermKey); return false; } + bool UnityScreen::launcherSwitcherPrevInitiate(CompAction* action, CompAction::State state, CompOption::Vector& options) { launcher_controller_->KeyNavPrevious(); return false; } + bool UnityScreen::launcherSwitcherTerminate(CompAction* action, CompAction::State state, CompOption::Vector& options) { bool accept_state = (state & CompAction::StateCancel) == 0; @@ -1728,6 +1735,48 @@ bool UnityScreen::launcherSwitcherTerminate(CompAction* action, CompAction::Stat return false; } +bool UnityScreen::maximizeKeyInitate(CompAction* action, CompAction::State state, CompOption::Vector& options) +{ + WindowManager* wm = PluginAdapter::Default(); + wm->Maximize(wm->GetActiveWindow()); + + return false; +} + +bool UnityScreen::restoreMinimizeKeyInitiate(CompAction* action, CompAction::State state, CompOption::Vector& options) +{ + WindowManager* wm = PluginAdapter::Default(); + guint32 focused_win = wm->GetActiveWindow(); + + if (wm->IsWindowVerticallyMaximized(focused_win) || + wm->IsWindowHorizontallyMaximized(focused_win)) + { + wm->Restore(focused_win); + } + else + { + wm->Minimize(focused_win); + } + + return false; +} + +bool UnityScreen::rightMaximizeKeyInitiate(CompAction* action, CompAction::State state, CompOption::Vector& options) +{ + WindowManager* wm = PluginAdapter::Default(); + wm->RightMaximize(wm->GetActiveWindow()); + + return false; +} + +bool UnityScreen::leftMaximizeKeyInitiate(CompAction* action, CompAction::State state, CompOption::Vector& options) +{ + WindowManager* wm = PluginAdapter::Default(); + wm->LeftMaximize(wm->GetActiveWindow()); + + return false; +} + void UnityScreen::OnLauncherStartKeyNav(GVariant* data) { startLauncherKeyNav(); diff --git a/plugins/unityshell/src/unityshell.h b/plugins/unityshell/src/unityshell.h index 8fa44f8ab..e547a6bed 100644 --- a/plugins/unityshell/src/unityshell.h +++ b/plugins/unityshell/src/unityshell.h @@ -206,6 +206,11 @@ public: bool launcherSwitcherPrevInitiate(CompAction* action, CompAction::State state, CompOption::Vector& options); bool launcherSwitcherTerminate(CompAction* action, CompAction::State state, CompOption::Vector& options); + bool maximizeKeyInitate(CompAction* action, CompAction::State state, CompOption::Vector& options); + bool restoreMinimizeKeyInitiate(CompAction* action, CompAction::State state, CompOption::Vector& options); + bool rightMaximizeKeyInitiate(CompAction* action, CompAction::State state, CompOption::Vector& options); + bool leftMaximizeKeyInitiate(CompAction* action, CompAction::State state, CompOption::Vector& options); + /* handle option changes and change settings inside of the * panel and dock views */ void optionChanged(CompOption*, Options num); diff --git a/plugins/unityshell/unityshell_xml.in b/plugins/unityshell/unityshell_xml.in index 6de5a413a..0e8256116 100644 --- a/plugins/unityshell/unityshell_xml.in +++ b/plugins/unityshell/unityshell_xml.in @@ -95,6 +95,26 @@ <_long>Switch the applications using the launcher, in reverse order <Super><Shift>Tab + + + + <_short>Switcher -- cgit v1.2.3 From f6d246c46060ab8bf854ab928512ccd8e21b554b Mon Sep 17 00:00:00 2001 From: Brandon Schaefer Date: Mon, 15 Jul 2013 18:08:36 -0700 Subject: * You can use the mouse now in the switcher :) (bzr r3426.1.1) --- plugins/unityshell/src/unityshell.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'plugins/unityshell') diff --git a/plugins/unityshell/src/unityshell.cpp b/plugins/unityshell/src/unityshell.cpp index ffcec742e..76483d3d4 100644 --- a/plugins/unityshell/src/unityshell.cpp +++ b/plugins/unityshell/src/unityshell.cpp @@ -1703,8 +1703,9 @@ void UnityScreen::handleEvent(XEvent* event) break; } - if (!skip_other_plugins && - screen->otherGrabExist("deco", "move", "switcher", "resize", "unity-switcher", nullptr)) + if ((!skip_other_plugins && + screen->otherGrabExist("deco", "move", "switcher", "resize", "unity-switcher", nullptr)) || + switcher_controller_->Visible()) { wt->ProcessForeignEvent(event, nullptr); } @@ -1901,7 +1902,7 @@ bool UnityScreen::setKeyboardFocusKeyInitiate(CompAction* action, bool UnityScreen::altTabInitiateCommon(CompAction* action, switcher::ShowMode show_mode) { if (!grab_index_) - grab_index_ = screen->pushGrab (screen->invisibleCursor(), "unity-switcher"); + grab_index_ = screen->pushGrab (screen->normalCursor(), "unity-switcher"); screen->addAction(&optionGetAltTabRight()); screen->addAction(&optionGetAltTabDetailStart()); -- cgit v1.2.3 From 9f9e10aa844376ca10a30eadbe3bbe24b4dab7eb Mon Sep 17 00:00:00 2001 From: Brandon Schaefer Date: Tue, 16 Jul 2013 13:18:14 -0700 Subject: * Add right clicking to toggle detail mode. * Refactor lambda funciton into a CB functions (bzr r3426.1.2) --- plugins/unityshell/src/unityshell.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'plugins/unityshell') diff --git a/plugins/unityshell/src/unityshell.cpp b/plugins/unityshell/src/unityshell.cpp index 76483d3d4..83dc72c8b 100644 --- a/plugins/unityshell/src/unityshell.cpp +++ b/plugins/unityshell/src/unityshell.cpp @@ -1703,9 +1703,8 @@ void UnityScreen::handleEvent(XEvent* event) break; } - if ((!skip_other_plugins && - screen->otherGrabExist("deco", "move", "switcher", "resize", "unity-switcher", nullptr)) || - switcher_controller_->Visible()) + if (!skip_other_plugins && + screen->otherGrabExist("deco", "move", "switcher", "resize", nullptr)) { wt->ProcessForeignEvent(event, nullptr); } -- cgit v1.2.3 From a5ec5795633a416a472fdb6e62bc179b555934ee Mon Sep 17 00:00:00 2001 From: Brandon Schaefer Date: Thu, 18 Jul 2013 16:10:43 -0700 Subject: * Moves scrolling event handing inside SwitcherView (bzr r3426.1.8) --- plugins/unityshell/src/unityshell.cpp | 38 +++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 15 deletions(-) (limited to 'plugins/unityshell') diff --git a/plugins/unityshell/src/unityshell.cpp b/plugins/unityshell/src/unityshell.cpp index 83dc72c8b..89934c2dc 100644 --- a/plugins/unityshell/src/unityshell.cpp +++ b/plugins/unityshell/src/unityshell.cpp @@ -1510,6 +1510,14 @@ void UnityScreen::handleEvent(XEvent* event) if (CompWindow *w = screen->findWindow(ss->getSelectedWindow())) skip_other_plugins = UnityWindow::get(w)->handleEvent(event); } + else if (switcher_controller_->IsDetailViewShown()) + { + Window win = switcher_controller_->GetCurrentSelection().window_; + CompWindow* w = screen->findWindow(win); + + if (w) + skip_other_plugins = UnityWindow::get(w)->handleEvent(event); + } break; case ButtonPress: if (super_keypressed_) @@ -1523,6 +1531,14 @@ void UnityScreen::handleEvent(XEvent* event) if (CompWindow *w = screen->findWindow(ss->getSelectedWindow())) skip_other_plugins = UnityWindow::get(w)->handleEvent(event); } + else if (switcher_controller_->IsDetailViewShown()) + { + Window win = switcher_controller_->GetCurrentSelection().window_; + CompWindow* w = screen->findWindow(win); + + if (w) + skip_other_plugins = UnityWindow::get(w)->handleEvent(event); + } if (dash_controller_->IsVisible()) { @@ -1567,22 +1583,14 @@ void UnityScreen::handleEvent(XEvent* event) } break; case ButtonRelease: - if (switcher_controller_ && switcher_controller_->Visible()) + + if (switcher_controller_->IsDetailViewShown()) { - XButtonEvent *bev = reinterpret_cast(event); - if (bev->time - last_scroll_event_ > 150) - { - if (bev->button == Button4 || bev->button == local::SCROLL_UP_BUTTON) - { - switcher_controller_->Prev(); - last_scroll_event_ = bev->time; - } - else if (bev->button == Button5 || bev->button == local::SCROLL_DOWN_BUTTON) - { - switcher_controller_->Next(); - last_scroll_event_ = bev->time; - } - } + Window win = switcher_controller_->GetCurrentSelection().window_; + CompWindow* w = screen->findWindow(win); + + if (w) + skip_other_plugins = UnityWindow::get(w)->handleEvent(event); } else if (wm.IsScaleActive()) { -- cgit v1.2.3 From d8b5ce771cb9bfd3ffddf89d990a238dc0faf11d Mon Sep 17 00:00:00 2001 From: Brandon Schaefer Date: Mon, 22 Jul 2013 17:11:11 -0700 Subject: * Fixed based on reviewers comment - Click outside closes switcher - Multi-monitor works in detail mode - Magic numbers fixed up (hopefully better names!) - Better signal names. - Flipped the scroll direction - Middle click now closes - Possibly something else! (bzr r3426.1.10) --- plugins/unityshell/src/unityshell.cpp | 85 ++++++++++++++++++++++++++--------- plugins/unityshell/src/unityshell.h | 3 ++ 2 files changed, 66 insertions(+), 22 deletions(-) (limited to 'plugins/unityshell') diff --git a/plugins/unityshell/src/unityshell.cpp b/plugins/unityshell/src/unityshell.cpp index 89934c2dc..9f1c3b17a 100644 --- a/plugins/unityshell/src/unityshell.cpp +++ b/plugins/unityshell/src/unityshell.cpp @@ -987,7 +987,24 @@ CompWindow * GetTopVisibleWindow() return top_visible_window; } - + +LayoutWindow::Ptr UnityScreen::GetSwitcherDetailLayoutWindow(Window window) const +{ + LayoutWindow::Vector const& targets = switcher_controller_->ExternalRenderTargets(); + LayoutWindow::Ptr layout_window(0); + + for (LayoutWindow::Ptr const& target : targets) + { + if (target->xid == window) + { + layout_window = target; + break; + } + } + + return layout_window; +} + void UnityWindow::enterShowDesktop () { if (!mShowdesktopHandler) @@ -1185,11 +1202,21 @@ bool UnityWindow::handleEvent(XEvent *event) cWindow->addDamageRect(CompRect(g.x, g.y, g.width, g.height)); handled = true; } - else if (event->xbutton.button == Button2 && - GetScaledGeometry().IsPointInside(event->xbutton.x_root, event->xbutton.y_root)) + else if (event->xbutton.button == Button2) { - middle_clicked_ = true; - handled = true; + if (UnityScreen::get (screen)->switcher_controller_->Visible()) + { + if (GetLayoutWindowGeometry().IsPointInside(event->xbutton.x_root, event->xbutton.y_root)) + { + middle_clicked_ = true; + handled = true; + } + } + else if (GetScaledGeometry().IsPointInside(event->xbutton.x_root, event->xbutton.y_root)) + { + middle_clicked_ = true; + handled = true; + } } break; @@ -1214,10 +1241,19 @@ bool UnityWindow::handleEvent(XEvent *event) if (middle_clicked_) { - if (event->xbutton.button == Button2 && - GetScaledGeometry().IsPointInside(event->xbutton.x_root, event->xbutton.y_root)) + if (event->xbutton.button == Button2) { - window->close(0); + if (UnityScreen::get (screen)->switcher_controller_->Visible()) + { + if (GetLayoutWindowGeometry().IsPointInside(event->xbutton.x_root, event->xbutton.y_root)) + { + window->close(0); + } + } + else if (GetScaledGeometry().IsPointInside(event->xbutton.x_root, event->xbutton.y_root)) + { + window->close(0); + } } middle_clicked_ = false; @@ -1566,8 +1602,7 @@ void UnityScreen::handleEvent(XEvent* event) } } } - - if (hud_controller_->IsVisible()) + else if (hud_controller_->IsVisible()) { nux::Point pt(event->xbutton.x_root, event->xbutton.y_root); nux::Geometry const& hud_geo = hud_controller_->GetInputWindowGeometry(); @@ -1581,6 +1616,16 @@ void UnityScreen::handleEvent(XEvent* event) hud_controller_->HideHud(false); } } + else if (switcher_controller_->Visible()) + { + nux::Point pt(event->xbutton.x_root, event->xbutton.y_root); + nux::Geometry const& switcher_geo = switcher_controller_->GetInputWindowGeometry(); + + if (!switcher_geo.IsInside(pt)) + { + switcher_controller_->Hide(false); + } + } break; case ButtonRelease: @@ -1940,18 +1985,6 @@ bool UnityScreen::altTabInitiateCommon(CompAction* action, switcher::ShowMode sh void UnityScreen::SetUpAndShowSwitcher(switcher::ShowMode show_mode) { - // maybe check launcher position/hide state? - - auto uscreen = UScreen::GetDefault(); - int monitor = uscreen->GetMonitorWithMouse(); - auto monitor_geo = uscreen->GetMonitorGeometry(monitor); - - monitor_geo.x += 100; - monitor_geo.y += 100; - monitor_geo.width -= 200; - monitor_geo.height -= 200; - switcher_controller_->SetWorkspace(monitor_geo, monitor); - RaiseInputWindows(); auto results = launcher_controller_->GetAltTabIcons(show_mode == switcher::ShowMode::CURRENT_VIEWPORT, @@ -3850,6 +3883,14 @@ void UnityWindow::scalePaintDecoration(GLWindowPaintAttrib const& attrib, paintFakeDecoration(scaled_geo, attrib, transform, mask, highlighted, pos.scale); } +nux::Geometry UnityWindow::GetLayoutWindowGeometry() +{ + LayoutWindow::Ptr const &layout_window = UnityScreen::get(screen)-> + GetSwitcherDetailLayoutWindow(window->id()); + + return layout_window->result; +} + nux::Geometry UnityWindow::GetScaledGeometry() { ScaleWindow* scale_win = ScaleWindow::get(window); diff --git a/plugins/unityshell/src/unityshell.h b/plugins/unityshell/src/unityshell.h index 2c35604d1..c96d91939 100644 --- a/plugins/unityshell/src/unityshell.h +++ b/plugins/unityshell/src/unityshell.h @@ -192,6 +192,8 @@ public: bool DoesPointIntersectUnityGeos(nux::Point const& pt); + ui::LayoutWindow::Ptr GetSwitcherDetailLayoutWindow(Window window) const; + protected: std::string GetName() const; void AddProperties(GVariantBuilder* builder); @@ -392,6 +394,7 @@ public: bool place(CompPoint& pos); CompPoint tryNotIntersectUI(CompPoint& pos); nux::Geometry GetScaledGeometry(); + nux::Geometry GetLayoutWindowGeometry(); void paintThumbnail(nux::Geometry const& bounding, float parent_alpha, float alpha, float scale_ratio, unsigned deco_height, bool selected); -- cgit v1.2.3 From d5db2b86692e30e40ff4e598263680ab49cac359 Mon Sep 17 00:00:00 2001 From: Chris Townsend Date: Tue, 23 Jul 2013 09:54:51 -0400 Subject: Fix yet another regression in revno. 3381 where the Panel shadow is not drawn when in Show Desktop mode. Fixes LP: #1203097 (bzr r3431.1.1) --- plugins/unityshell/src/unityshell.cpp | 9 +++++++-- plugins/unityshell/src/unityshell.h | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'plugins/unityshell') diff --git a/plugins/unityshell/src/unityshell.cpp b/plugins/unityshell/src/unityshell.cpp index ffcec742e..7daf220e1 100644 --- a/plugins/unityshell/src/unityshell.cpp +++ b/plugins/unityshell/src/unityshell.cpp @@ -150,6 +150,7 @@ UnityScreen::UnityScreen(CompScreen* screen) , big_tick_(0) , screen_introspection_(screen) , is_desktop_active_(false) + , in_show_desktop_(false) { Timer timer; #ifndef USE_GLES @@ -856,6 +857,8 @@ void UnityScreen::EnableCancelAction(CancelActionTarget target, bool enabled, in void UnityScreen::enterShowDesktopMode () { + in_show_desktop_ = true; + for (CompWindow *w : screen->windows ()) { CompPoint const& viewport = w->defaultViewport(); @@ -940,6 +943,7 @@ void UnityScreen::leaveShowDesktopMode (CompWindow *w) } } } + in_show_desktop_ = false; } bool UnityScreen::DoesPointIntersectUnityGeos(nux::Point const& pt) @@ -2642,7 +2646,8 @@ bool UnityWindow::glDraw(const GLMatrix& matrix, { top_visible_window = GetTopVisibleWindow(); - if (top_visible_window && (window->id() == top_visible_window->id())) + if ((top_visible_window && (window->id() == top_visible_window->id())) || + uScreen->in_show_desktop_) { draw_panel_shadow = DrawPanelShadow::OVER_WINDOW; } @@ -2670,7 +2675,7 @@ bool UnityWindow::glDraw(const GLMatrix& matrix, } else { - if (uScreen->is_desktop_active_) + if (uScreen->is_desktop_active_ && !uScreen->in_show_desktop_) { top_visible_window = GetTopVisibleWindow(); diff --git a/plugins/unityshell/src/unityshell.h b/plugins/unityshell/src/unityshell.h index 2c35604d1..d08268c72 100644 --- a/plugins/unityshell/src/unityshell.h +++ b/plugins/unityshell/src/unityshell.h @@ -344,6 +344,7 @@ private: glib::SourceManager sources_; bool is_desktop_active_; + bool in_show_desktop_; friend class UnityWindow; }; -- cgit v1.2.3 From 742ea950038fa727ae95f059107fffd7c48b5429 Mon Sep 17 00:00:00 2001 From: Andrea Azzarone Date: Wed, 24 Jul 2013 22:23:49 +0200 Subject: Add show_desktop_key shortcut. (bzr r3439.2.1) --- plugins/unityshell/src/unityshell.cpp | 8 ++++++++ plugins/unityshell/src/unityshell.h | 1 + plugins/unityshell/unityshell_xml.in | 6 ++++++ 3 files changed, 15 insertions(+) (limited to 'plugins/unityshell') diff --git a/plugins/unityshell/src/unityshell.cpp b/plugins/unityshell/src/unityshell.cpp index 01f446aa8..a5b5752a3 100644 --- a/plugins/unityshell/src/unityshell.cpp +++ b/plugins/unityshell/src/unityshell.cpp @@ -307,6 +307,7 @@ UnityScreen::UnityScreen(CompScreen* screen) optionSetKeyboardFocusInitiate(boost::bind(&UnityScreen::setKeyboardFocusKeyInitiate, this, _1, _2, _3)); //optionSetKeyboardFocusTerminate (boost::bind (&UnityScreen::setKeyboardFocusKeyTerminate, this, _1, _2, _3)); optionSetExecuteCommandInitiate(boost::bind(&UnityScreen::executeCommand, this, _1, _2, _3)); + optionSetShowDesktopKeyInitiate(boost::bind(&UnityScreen::showDesktopKeyInitiate, this, _1, _2, _3)); optionSetPanelFirstMenuInitiate(boost::bind(&UnityScreen::showPanelFirstMenuKeyInitiate, this, _1, _2, _3)); optionSetPanelFirstMenuTerminate(boost::bind(&UnityScreen::showPanelFirstMenuKeyTerminate, this, _1, _2, _3)); optionSetAutomaximizeValueNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2)); @@ -1889,6 +1890,13 @@ bool UnityScreen::executeCommand(CompAction* action, return true; } +bool UnityScreen::showDesktopKeyInitiate(CompAction* action, + CompAction::State state, + CompOption::Vector& options) +{ + WindowManager::Default().ShowDesktop(); + return true; +} bool UnityScreen::setKeyboardFocusKeyInitiate(CompAction* action, CompAction::State state, diff --git a/plugins/unityshell/src/unityshell.h b/plugins/unityshell/src/unityshell.h index b9a0248c1..7684ae4ca 100644 --- a/plugins/unityshell/src/unityshell.h +++ b/plugins/unityshell/src/unityshell.h @@ -141,6 +141,7 @@ public: bool showPanelFirstMenuKeyTerminate(CompAction* action, CompAction::State state, CompOption::Vector& options); bool executeCommand(CompAction* action, CompAction::State state, CompOption::Vector& options); + bool showDesktopKeyInitiate(CompAction* action, CompAction::State state, CompOption::Vector& options); bool setKeyboardFocusKeyInitiate(CompAction* action, CompAction::State state, CompOption::Vector& options); bool altTabInitiateCommon(CompAction* action, switcher::ShowMode mode); diff --git a/plugins/unityshell/unityshell_xml.in b/plugins/unityshell/unityshell_xml.in index 95bacd191..9fa3f5ea3 100644 --- a/plugins/unityshell/unityshell_xml.in +++ b/plugins/unityshell/unityshell_xml.in @@ -56,6 +56,12 @@ <Alt>F2 + + -- cgit v1.2.3 From bad5999cc1393740e0f7de3e89e35b2e6c355f71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Thu, 12 Sep 2013 23:46:23 +0200 Subject: Launcher: remove useless member variables and add some internal const (bzr r3494.5.9) --- plugins/unityshell/src/unityshell.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'plugins/unityshell') diff --git a/plugins/unityshell/src/unityshell.cpp b/plugins/unityshell/src/unityshell.cpp index 4b052125e..08e58dd14 100644 --- a/plugins/unityshell/src/unityshell.cpp +++ b/plugins/unityshell/src/unityshell.cpp @@ -2979,11 +2979,11 @@ CompPoint UnityWindow::tryNotIntersectUI(CompPoint& pos) for (auto const& launcher : launchers) { - nux::Geometry geo = launcher->GetAbsoluteGeometry(); - if (launcher->options()->hide_mode == LAUNCHER_HIDE_AUTOHIDE && launcher->Hidden()) continue; + auto const& geo = launcher->GetAbsoluteGeometry(); + if (geo.IsInside(result)) { if (geo.x + geo.width + 1 + window_geo.width() < target_monitor.x + target_monitor.width) -- cgit v1.2.3 From b66527337c02f837e1a49f9ff7eb94b4b1377bce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Sat, 14 Sep 2013 11:58:26 +0200 Subject: UnityScreen: consume the key actions or they will be repeated around (bzr r1820.4.6) --- plugins/unityshell/src/unityshell.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'plugins/unityshell') diff --git a/plugins/unityshell/src/unityshell.cpp b/plugins/unityshell/src/unityshell.cpp index 856c88e05..4c7ca7aba 100644 --- a/plugins/unityshell/src/unityshell.cpp +++ b/plugins/unityshell/src/unityshell.cpp @@ -2175,8 +2175,7 @@ bool UnityScreen::maximizeKeyInitate(CompAction* action, CompAction::State state { auto& WM = WindowManager::Default(); WM.Maximize(WM.GetActiveWindow()); - - return false; + return true; } bool UnityScreen::restoreMinimizeKeyInitiate(CompAction* action, CompAction::State state, CompOption::Vector& options) @@ -2194,23 +2193,21 @@ bool UnityScreen::restoreMinimizeKeyInitiate(CompAction* action, CompAction::Sta WM.Minimize(focused_win); } - return false; + return true; } bool UnityScreen::rightMaximizeKeyInitiate(CompAction* action, CompAction::State state, CompOption::Vector& options) { auto& WM = WindowManager::Default(); WM.RightMaximize(WM.GetActiveWindow()); - - return false; + return true; } bool UnityScreen::leftMaximizeKeyInitiate(CompAction* action, CompAction::State state, CompOption::Vector& options) { auto& WM = WindowManager::Default(); WM.LeftMaximize(WM.GetActiveWindow()); - - return false; + return true; } void UnityScreen::OnLauncherStartKeyNav(GVariant* data) -- cgit v1.2.3 From 9fc52146c32b70cb651f3a22c435bd5c669b3256 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Sat, 14 Sep 2013 13:36:32 +0200 Subject: UnityShell_xml: adapt the default window management keybindings to new values (bzr r1820.4.8) --- plugins/unityshell/unityshell_xml.in | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'plugins/unityshell') diff --git a/plugins/unityshell/unityshell_xml.in b/plugins/unityshell/unityshell_xml.in index e3817f476..b1f9ffc23 100644 --- a/plugins/unityshell/unityshell_xml.in +++ b/plugins/unityshell/unityshell_xml.in @@ -71,25 +71,25 @@ - - - - - - - - - - - -