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

Proposed by Albert Astals Cid on 2012-05-25
Status: Merged
Approved by: Gerry Boland on 2012-05-28
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 2012-05-25 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
1=== modified file 'panel/applets/appname/appnameapplet.cpp'
2--- panel/applets/appname/appnameapplet.cpp 2012-05-24 11:18:30 +0000
3+++ panel/applets/appname/appnameapplet.cpp 2012-05-25 10:07:19 +0000
4@@ -400,6 +400,12 @@
5
6 void AppNameApplet::mousePressEvent(QMouseEvent* event) {
7 if (event->button() == Qt::LeftButton) {
8+ if (!d->m_label->geometry().contains(event->pos()) || !d->m_label->isVisible()) {
9+ // Clicked outside the label and outside the menus
10+ // focus the top most maximized window
11+ d->m_windowHelper->focusTopMostMaximizedWindowOnScreen();
12+ }
13+
14 d->m_dragStartPosition = event->pos();
15 d->m_dragInProgress = true;
16 } else {
17
18=== modified file 'panel/applets/appname/windowhelper.cpp'
19--- panel/applets/appname/windowhelper.cpp 2012-05-25 10:07:19 +0000
20+++ panel/applets/appname/windowhelper.cpp 2012-05-25 10:07:19 +0000
21@@ -178,6 +178,32 @@
22 return true;
23 }
24
25+void WindowHelper::focusTopMostMaximizedWindowOnScreen() const
26+{
27+ WnckWindow *topMostMaximizedWindowOnScreen = NULL;
28+ GList *stack = wnck_screen_get_windows_stacked(wnck_screen_get_default());
29+ GList *cur = stack;
30+ while (cur) {
31+ WnckWindow *window = (WnckWindow*) cur->data;
32+
33+ if (window != NULL) {
34+ if (wnck_window_is_maximized(window)) {
35+ // Check the window screen
36+ int x, y, width, height;
37+ wnck_window_get_geometry(window, &x, &y, &width, &height);
38+ if (QApplication::desktop()->screenNumber(QRect(x, y, width, height).center()) == d->screen()) {
39+ topMostMaximizedWindowOnScreen = window;
40+ }
41+ }
42+ }
43+ cur = g_list_next(cur);
44+ }
45+
46+ if (topMostMaximizedWindowOnScreen) {
47+ wnck_window_activate(topMostMaximizedWindowOnScreen, CurrentTime);
48+ }
49+}
50+
51 void WindowHelper::close()
52 {
53 if (DashClient::instance()->activeInScreen(d->screen())) {
54
55=== modified file 'panel/applets/appname/windowhelper.h'
56--- panel/applets/appname/windowhelper.h 2012-05-24 11:18:30 +0000
57+++ panel/applets/appname/windowhelper.h 2012-05-25 10:07:19 +0000
58@@ -44,6 +44,8 @@
59 bool isMaximized() const;
60 bool isMostlyOnScreen(int screen) const;
61
62+ void focusTopMostMaximizedWindowOnScreen() const;
63+
64 public Q_SLOTS:
65 void close();
66 void minimize();
67
68=== modified file 'tests/manual-tests/panel.txt'
69--- tests/manual-tests/panel.txt 2012-05-25 10:07:19 +0000
70+++ tests/manual-tests/panel.txt 2012-05-25 10:07:19 +0000
71@@ -58,8 +58,26 @@
72 * Double click the panel in the monitor that does not contain the window
73 * Verify the window stays maximized
74 ----
75-* Have two monitors
76+ * Have two monitors
77 * Maximize one window
78 * Press and drag the mouse in the panel in the monitor that does not contain the window
79 * Verify the window stays unaffected
80 ----
81+ * Have two monitors
82+ * Maximize one window in each monitor
83+ * Give focus to windown in monitor 1
84+ * Click in the panel of monitor 2
85+ * Verify the window from monitor 2 gets the focus
86+----
87+ * Have two monitors
88+ * Maximize one window in each monitor
89+ * Give focus to windown in monitor 1
90+ * Press and drag the mouse in the panel of monitor 2 (has the window without focus)
91+ * Verify the window from monitor 2 gets the focus and starts to be dragged
92+----
93+ * Have two windows in one monitor
94+ * Maximize one window
95+ * Give focus to unmaximized one
96+ * Click in the panel (not in window label nor menus)
97+ * Verify focus goes to the maximized window
98+----

Subscribers

People subscribed via source and target branches