Merge lp:~aacid/unity-2d/panel_click_gives_focus_to_maximized_windows into lp:unity-2d

Proposed by Albert Astals Cid
Status: Merged
Approved by: Gerry Boland
Approved revision: 1105
Merged at revision: 1109
Proposed branch: lp:~aacid/unity-2d/panel_click_gives_focus_to_maximized_windows
Merge into: lp:unity-2d
Prerequisite: lp:~aacid/unity-2d/panel_mm_fixes
Diff against target: 98 lines (+53/-1)
4 files modified
panel/applets/appname/appnameapplet.cpp (+6/-0)
panel/applets/appname/windowhelper.cpp (+26/-0)
panel/applets/appname/windowhelper.h (+2/-0)
tests/manual-tests/panel.txt (+19/-1)
To merge this branch: bzr merge lp:~aacid/unity-2d/panel_click_gives_focus_to_maximized_windows
Reviewer Review Type Date Requested Status
Gerry Boland Pending
Review via email: mp+107353@code.launchpad.net

Commit message

[panel] Clicking in the panel focuses the maximized window on that screen

Description of the change

[panel] Clicking in the panel focuses the maximized window on that screen

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'panel/applets/appname/appnameapplet.cpp'
--- panel/applets/appname/appnameapplet.cpp 2012-05-24 11:18:30 +0000
+++ panel/applets/appname/appnameapplet.cpp 2012-05-25 10:07:19 +0000
@@ -400,6 +400,12 @@
400400
401void AppNameApplet::mousePressEvent(QMouseEvent* event) {401void AppNameApplet::mousePressEvent(QMouseEvent* event) {
402 if (event->button() == Qt::LeftButton) {402 if (event->button() == Qt::LeftButton) {
403 if (!d->m_label->geometry().contains(event->pos()) || !d->m_label->isVisible()) {
404 // Clicked outside the label and outside the menus
405 // focus the top most maximized window
406 d->m_windowHelper->focusTopMostMaximizedWindowOnScreen();
407 }
408
403 d->m_dragStartPosition = event->pos();409 d->m_dragStartPosition = event->pos();
404 d->m_dragInProgress = true;410 d->m_dragInProgress = true;
405 } else {411 } else {
406412
=== modified file 'panel/applets/appname/windowhelper.cpp'
--- panel/applets/appname/windowhelper.cpp 2012-05-25 10:07:19 +0000
+++ panel/applets/appname/windowhelper.cpp 2012-05-25 10:07:19 +0000
@@ -178,6 +178,32 @@
178 return true;178 return true;
179}179}
180180
181void WindowHelper::focusTopMostMaximizedWindowOnScreen() const
182{
183 WnckWindow *topMostMaximizedWindowOnScreen = NULL;
184 GList *stack = wnck_screen_get_windows_stacked(wnck_screen_get_default());
185 GList *cur = stack;
186 while (cur) {
187 WnckWindow *window = (WnckWindow*) cur->data;
188
189 if (window != NULL) {
190 if (wnck_window_is_maximized(window)) {
191 // Check the window screen
192 int x, y, width, height;
193 wnck_window_get_geometry(window, &x, &y, &width, &height);
194 if (QApplication::desktop()->screenNumber(QRect(x, y, width, height).center()) == d->screen()) {
195 topMostMaximizedWindowOnScreen = window;
196 }
197 }
198 }
199 cur = g_list_next(cur);
200 }
201
202 if (topMostMaximizedWindowOnScreen) {
203 wnck_window_activate(topMostMaximizedWindowOnScreen, CurrentTime);
204 }
205}
206
181void WindowHelper::close()207void WindowHelper::close()
182{208{
183 if (DashClient::instance()->activeInScreen(d->screen())) {209 if (DashClient::instance()->activeInScreen(d->screen())) {
184210
=== modified file 'panel/applets/appname/windowhelper.h'
--- panel/applets/appname/windowhelper.h 2012-05-24 11:18:30 +0000
+++ panel/applets/appname/windowhelper.h 2012-05-25 10:07:19 +0000
@@ -44,6 +44,8 @@
44 bool isMaximized() const;44 bool isMaximized() const;
45 bool isMostlyOnScreen(int screen) const;45 bool isMostlyOnScreen(int screen) const;
4646
47 void focusTopMostMaximizedWindowOnScreen() const;
48
47public Q_SLOTS:49public Q_SLOTS:
48 void close();50 void close();
49 void minimize();51 void minimize();
5052
=== modified file 'tests/manual-tests/panel.txt'
--- tests/manual-tests/panel.txt 2012-05-25 10:07:19 +0000
+++ tests/manual-tests/panel.txt 2012-05-25 10:07:19 +0000
@@ -58,8 +58,26 @@
58 * Double click the panel in the monitor that does not contain the window58 * Double click the panel in the monitor that does not contain the window
59 * Verify the window stays maximized59 * Verify the window stays maximized
60----60----
61* Have two monitors61 * Have two monitors
62 * Maximize one window62 * Maximize one window
63 * Press and drag the mouse in the panel in the monitor that does not contain the window63 * Press and drag the mouse in the panel in the monitor that does not contain the window
64 * Verify the window stays unaffected64 * Verify the window stays unaffected
65----65----
66 * Have two monitors
67 * Maximize one window in each monitor
68 * Give focus to windown in monitor 1
69 * Click in the panel of monitor 2
70 * Verify the window from monitor 2 gets the focus
71----
72 * Have two monitors
73 * Maximize one window in each monitor
74 * Give focus to windown in monitor 1
75 * Press and drag the mouse in the panel of monitor 2 (has the window without focus)
76 * Verify the window from monitor 2 gets the focus and starts to be dragged
77----
78 * Have two windows in one monitor
79 * Maximize one window
80 * Give focus to unmaximized one
81 * Click in the panel (not in window label nor menus)
82 * Verify focus goes to the maximized window
83----

Subscribers

People subscribed via source and target branches