Merge lp:~3v1n0/unity/disabled-close-winbutton-support into lp:unity

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Marco Trevisan (Treviño)
Approved revision: no longer in the source branch.
Merged at revision: 2321
Proposed branch: lp:~3v1n0/unity/disabled-close-winbutton-support
Merge into: lp:unity
Diff against target: 134 lines (+57/-1)
6 files modified
manual-tests/WindowButtons.txt (+11/-0)
plugins/unityshell/src/PluginAdapter.cpp (+26/-0)
plugins/unityshell/src/PluginAdapter.h (+2/-0)
plugins/unityshell/src/WindowButtons.cpp (+6/-1)
plugins/unityshell/src/WindowManager.cpp (+10/-0)
plugins/unityshell/src/WindowManager.h (+2/-0)
To merge this branch: bzr merge lp:~3v1n0/unity/disabled-close-winbutton-support
Reviewer Review Type Date Requested Status
Thomi Richards (community) Approve
Brandon Schaefer (community) Approve
Review via email: mp+101981@code.launchpad.net

Commit message

WindowButtons: disable the close button if the controlled window is not closable

Added support to WindowManager to get if a window is closable and maximizable, then used the IsWindowClosable method to enable or disable the close window button.

Description of the change

Added support to WindowManager to get if a window is closable and maximizable, then used the IsWindowClosable method to enable or disable the close window button.

This is needed by few applications that disable the close button, and it's currently quite hard to test with AP due to the missing test cases (one is the Updates Manager's packages cache updater, but only after enlarging the detailed view).
Anyway this exact behavior is already tested with AP for the not-minimizable windows.
That's why I'm including here a manual test.

To post a comment you must log in.
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

Confirmed working.

review: Approve
Revision history for this message
Thomi Richards (thomir-deactivatedaccount) wrote :

Approved with a manual test since we don't yet have the ability to generate windows with arbitrary features (It's on the TODO list).

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'manual-tests/WindowButtons.txt'
2--- manual-tests/WindowButtons.txt 1970-01-01 00:00:00 +0000
3+++ manual-tests/WindowButtons.txt 2012-04-13 22:06:26 +0000
4@@ -0,0 +1,11 @@
5+Window Close Button should be Disabled if not available
6+-------------------------------------------------------
7+
8+Actions:
9+ * Start the Update Manager
10+ * Press on the "Check" button
11+ * On the "Updating Chache" dialog, press the "Details" toggle
12+ * Press on the maximize window button that will show on the dialog decoration
13+
14+Expected Result:
15+ * The close window button should be shown as disabled (grayed)
16
17=== modified file 'plugins/unityshell/src/PluginAdapter.cpp'
18--- plugins/unityshell/src/PluginAdapter.cpp 2012-04-02 10:45:47 +0000
19+++ plugins/unityshell/src/PluginAdapter.cpp 2012-04-13 22:06:26 +0000
20@@ -522,6 +522,19 @@
21 }
22
23 bool
24+PluginAdapter::IsWindowClosable(guint32 xid)
25+{
26+ Window win = xid;
27+ CompWindow* window;
28+
29+ window = m_Screen->findWindow(win);
30+ if (window)
31+ return (window->actions() & CompWindowActionCloseMask);
32+
33+ return false;
34+}
35+
36+bool
37 PluginAdapter::IsWindowMinimizable(guint32 xid)
38 {
39 Window win = xid;
40@@ -534,6 +547,19 @@
41 return false;
42 }
43
44+bool
45+PluginAdapter::IsWindowMaximizable(guint32 xid)
46+{
47+ Window win = xid;
48+ CompWindow* window;
49+
50+ window = m_Screen->findWindow(win);
51+ if (window)
52+ return (window->actions() & MAXIMIZABLE);
53+
54+ return false;
55+}
56+
57 void
58 PluginAdapter::Restore(guint32 xid)
59 {
60
61=== modified file 'plugins/unityshell/src/PluginAdapter.h'
62--- plugins/unityshell/src/PluginAdapter.h 2012-04-02 10:45:47 +0000
63+++ plugins/unityshell/src/PluginAdapter.h 2012-04-13 22:06:26 +0000
64@@ -119,7 +119,9 @@
65 bool IsWindowObscured(guint xid);
66 bool IsWindowMapped(guint xid);
67 bool IsWindowVisible(guint32 xid);
68+ bool IsWindowClosable(guint32 xid);
69 bool IsWindowMinimizable(guint32 xid);
70+ bool IsWindowMaximizable(guint32 xid);
71
72 void Restore(guint32 xid);
73 void RestoreAt(guint32 xid, int x, int y);
74
75=== modified file 'plugins/unityshell/src/WindowButtons.cpp'
76--- plugins/unityshell/src/WindowButtons.cpp 2012-04-04 20:13:10 +0000
77+++ plugins/unityshell/src/WindowButtons.cpp 2012-04-13 22:06:26 +0000
78@@ -725,11 +725,16 @@
79 {
80 auto button = dynamic_cast<WindowButton*>(area);
81
82+ if (button->GetType() == panel::WindowButtonType::CLOSE)
83+ {
84+ bool closable = WindowManager::Default()->IsWindowClosable(xid);
85+ button->SetEnabled(closable);
86+ }
87+
88 if (button->GetType() == panel::WindowButtonType::MINIMIZE)
89 {
90 bool minimizable = WindowManager::Default()->IsWindowMinimizable(xid);
91 button->SetEnabled(minimizable);
92- break;
93 }
94 }
95 }
96
97=== modified file 'plugins/unityshell/src/WindowManager.cpp'
98--- plugins/unityshell/src/WindowManager.cpp 2012-04-02 10:45:47 +0000
99+++ plugins/unityshell/src/WindowManager.cpp 2012-04-13 22:06:26 +0000
100@@ -73,11 +73,21 @@
101 return true;
102 }
103
104+ bool IsWindowClosable(guint32 xid)
105+ {
106+ return true;
107+ }
108+
109 bool IsWindowMinimizable(guint32 xid)
110 {
111 return true;
112 }
113
114+ bool IsWindowMaximizable(guint32 xid)
115+ {
116+ return true;
117+ }
118+
119 void Restore(guint32 xid)
120 {
121 g_debug("%s", G_STRFUNC);
122
123=== modified file 'plugins/unityshell/src/WindowManager.h'
124--- plugins/unityshell/src/WindowManager.h 2012-04-02 10:45:47 +0000
125+++ plugins/unityshell/src/WindowManager.h 2012-04-13 22:06:26 +0000
126@@ -61,7 +61,9 @@
127 virtual bool IsWindowObscured(guint32 xid) = 0;
128 virtual bool IsWindowMapped(guint32 xid) = 0;
129 virtual bool IsWindowVisible(guint32 xid) = 0;
130+ virtual bool IsWindowClosable(guint32 xid) = 0;
131 virtual bool IsWindowMinimizable(guint32 xid) = 0;
132+ virtual bool IsWindowMaximizable(guint32 xid) = 0;
133
134 virtual void ShowDesktop() = 0;
135