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
=== added file 'manual-tests/WindowButtons.txt'
--- manual-tests/WindowButtons.txt 1970-01-01 00:00:00 +0000
+++ manual-tests/WindowButtons.txt 2012-04-13 22:06:26 +0000
@@ -0,0 +1,11 @@
1Window Close Button should be Disabled if not available
2-------------------------------------------------------
3
4Actions:
5 * Start the Update Manager
6 * Press on the "Check" button
7 * On the "Updating Chache" dialog, press the "Details" toggle
8 * Press on the maximize window button that will show on the dialog decoration
9
10Expected Result:
11 * The close window button should be shown as disabled (grayed)
012
=== modified file 'plugins/unityshell/src/PluginAdapter.cpp'
--- plugins/unityshell/src/PluginAdapter.cpp 2012-04-02 10:45:47 +0000
+++ plugins/unityshell/src/PluginAdapter.cpp 2012-04-13 22:06:26 +0000
@@ -522,6 +522,19 @@
522}522}
523523
524bool524bool
525PluginAdapter::IsWindowClosable(guint32 xid)
526{
527 Window win = xid;
528 CompWindow* window;
529
530 window = m_Screen->findWindow(win);
531 if (window)
532 return (window->actions() & CompWindowActionCloseMask);
533
534 return false;
535}
536
537bool
525PluginAdapter::IsWindowMinimizable(guint32 xid)538PluginAdapter::IsWindowMinimizable(guint32 xid)
526{539{
527 Window win = xid;540 Window win = xid;
@@ -534,6 +547,19 @@
534 return false;547 return false;
535}548}
536549
550bool
551PluginAdapter::IsWindowMaximizable(guint32 xid)
552{
553 Window win = xid;
554 CompWindow* window;
555
556 window = m_Screen->findWindow(win);
557 if (window)
558 return (window->actions() & MAXIMIZABLE);
559
560 return false;
561}
562
537void563void
538PluginAdapter::Restore(guint32 xid)564PluginAdapter::Restore(guint32 xid)
539{565{
540566
=== modified file 'plugins/unityshell/src/PluginAdapter.h'
--- plugins/unityshell/src/PluginAdapter.h 2012-04-02 10:45:47 +0000
+++ plugins/unityshell/src/PluginAdapter.h 2012-04-13 22:06:26 +0000
@@ -119,7 +119,9 @@
119 bool IsWindowObscured(guint xid);119 bool IsWindowObscured(guint xid);
120 bool IsWindowMapped(guint xid);120 bool IsWindowMapped(guint xid);
121 bool IsWindowVisible(guint32 xid);121 bool IsWindowVisible(guint32 xid);
122 bool IsWindowClosable(guint32 xid);
122 bool IsWindowMinimizable(guint32 xid);123 bool IsWindowMinimizable(guint32 xid);
124 bool IsWindowMaximizable(guint32 xid);
123125
124 void Restore(guint32 xid);126 void Restore(guint32 xid);
125 void RestoreAt(guint32 xid, int x, int y);127 void RestoreAt(guint32 xid, int x, int y);
126128
=== modified file 'plugins/unityshell/src/WindowButtons.cpp'
--- plugins/unityshell/src/WindowButtons.cpp 2012-04-04 20:13:10 +0000
+++ plugins/unityshell/src/WindowButtons.cpp 2012-04-13 22:06:26 +0000
@@ -725,11 +725,16 @@
725 {725 {
726 auto button = dynamic_cast<WindowButton*>(area);726 auto button = dynamic_cast<WindowButton*>(area);
727727
728 if (button->GetType() == panel::WindowButtonType::CLOSE)
729 {
730 bool closable = WindowManager::Default()->IsWindowClosable(xid);
731 button->SetEnabled(closable);
732 }
733
728 if (button->GetType() == panel::WindowButtonType::MINIMIZE)734 if (button->GetType() == panel::WindowButtonType::MINIMIZE)
729 {735 {
730 bool minimizable = WindowManager::Default()->IsWindowMinimizable(xid);736 bool minimizable = WindowManager::Default()->IsWindowMinimizable(xid);
731 button->SetEnabled(minimizable);737 button->SetEnabled(minimizable);
732 break;
733 }738 }
734 }739 }
735 }740 }
736741
=== modified file 'plugins/unityshell/src/WindowManager.cpp'
--- plugins/unityshell/src/WindowManager.cpp 2012-04-02 10:45:47 +0000
+++ plugins/unityshell/src/WindowManager.cpp 2012-04-13 22:06:26 +0000
@@ -73,11 +73,21 @@
73 return true;73 return true;
74 }74 }
7575
76 bool IsWindowClosable(guint32 xid)
77 {
78 return true;
79 }
80
76 bool IsWindowMinimizable(guint32 xid)81 bool IsWindowMinimizable(guint32 xid)
77 {82 {
78 return true;83 return true;
79 }84 }
8085
86 bool IsWindowMaximizable(guint32 xid)
87 {
88 return true;
89 }
90
81 void Restore(guint32 xid)91 void Restore(guint32 xid)
82 {92 {
83 g_debug("%s", G_STRFUNC);93 g_debug("%s", G_STRFUNC);
8494
=== modified file 'plugins/unityshell/src/WindowManager.h'
--- plugins/unityshell/src/WindowManager.h 2012-04-02 10:45:47 +0000
+++ plugins/unityshell/src/WindowManager.h 2012-04-13 22:06:26 +0000
@@ -61,7 +61,9 @@
61 virtual bool IsWindowObscured(guint32 xid) = 0;61 virtual bool IsWindowObscured(guint32 xid) = 0;
62 virtual bool IsWindowMapped(guint32 xid) = 0;62 virtual bool IsWindowMapped(guint32 xid) = 0;
63 virtual bool IsWindowVisible(guint32 xid) = 0;63 virtual bool IsWindowVisible(guint32 xid) = 0;
64 virtual bool IsWindowClosable(guint32 xid) = 0;
64 virtual bool IsWindowMinimizable(guint32 xid) = 0;65 virtual bool IsWindowMinimizable(guint32 xid) = 0;
66 virtual bool IsWindowMaximizable(guint32 xid) = 0;
6567
66 virtual void ShowDesktop() = 0;68 virtual void ShowDesktop() = 0;
6769