Merge lp:~3v1n0/unity/maximized-deco-dragging-fix into lp:unity

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Brandon Schaefer
Approved revision: no longer in the source branch.
Merged at revision: 3685
Proposed branch: lp:~3v1n0/unity/maximized-deco-dragging-fix
Merge into: lp:unity
Prerequisite: lp:~brandontschaefer/unity/decor-dynamic-hi-dpi
Diff against target: 140 lines (+51/-17)
3 files modified
unity-shared/PluginAdapter.cpp (+43/-11)
unity-shared/UScreen.cpp (+3/-1)
unity-shared/UnitySettings.cpp (+5/-5)
To merge this branch: bzr merge lp:~3v1n0/unity/maximized-deco-dragging-fix
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Brandon Schaefer (community) Approve
Review via email: mp+207341@code.launchpad.net

This proposal supersedes a proposal from 2014-02-20.

Commit message

PluginAdapter: take in account the window border size when restoring it from maximization state

Also don't forget about monitor scaling when getting data from the decoration Style.

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

LGTM

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'unity-shared/PluginAdapter.cpp'
2--- unity-shared/PluginAdapter.cpp 2014-02-20 02:24:37 +0000
3+++ unity-shared/PluginAdapter.cpp 2014-02-20 02:24:37 +0000
4@@ -20,6 +20,7 @@
5 #include <glib.h>
6 #include <gdk/gdkx.h>
7 #include "UScreen.h"
8+#include "UnitySettings.h"
9 #include "DecorationStyle.h"
10 #include "PluginAdapter.h"
11 #include "CompizUtils.h"
12@@ -699,8 +700,20 @@
13 if (window && (window->state() & MAXIMIZE_STATE))
14 {
15 nux::Geometry new_geo(GetWindowSavedGeometry(window_id));
16+ decoration::Border border;
17+ double scale = 1.0f;
18+
19+ if (compiz_utils::IsWindowFullyDecorable(window))
20+ {
21+ auto& settings = Settings::Instance();
22+ border = decoration::Style::Get()->Border();
23+ scale = settings.em(MonitorGeometryIn(new_geo))->DPIScale();
24+ }
25+
26 new_geo.x = x;
27 new_geo.y = y;
28+ new_geo.width -= (border.left - border.right) * scale;
29+ new_geo.height -= (border.top - border.bottom) * scale;
30 window->maximize(0);
31 MoveResizeWindow(window_id, new_geo);
32 }
33@@ -1011,6 +1024,24 @@
34 return nux::Geometry(0, 0, m_Screen->width(), m_Screen->height());
35 }
36
37+template<typename T>
38+nux::Size get_edge_size(WindowManager::Edge edge, CompRect const& win_rect, T const& extents)
39+{
40+ switch (edge)
41+ {
42+ case WindowManager::Edge::LEFT:
43+ return nux::Size(extents.left, win_rect.height());
44+ case WindowManager::Edge::TOP:
45+ return nux::Size(win_rect.width(), extents.top);
46+ case WindowManager::Edge::RIGHT:
47+ return nux::Size(extents.right, win_rect.height());
48+ case WindowManager::Edge::BOTTOM:
49+ return nux::Size(win_rect.width(), extents.bottom);
50+ }
51+
52+ return nux::Size();
53+}
54+
55 nux::Size PluginAdapter::GetWindowDecorationSize(Window window_id, WindowManager::Edge edge) const
56 {
57 if (CompWindow* window = m_Screen->findWindow(window_id))
58@@ -1018,18 +1049,19 @@
59 if (compiz_utils::IsWindowFullyDecorable(window))
60 {
61 auto const& win_rect = window->borderRect();
62- auto const& extents = decoration::Style::Get()->Border();
63
64- switch (edge)
65- {
66- case Edge::LEFT:
67- return nux::Size(extents.left, win_rect.height());
68- case Edge::TOP:
69- return nux::Size(win_rect.width(), extents.top);
70- case Edge::RIGHT:
71- return nux::Size(extents.right, win_rect.height());
72- case Edge::BOTTOM:
73- return nux::Size(win_rect.width(), extents.bottom);
74+ if ((window->state() & MAXIMIZE_STATE) == MAXIMIZE_STATE)
75+ {
76+ auto const& extents = decoration::Style::Get()->Border();
77+ nux::Geometry win_geo(win_rect.x(), win_rect.y(), win_rect.width(), win_rect.height());
78+ auto deco_size = get_edge_size(edge, win_rect, extents);
79+ double scale = Settings::Instance().em(MonitorGeometryIn(win_geo))->DPIScale();
80+ return nux::Size(deco_size.width * scale, deco_size.height * scale);
81+ }
82+ else
83+ {
84+ auto const& extents = window->border();
85+ return get_edge_size(edge, win_rect, extents);
86 }
87 }
88 }
89
90=== modified file 'unity-shared/UScreen.cpp'
91--- unity-shared/UScreen.cpp 2014-02-07 16:31:54 +0000
92+++ unity-shared/UScreen.cpp 2014-02-20 02:24:37 +0000
93@@ -133,7 +133,9 @@
94 {
95 GdkRectangle rect = { 0 };
96 gdk_screen_get_monitor_geometry(screen_, i, &rect);
97- nux::Geometry geo(rect.x, rect.y, rect.width, rect.height);
98+
99+ float scale = gdk_screen_get_monitor_scale_factor(screen_, i);
100+ nux::Geometry geo(rect.x*scale, rect.y*scale, rect.width*scale, rect.height*scale);
101
102 // Check for mirrored displays
103 if (geo == last_geo)
104
105=== modified file 'unity-shared/UnitySettings.cpp'
106--- unity-shared/UnitySettings.cpp 2014-02-20 02:24:37 +0000
107+++ unity-shared/UnitySettings.cpp 2014-02-20 02:24:37 +0000
108@@ -40,9 +40,9 @@
109 const std::string FORM_FACTOR = "form-factor";
110 const std::string DOUBLE_CLICK_ACTIVATE = "double-click-activate";
111
112-// FIXME Remove me when hikikos settings changes land in unity
113+// FIXME Remove this (and UScreen changes) when hikikos settings changes land in unity
114 const std::string GNOME_SETTINGS = "org.gnome.desktop.interface";
115-const std::string TEXT_SCALING_FACTOR = "text-scaling-factor";
116+const std::string SCALING_FACTOR = "scaling-factor";
117 }
118
119 //
120@@ -74,7 +74,7 @@
121 parent_->double_click_activate.changed.emit(cached_double_click_activate_);
122 });
123
124- signals_.Add<void, GSettings*, const gchar*>(gnome_settings_, "changed::" + TEXT_SCALING_FACTOR, [this] (GSettings*, const gchar* t) {
125+ signals_.Add<void, GSettings*, const gchar*>(gnome_settings_, "changed::" + SCALING_FACTOR, [this] (GSettings*, const gchar* t) {
126 UpdateEMConverter();
127 });
128
129@@ -136,9 +136,9 @@
130 int GetDPI(int monitor = 0) const
131 {
132 int dpi = 96;
133- float scale = g_settings_get_double(gnome_settings_, TEXT_SCALING_FACTOR.c_str());
134+ int scale = g_settings_get_uint(gnome_settings_, SCALING_FACTOR.c_str());
135
136- return dpi * scale;
137+ return dpi * (scale > 0 ? scale : 1);
138 }
139
140 void UpdateFontSize()