Status: | Superseded | ||||
---|---|---|---|---|---|
Proposed branch: | lp:~tintou/gala/hidpi | ||||
Merge into: | lp:gala | ||||
Diff against target: |
1163 lines (+626/-74) 13 files modified
data/Makefile.am (+2/-2) data/close.svg (+175/-0) lib/Utils.vala (+8/-6) lib/WindowManager.vala (+5/-0) plugins/notify/ConfirmationNotification.vala (+17/-8) plugins/notify/Main.vala (+3/-3) plugins/notify/Makefile.am (+1/-1) plugins/notify/NormalNotification.vala (+33/-14) plugins/notify/Notification.vala (+52/-25) plugins/notify/NotificationStack.vala (+8/-7) plugins/notify/NotifyServer.vala (+18/-8) plugins/notify/data/image-mask.svg (+235/-0) src/WindowManager.vala (+69/-0) |
||||
To merge this branch: | bzr merge lp:~tintou/gala/hidpi | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Gala developers | Pending | ||
Review via email: mp+313508@code.launchpad.net |
Commit message
Description of the change
Enable HiDPI on the notifications
To post a comment you must log in.
lp:~tintou/gala/hidpi
updated
- 549. By Corentin Noël
-
[HiDPI] Notifications are now working
Revision history for this message
Rico Tzschichholz (ricotz) wrote : | # |
Unmerged revisions
- 549. By Corentin Noël
-
[HiDPI] Notifications are now working
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'data/Makefile.am' |
2 | --- data/Makefile.am 2016-07-14 20:04:44 +0000 |
3 | +++ data/Makefile.am 2016-12-18 21:20:25 +0000 |
4 | @@ -3,7 +3,7 @@ |
5 | $(NULL) |
6 | |
7 | stylesdir = $(pkgdatadir) |
8 | -styles_DATA = gala.css texture.png close.png |
9 | +styles_DATA = gala.css texture.png close.svg |
10 | |
11 | applicationsdir = $(datadir)/applications |
12 | applications_DATA = gala.desktop gala-wayland.desktop gala-other.desktop gala-multitaskingview.desktop |
13 | @@ -28,7 +28,7 @@ |
14 | gala-other.desktop.in \ |
15 | gala-multitaskingview.desktop.in \ |
16 | texture.png \ |
17 | - close.png \ |
18 | + close.svg \ |
19 | org.pantheon.desktop.gala.gschema.xml.in.in \ |
20 | $(NULL) |
21 | |
22 | |
23 | === removed file 'data/close.png' |
24 | Binary files data/close.png 2014-07-17 00:55:13 +0000 and data/close.png 1970-01-01 00:00:00 +0000 differ |
25 | === added file 'data/close.svg' |
26 | --- data/close.svg 1970-01-01 00:00:00 +0000 |
27 | +++ data/close.svg 2016-12-18 21:20:25 +0000 |
28 | @@ -0,0 +1,175 @@ |
29 | +<?xml version="1.0" encoding="UTF-8" standalone="no"?> |
30 | +<svg |
31 | + xmlns:osb="http://www.openswatchbook.org/uri/2009/osb" |
32 | + xmlns:dc="http://purl.org/dc/elements/1.1/" |
33 | + xmlns:cc="http://creativecommons.org/ns#" |
34 | + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" |
35 | + xmlns:svg="http://www.w3.org/2000/svg" |
36 | + xmlns="http://www.w3.org/2000/svg" |
37 | + xmlns:xlink="http://www.w3.org/1999/xlink" |
38 | + version="1.1" |
39 | + id="svg2" |
40 | + height="36" |
41 | + width="36"> |
42 | + <defs |
43 | + id="defs4"> |
44 | + <linearGradient |
45 | + id="linearGradient5827"> |
46 | + <stop |
47 | + id="stop5829" |
48 | + offset="0" |
49 | + style="stop-color:#000000;stop-opacity:1;" /> |
50 | + <stop |
51 | + style="stop-color:#000000;stop-opacity:0.49411765;" |
52 | + offset="0.80939096" |
53 | + id="stop5835" /> |
54 | + <stop |
55 | + id="stop5831" |
56 | + offset="1" |
57 | + style="stop-color:#000000;stop-opacity:0;" /> |
58 | + </linearGradient> |
59 | + <linearGradient |
60 | + id="linearGradient5714"> |
61 | + <stop |
62 | + id="stop5716" |
63 | + offset="0" |
64 | + style="stop-color:#000000;stop-opacity:0.79912664" /> |
65 | + <stop |
66 | + id="stop5718" |
67 | + offset="1" |
68 | + style="stop-color:#000000;stop-opacity:1" /> |
69 | + </linearGradient> |
70 | + <linearGradient |
71 | + osb:paint="solid" |
72 | + id="linearGradient8590"> |
73 | + <stop |
74 | + id="stop8592" |
75 | + offset="0" |
76 | + style="stop-color:#000000;stop-opacity:1;" /> |
77 | + </linearGradient> |
78 | + <linearGradient |
79 | + id="linearGradient4011-28"> |
80 | + <stop |
81 | + id="stop4013-26" |
82 | + style="stop-color:#ffffff;stop-opacity:1;" |
83 | + offset="0" /> |
84 | + <stop |
85 | + offset="0.507761" |
86 | + style="stop-color:#ffffff;stop-opacity:0.23529412;" |
87 | + id="stop4015-7" /> |
88 | + <stop |
89 | + id="stop4017-0" |
90 | + style="stop-color:#ffffff;stop-opacity:0.15686275;" |
91 | + offset="0.83456558" /> |
92 | + <stop |
93 | + id="stop4019-9" |
94 | + style="stop-color:#ffffff;stop-opacity:0.39215687;" |
95 | + offset="1" /> |
96 | + </linearGradient> |
97 | + <linearGradient |
98 | + id="linearGradient7232-8-8-68-3"> |
99 | + <stop |
100 | + id="stop7234-8-8-5-3" |
101 | + style="stop-color:#7e7e7e;stop-opacity:1;" |
102 | + offset="0" /> |
103 | + <stop |
104 | + id="stop7236-3-00-8-3" |
105 | + style="stop-color:#3e3e3e;stop-opacity:1;" |
106 | + offset="1" /> |
107 | + </linearGradient> |
108 | + <linearGradient |
109 | + y2="607.51257" |
110 | + x2="721.04901" |
111 | + y1="583.98163" |
112 | + x1="721.04901" |
113 | + gradientTransform="matrix(0.47559079,0,0,1.454704,-230.86429,-383.79963)" |
114 | + gradientUnits="userSpaceOnUse" |
115 | + id="linearGradient5190" |
116 | + xlink:href="#linearGradient7232-8-8-68-3" /> |
117 | + <linearGradient |
118 | + x1="71.204407" |
119 | + y1="6.2375584" |
120 | + x2="71.204407" |
121 | + y2="44.340794" |
122 | + id="linearGradient3089-9" |
123 | + xlink:href="#linearGradient4011-28" |
124 | + gradientUnits="userSpaceOnUse" |
125 | + gradientTransform="matrix(0.78378373,0,0,0.78378373,52.776438,464.50041)" /> |
126 | + <linearGradient |
127 | + gradientUnits="userSpaceOnUse" |
128 | + y2="500.487" |
129 | + x2="109.62553" |
130 | + y1="468.96909" |
131 | + x1="109.62553" |
132 | + id="linearGradient5720" |
133 | + xlink:href="#linearGradient5714" /> |
134 | + <radialGradient |
135 | + gradientUnits="userSpaceOnUse" |
136 | + r="18" |
137 | + fy="485.375" |
138 | + fx="109" |
139 | + cy="485.375" |
140 | + cx="109" |
141 | + id="radialGradient5833" |
142 | + xlink:href="#linearGradient5827" /> |
143 | + <radialGradient |
144 | + gradientTransform="matrix(0.94444444,0,0,0.94444444,6.0555566,25.965278)" |
145 | + gradientUnits="userSpaceOnUse" |
146 | + r="18" |
147 | + fy="485.375" |
148 | + fx="109" |
149 | + cy="485.375" |
150 | + cx="109" |
151 | + id="radialGradient5833-9" |
152 | + xlink:href="#linearGradient5827" /> |
153 | + </defs> |
154 | + <metadata |
155 | + id="metadata7"> |
156 | + <rdf:RDF> |
157 | + <cc:Work |
158 | + rdf:about=""> |
159 | + <dc:format>image/svg+xml</dc:format> |
160 | + <dc:type |
161 | + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> |
162 | + <dc:title></dc:title> |
163 | + </cc:Work> |
164 | + </rdf:RDF> |
165 | + </metadata> |
166 | + <g |
167 | + transform="translate(-91,-467.375)" |
168 | + id="layer1"> |
169 | + <path |
170 | + d="m 109.00003,467.375 c -9.93187,0 -18.00003,8.06821 -18.00003,18 0,9.93179 8.06816,18 18.00003,18 9.93176,0 18,-8.06821 17.99997,-18 0,-9.93179 -8.06821,-18 -17.99997,-18 z" |
171 | + id="path2555-7-1-4-4-8-6-5-1-0-2-9-5" |
172 | + style="color:#000000;display:inline;overflow:visible;visibility:visible;fill:url(#radialGradient5833);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.99999982;marker:none;enable-background:accumulate;opacity:0.7" /> |
173 | + <path |
174 | + d="m 109.00003,467.375 c -9.3801,0 -17.000029,7.61998 -17.000029,17 0,9.38002 7.619929,17 17.000029,17 9.37999,0 17,-7.61998 16.99997,-17 0,-9.38002 -7.61998,-17 -16.99997,-17 z" |
175 | + id="path2555-7-1-4-4-8-6-5-1-0-2-9-5-9" |
176 | + style="color:#000000;display:inline;overflow:visible;visibility:visible;opacity:0.7;fill:url(#radialGradient5833-9);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.99999982;marker:none;enable-background:accumulate" /> |
177 | + <path |
178 | + d="m 109.00002,469.375 c -8.27655,0 -15.000019,6.72351 -15.000019,15 0,8.27649 6.723469,15 15.000019,15 8.27647,0 15,-6.72351 14.99998,-15 0,-8.27649 -6.72351,-15 -14.99998,-15 z" |
179 | + id="path2555-7-1-4-4-8-6-5-1-0-2-9" |
180 | + style="color:#000000;display:inline;overflow:visible;visibility:visible;fill:url(#linearGradient5190);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.99999982;marker:none;enable-background:accumulate" /> |
181 | + <path |
182 | + d="m 124.5,484.375 c 0,-8.56039 -6.9396,-15.5 -15.50007,-15.5 -8.5604,0 -15.499928,6.93961 -15.499928,15.5 0,8.56038 6.939528,15.5 15.499928,15.5 8.56047,0 15.50007,-6.93962 15.50007,-15.5 z" |
183 | + id="path3019-2-0-4-7-1-46-65-2-0" |
184 | + style="color:#000000;display:inline;overflow:visible;visibility:visible;opacity:0.6;fill:none;stroke:url(#linearGradient5720);stroke-width:0.99999988;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;enable-background:accumulate" /> |
185 | + <path |
186 | + style="color:#000000;display:inline;overflow:visible;visibility:visible;opacity:0.2;fill:none;stroke:url(#linearGradient3089-9);stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;enable-background:accumulate" |
187 | + id="path8655-2" |
188 | + d="m 123.5,484.37448 c 0,8.0084 -6.49236,14.50052 -14.49983,14.50052 -8.00819,0 -14.50017,-6.4922 -14.50017,-14.50052 0,-8.00801 6.49198,-14.49948 14.50017,-14.49948 8.00747,0 14.49983,6.49147 14.49983,14.49948 l 0,0 z" /> |
189 | + <path |
190 | + d="m 104.58008,478.375 c -0.66357,0 -1.33178,0.26145 -1.83203,0.76172 -1.00181,1.00181 -1.0018,2.66225 0,3.66406 l 2.58789,2.58594 -2.58789,2.58789 c -1.00181,1.00181 -1.00181,2.66225 0,3.66406 1.00181,1.00181 2.66226,1.00183 3.66406,0 L 109,489.05078 l 2.58789,2.58789 c 1.0018,1.00184 2.66226,1.00183 3.66406,0 1.00183,-1.00181 1.00183,-2.66225 0,-3.66406 l -2.58789,-2.58789 2.58789,-2.58594 c 1.00181,-1.00181 1.00182,-2.66226 0,-3.66406 -1.0018,-1.00182 -2.66226,-1.00182 -3.66406,0 L 109,481.72461 l -2.58789,-2.58789 c -0.50025,-0.50026 -1.16846,-0.76172 -1.83203,-0.76172 z" |
191 | + id="path5787" |
192 | + style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:0.05;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate;filter-blend-mode:normal;filter-gaussianBlur-deviation:0" /> |
193 | + <path |
194 | + id="rect5962-1" |
195 | + d="m 104.58008,479.4669 c -0.38343,0 -0.76675,0.1476 -1.06055,0.44141 -0.5876,0.5876 -0.5876,1.53348 0,2.12109 l 3.35938,3.35742 -3.35938,3.35938 c -0.5876,0.5876 -0.5876,1.53349 0,2.12109 0.58761,0.58761 1.53349,0.58761 2.12109,0 L 109,487.50792 l 3.35938,3.35937 c 0.5876,0.58761 1.53349,0.58761 2.12109,0 0.58761,-0.5876 0.58761,-1.53349 0,-2.12109 l -3.35938,-3.35938 3.35938,-3.35742 c 0.58761,-0.58761 0.58761,-1.53349 0,-2.12109 -0.5876,-0.58761 -1.53349,-0.58761 -2.12109,0 L 109,483.26768 l -3.35938,-3.35937 c -0.2938,-0.29381 -0.67711,-0.44141 -1.06054,-0.44141 z" |
196 | + style="color:#000000;display:inline;overflow:visible;visibility:visible;opacity:0.15;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;enable-background:accumulate;clip-rule:nonzero;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;filter-blend-mode:normal;filter-gaussianBlur-deviation:0;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto" /> |
197 | + <path |
198 | + transform="translate(91,467.375)" |
199 | + id="rect5962" |
200 | + d="M 13.580078 11.091797 C 13.196649 11.091797 12.813334 11.2394 12.519531 11.533203 C 11.931926 12.120809 11.931926 13.066691 12.519531 13.654297 L 15.878906 17.011719 L 12.519531 20.371094 C 11.931926 20.958699 11.931926 21.904582 12.519531 22.492188 C 13.107137 23.079793 14.053019 23.079793 14.640625 22.492188 L 18 19.132812 L 21.359375 22.492188 C 21.946981 23.079793 22.892863 23.079793 23.480469 22.492188 C 24.068074 21.904582 24.068074 20.958699 23.480469 20.371094 L 20.121094 17.011719 L 23.480469 13.654297 C 24.068074 13.066691 24.068074 12.120809 23.480469 11.533203 C 22.892863 10.945597 21.946981 10.945597 21.359375 11.533203 L 18 14.892578 L 14.640625 11.533203 C 14.346822 11.2394 13.963507 11.091797 13.580078 11.091797 z " |
201 | + style="color:#000000;display:inline;overflow:visible;visibility:visible;opacity:1;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:2;marker:none;enable-background:accumulate" /> |
202 | + </g> |
203 | +</svg> |
204 | |
205 | === modified file 'lib/Utils.vala' |
206 | --- lib/Utils.vala 2016-11-15 16:13:39 +0000 |
207 | +++ lib/Utils.vala 2016-12-18 21:20:25 +0000 |
208 | @@ -25,6 +25,7 @@ |
209 | static uint cache_clear_timeout = 0; |
210 | |
211 | static Gdk.Pixbuf? close_pixbuf = null; |
212 | + static int close_pixbuf_scale = 0; |
213 | |
214 | static construct |
215 | { |
216 | @@ -290,11 +291,12 @@ |
217 | * |
218 | * @return the close button pixbuf or null if it failed to load |
219 | */ |
220 | - public static Gdk.Pixbuf? get_close_button_pixbuf () |
221 | + public static Gdk.Pixbuf? get_close_button_pixbuf (int scale_factor) |
222 | { |
223 | - if (close_pixbuf == null) { |
224 | + if (close_pixbuf == null || close_pixbuf_scale != scale_factor) { |
225 | try { |
226 | - close_pixbuf = new Gdk.Pixbuf.from_file (Config.PKGDATADIR + "/close.png"); |
227 | + close_pixbuf = new Gdk.Pixbuf.from_file_at_scale (Config.PKGDATADIR + "/close.svg", -1, 36 * scale_factor, true); |
228 | + close_pixbuf_scale = scale_factor; |
229 | } catch (Error e) { |
230 | warning (e.message); |
231 | return null; |
232 | @@ -309,10 +311,10 @@ |
233 | * |
234 | * @return The close button actor |
235 | */ |
236 | - public static Clutter.Actor create_close_button () |
237 | + public static Clutter.Actor create_close_button (int scale_factor = 1) |
238 | { |
239 | var texture = new Clutter.Texture (); |
240 | - var pixbuf = get_close_button_pixbuf (); |
241 | + var pixbuf = get_close_button_pixbuf (scale_factor); |
242 | |
243 | texture.reactive = true; |
244 | |
245 | @@ -326,7 +328,7 @@ |
246 | // we'll just make this red so there's at least something as an |
247 | // indicator that loading failed. Should never happen and this |
248 | // works as good as some weird fallback-image-failed-to-load pixbuf |
249 | - texture.set_size (36, 36); |
250 | + texture.set_size (36 * scale_factor, 36 * scale_factor); |
251 | texture.background_color = { 255, 0, 0, 255 }; |
252 | } |
253 | |
254 | |
255 | === modified file 'lib/WindowManager.vala' |
256 | --- lib/WindowManager.vala 2015-03-04 11:07:30 +0000 |
257 | +++ lib/WindowManager.vala 2016-12-18 21:20:25 +0000 |
258 | @@ -92,6 +92,11 @@ |
259 | public abstract Meta.BackgroundGroup background_group { get; protected set; } |
260 | |
261 | /** |
262 | + * The scale factor is the scale used by all user-facing elements |
263 | + */ |
264 | + public abstract int scale_factor { get; protected set; } |
265 | + |
266 | + /** |
267 | * Enters the modal mode, which means that all events are directed to the stage instead |
268 | * of the windows. This is the only way to receive keyboard events besides shortcut listeners. |
269 | * |
270 | |
271 | === modified file 'plugins/notify/ConfirmationNotification.vala' |
272 | --- plugins/notify/ConfirmationNotification.vala 2014-07-21 01:21:19 +0000 |
273 | +++ plugins/notify/ConfirmationNotification.vala 2016-12-18 21:20:25 +0000 |
274 | @@ -55,7 +55,7 @@ |
275 | |
276 | public override void update_allocation (out float content_height, AllocationFlags flags) |
277 | { |
278 | - content_height = ICON_SIZE; |
279 | + content_height = ICON_SIZE * style_context.get_scale (); |
280 | } |
281 | |
282 | public override void draw_content (Cairo.Context cr) |
283 | @@ -63,14 +63,21 @@ |
284 | if (!has_progress) |
285 | return; |
286 | |
287 | - var x = MARGIN + PADDING + ICON_SIZE + SPACING; |
288 | - var y = MARGIN + PADDING + (ICON_SIZE - PROGRESS_HEIGHT) / 2; |
289 | - var width = WIDTH - x - MARGIN; |
290 | + var scale = style_context.get_scale (); |
291 | + var scaled_width = WIDTH * scale; |
292 | + var scaled_margin = MARGIN * scale; |
293 | + var scaled_padding = PADDING * scale; |
294 | + var scaled_icon_size = ICON_SIZE * scale; |
295 | + var scaled_spacing = SPACING * scale; |
296 | + var scaled_progress_height = PROGRESS_HEIGHT * scale; |
297 | + var x = scaled_margin + scaled_padding + scaled_icon_size + scaled_spacing; |
298 | + var y = scaled_margin + scaled_padding + (scaled_icon_size - scaled_progress_height) / 2; |
299 | + var width = scaled_width - x - scaled_margin; |
300 | |
301 | if (!transitioning) |
302 | draw_progress_bar (cr, x, y, width, progress); |
303 | else { |
304 | - Granite.Drawing.Utilities.cairo_rounded_rectangle (cr, MARGIN, MARGIN, WIDTH - MARGIN * 2, ICON_SIZE + PADDING * 2, 4); |
305 | + Granite.Drawing.Utilities.cairo_rounded_rectangle (cr, scaled_margin, scaled_margin, scaled_width - scaled_margin * 2, scaled_icon_size + scaled_padding * 2, 4); |
306 | cr.clip (); |
307 | |
308 | draw_progress_bar (cr, x, y + animation_slide_y_offset, width, old_progress); |
309 | @@ -82,16 +89,18 @@ |
310 | |
311 | void draw_progress_bar (Cairo.Context cr, int x, float y, int width, int progress) |
312 | { |
313 | + var scale = style_context.get_scale (); |
314 | var fraction = (int) Math.floor (progress.clamp (0, 100) / 100.0 * width); |
315 | |
316 | + var scaled_height = PROGRESS_HEIGHT * scale; |
317 | Granite.Drawing.Utilities.cairo_rounded_rectangle (cr, x, y, width, |
318 | - PROGRESS_HEIGHT, PROGRESS_HEIGHT / 2); |
319 | + scaled_height, scaled_height / 2); |
320 | cr.set_source_rgb (0.8, 0.8, 0.8); |
321 | cr.fill (); |
322 | |
323 | if (progress > 0) { |
324 | Granite.Drawing.Utilities.cairo_rounded_rectangle (cr, x, y, fraction, |
325 | - PROGRESS_HEIGHT, PROGRESS_HEIGHT / 2); |
326 | + scaled_height, scaled_height / 2); |
327 | cr.set_source_rgb (0.3, 0.3, 0.3); |
328 | cr.fill (); |
329 | } |
330 | @@ -111,7 +120,7 @@ |
331 | |
332 | old_progress = this.progress; |
333 | |
334 | - play_update_transition (ICON_SIZE + PADDING * 2); |
335 | + play_update_transition ((ICON_SIZE + PADDING * 2) * style_context.get_scale ()); |
336 | } |
337 | |
338 | if (this.icon_only != icon_only) { |
339 | |
340 | === modified file 'plugins/notify/Main.vala' |
341 | --- plugins/notify/Main.vala 2014-07-18 11:12:31 +0000 |
342 | +++ plugins/notify/Main.vala 2016-12-18 21:20:25 +0000 |
343 | @@ -30,9 +30,8 @@ |
344 | public override void initialize (Gala.WindowManager wm) |
345 | { |
346 | this.wm = wm; |
347 | - var screen = wm.get_screen (); |
348 | |
349 | - stack = new NotificationStack (wm.get_screen ()); |
350 | + stack = new NotificationStack (wm); |
351 | wm.ui_group.add_child (stack); |
352 | track_actor (stack); |
353 | |
354 | @@ -43,6 +42,7 @@ |
355 | server = new NotifyServer (stack); |
356 | |
357 | update_position (); |
358 | + unowned Meta.Screen screen = wm.get_screen (); |
359 | screen.monitors_changed.connect (update_position); |
360 | screen.workareas_changed.connect (update_position); |
361 | |
362 | @@ -64,7 +64,7 @@ |
363 | |
364 | void update_position () |
365 | { |
366 | - var screen = wm.get_screen (); |
367 | + unowned Meta.Screen screen = wm.get_screen (); |
368 | var primary = screen.get_primary_monitor (); |
369 | var area = screen.get_active_workspace ().get_work_area_for_monitor (primary); |
370 | |
371 | |
372 | === modified file 'plugins/notify/Makefile.am' |
373 | --- plugins/notify/Makefile.am 2015-03-04 10:56:41 +0000 |
374 | +++ plugins/notify/Makefile.am 2016-12-18 21:20:25 +0000 |
375 | @@ -3,7 +3,7 @@ |
376 | VAPIDIR = $(top_srcdir)/vapi |
377 | |
378 | imagedir = $(pkgdatadir) |
379 | -dist_image_DATA = data/image-mask.png |
380 | +dist_image_DATA = data/image-mask.svg |
381 | |
382 | BUILT_SOURCES = libgala_notify_la_vala.stamp |
383 | |
384 | |
385 | === modified file 'plugins/notify/NormalNotification.vala' |
386 | --- plugins/notify/NormalNotification.vala 2016-08-04 07:37:29 +0000 |
387 | +++ plugins/notify/NormalNotification.vala 2016-12-18 21:20:25 +0000 |
388 | @@ -38,6 +38,8 @@ |
389 | } catch (Error e) {} |
390 | } |
391 | |
392 | + public unowned Gtk.StyleContext parent_style_context { get; construct; } |
393 | + |
394 | const int LABEL_SPACING = 2; |
395 | |
396 | Text summary_label; |
397 | @@ -64,6 +66,7 @@ |
398 | var label_style_context = new Gtk.StyleContext (); |
399 | label_style_context.add_provider (Notification.default_css, Gtk.STYLE_PROVIDER_PRIORITY_FALLBACK); |
400 | label_style_context.set_path (style_path); |
401 | + label_style_context.set_parent (parent_style_context); |
402 | |
403 | Gdk.RGBA color; |
404 | |
405 | @@ -93,6 +96,11 @@ |
406 | add_child (body_label); |
407 | } |
408 | |
409 | + public NormalNotificationContent (Gtk.StyleContext parent_style_context) |
410 | + { |
411 | + Object (parent_style_context: parent_style_context); |
412 | + } |
413 | + |
414 | public void set_values (string summary, string body) |
415 | { |
416 | summary_label.set_markup ("<b>%s</b>".printf (fix_markup (summary))); |
417 | @@ -119,7 +127,7 @@ |
418 | summary_label.allocate (summary_alloc, flags); |
419 | |
420 | var body_alloc = ActorBox (); |
421 | - body_alloc.set_origin (label_x, label_y + summary_height + LABEL_SPACING); |
422 | + body_alloc.set_origin (label_x, label_y + summary_height + LABEL_SPACING * parent_style_context.get_scale ()); |
423 | body_alloc.set_size (label_width, body_height); |
424 | body_label.allocate (body_alloc, flags); |
425 | |
426 | @@ -129,16 +137,22 @@ |
427 | void get_allocation_values (out float label_x, out float label_width, out float summary_height, |
428 | out float body_height, out float label_height, out float label_y) |
429 | { |
430 | - var height = Notification.ICON_SIZE; |
431 | + var scale = parent_style_context.get_scale (); |
432 | + var height = Notification.ICON_SIZE * scale; |
433 | + var width = scale * Notification.WIDTH; |
434 | + var margin = scale * Notification.MARGIN; |
435 | + var padding = scale * Notification.PADDING; |
436 | + var spacing = scale * Notification.SPACING; |
437 | + var label_spacing = scale * LABEL_SPACING; |
438 | |
439 | - label_x = Notification.MARGIN + Notification.PADDING + height + Notification.SPACING; |
440 | - label_width = Notification.WIDTH - label_x - Notification.MARGIN - Notification.SPACING; |
441 | + label_x = margin + padding + height + spacing; |
442 | + label_width = width - label_x - margin - spacing; |
443 | |
444 | summary_label.get_preferred_height (label_width, null, out summary_height); |
445 | body_label.get_preferred_height (label_width, null, out body_height); |
446 | |
447 | - label_height = summary_height + LABEL_SPACING + body_height; |
448 | - label_y = Notification.MARGIN + Notification.PADDING; |
449 | + label_height = summary_height + label_spacing + body_height; |
450 | + label_y = margin + padding; |
451 | // center |
452 | if (label_height < height) { |
453 | label_y += (height - (int) label_height) / 2; |
454 | @@ -168,13 +182,13 @@ |
455 | public string body { get; construct set; } |
456 | public uint32 sender_pid { get; construct; } |
457 | public string[] notification_actions { get; construct set; } |
458 | - public Screen screen { get; construct; } |
459 | + public unowned Gala.WindowManager wm { get; construct; } |
460 | |
461 | Actor content_container; |
462 | NormalNotificationContent notification_content; |
463 | NormalNotificationContent? old_notification_content = null; |
464 | |
465 | - public NormalNotification (Screen screen, uint32 id, string summary, string body, Gdk.Pixbuf? icon, |
466 | + public NormalNotification (Gala.WindowManager wm, uint32 id, string summary, string body, Gdk.Pixbuf? icon, |
467 | NotificationUrgency urgency, int32 expire_timeout, uint32 pid, string[] actions) |
468 | { |
469 | Object ( |
470 | @@ -182,7 +196,7 @@ |
471 | icon: icon, |
472 | urgency: urgency, |
473 | expire_timeout: expire_timeout, |
474 | - screen: screen, |
475 | + wm: wm, |
476 | summary: summary, |
477 | body: body, |
478 | sender_pid: pid, |
479 | @@ -192,9 +206,10 @@ |
480 | |
481 | construct |
482 | { |
483 | + set_scale_factor (wm.scale_factor); |
484 | content_container = new Actor (); |
485 | |
486 | - notification_content = new NormalNotificationContent (); |
487 | + notification_content = new NormalNotificationContent (style_context); |
488 | notification_content.set_values (summary, body); |
489 | |
490 | content_container.add_child (notification_content); |
491 | @@ -210,7 +225,7 @@ |
492 | if (old_notification_content != null) |
493 | old_notification_content.destroy (); |
494 | |
495 | - old_notification_content = new NormalNotificationContent (); |
496 | + old_notification_content = new NormalNotificationContent (style_context); |
497 | old_notification_content.set_values (this.summary, this.body); |
498 | |
499 | content_container.add_child (old_notification_content); |
500 | @@ -225,7 +240,7 @@ |
501 | |
502 | content_height = float.max (content_height, old_content_height); |
503 | |
504 | - play_update_transition (content_height + PADDING * 2); |
505 | + play_update_transition (content_height + PADDING * 2 * style_context.get_scale ()); |
506 | |
507 | get_transition ("switch").completed.connect (() => { |
508 | if (old_notification_content != null) |
509 | @@ -257,8 +272,10 @@ |
510 | // the for_width is not needed in our implementation of get_preferred_height as we |
511 | // assume a constant width |
512 | notification_content.get_preferred_height (0, null, out content_height); |
513 | + var scale = style_context.get_scale (); |
514 | + var scaled_margin = MARGIN * scale; |
515 | |
516 | - content_container.set_clip (MARGIN, MARGIN, MARGIN * 2 + WIDTH, content_height + PADDING * 2); |
517 | + content_container.set_clip (scaled_margin, scaled_margin, scaled_margin * 2 + WIDTH * scale, content_height + PADDING * 2 * scale); |
518 | } |
519 | |
520 | public override void get_preferred_height (float for_width, out float min_height, out float nat_height) |
521 | @@ -266,7 +283,7 @@ |
522 | float content_height; |
523 | notification_content.get_preferred_height (for_width, null, out content_height); |
524 | |
525 | - min_height = nat_height = content_height + (MARGIN + PADDING) * 2; |
526 | + min_height = nat_height = content_height + ((MARGIN + PADDING) * 2) * style_context.get_scale (); |
527 | } |
528 | |
529 | public override void activate () |
530 | @@ -287,6 +304,7 @@ |
531 | unowned Meta.Window? window = get_window (); |
532 | if (window != null) { |
533 | unowned Meta.Workspace workspace = window.get_workspace (); |
534 | + unowned Meta.Screen screen = wm.get_screen (); |
535 | var time = screen.get_display ().get_current_time (); |
536 | |
537 | if (workspace != screen.get_active_workspace ()) |
538 | @@ -303,6 +321,7 @@ |
539 | if (sender_pid == 0) |
540 | return null; |
541 | |
542 | + unowned Meta.Screen screen = wm.get_screen (); |
543 | foreach (unowned Meta.WindowActor actor in Meta.Compositor.get_window_actors (screen)) { |
544 | if (actor.is_destroyed ()) |
545 | continue; |
546 | |
547 | === modified file 'plugins/notify/Notification.vala' |
548 | --- plugins/notify/Notification.vala 2016-11-15 16:13:39 +0000 |
549 | +++ plugins/notify/Notification.vala 2016-12-18 21:20:25 +0000 |
550 | @@ -53,7 +53,7 @@ |
551 | |
552 | Clutter.Actor close_button; |
553 | |
554 | - Gtk.StyleContext style_context; |
555 | + protected Gtk.StyleContext style_context { get; private set; } |
556 | |
557 | uint remove_timeout = 0; |
558 | |
559 | @@ -99,20 +99,7 @@ |
560 | icon_container = new Actor (); |
561 | icon_container.add_child (icon_texture); |
562 | |
563 | - close_button = Utils.create_close_button (); |
564 | - close_button.opacity = 0; |
565 | - close_button.reactive = true; |
566 | - close_button.set_easing_duration (300); |
567 | - |
568 | - var close_click = new ClickAction (); |
569 | - close_click.clicked.connect (() => { |
570 | - closed (id, NotificationClosedReason.DISMISSED); |
571 | - close (); |
572 | - }); |
573 | - close_button.add_action (close_click); |
574 | - |
575 | add_child (icon_container); |
576 | - add_child (close_button); |
577 | |
578 | if (default_css == null) { |
579 | default_css = new Gtk.CssProvider (); |
580 | @@ -132,6 +119,8 @@ |
581 | style_context.add_class ("gala-notification"); |
582 | style_context.set_path (style_path); |
583 | |
584 | + create_close_button (); |
585 | + |
586 | var label_style_path = style_path.copy (); |
587 | label_style_path.iter_add_class (1, "gala-notification"); |
588 | label_style_path.append_type (typeof (Gtk.Label)); |
589 | @@ -227,6 +216,26 @@ |
590 | destroy (); |
591 | } |
592 | |
593 | + void create_close_button () { |
594 | + if (close_button != null) |
595 | + { |
596 | + close_button.destroy (); |
597 | + } |
598 | + |
599 | + close_button = Utils.create_close_button (style_context.get_scale ()); |
600 | + close_button.opacity = 0; |
601 | + close_button.reactive = true; |
602 | + close_button.set_easing_duration (300); |
603 | + |
604 | + var close_click = new ClickAction (); |
605 | + close_click.clicked.connect (() => { |
606 | + closed (id, NotificationClosedReason.DISMISSED); |
607 | + close (); |
608 | + }); |
609 | + close_button.add_action (close_click); |
610 | + add_child (close_button); |
611 | + } |
612 | + |
613 | protected void update_base (Gdk.Pixbuf? icon, int32 expire_timeout) |
614 | { |
615 | this.icon = icon; |
616 | @@ -273,6 +282,16 @@ |
617 | } |
618 | } |
619 | |
620 | + public void set_scale_factor (int scale_factor) |
621 | + { |
622 | + style_context.set_scale (scale_factor); |
623 | + width = (WIDTH + MARGIN * 2) * scale_factor; |
624 | + create_close_button (); |
625 | + if (content is Canvas) { |
626 | + ((Canvas) content).set_scale_factor (scale_factor); |
627 | + } |
628 | + } |
629 | + |
630 | public override bool enter_event (CrossingEvent event) |
631 | { |
632 | close_button.opacity = 255; |
633 | @@ -304,21 +323,26 @@ |
634 | |
635 | public override void allocate (ActorBox box, AllocationFlags flags) |
636 | { |
637 | + var scale = style_context.get_scale (); |
638 | + var scaled_width = WIDTH * scale; |
639 | + var scaled_icon_size = ICON_SIZE * scale; |
640 | + var scaled_margin = MARGIN * scale; |
641 | + var scaled_padding = PADDING * scale; |
642 | + var margin_padding = scaled_margin + scaled_padding; |
643 | var icon_alloc = ActorBox (); |
644 | |
645 | - icon_alloc.set_origin (icon_only ? (WIDTH - ICON_SIZE) / 2 : MARGIN + PADDING, MARGIN + PADDING); |
646 | - icon_alloc.set_size (ICON_SIZE, ICON_SIZE); |
647 | + icon_alloc.set_origin (icon_only ? (scaled_width - scaled_icon_size) / 2 : margin_padding, margin_padding); |
648 | + icon_alloc.set_size (scaled_icon_size, scaled_icon_size); |
649 | icon_container.allocate (icon_alloc, flags); |
650 | |
651 | var close_alloc = ActorBox (); |
652 | - close_alloc.set_origin (MARGIN + PADDING - close_button.width / 2, |
653 | - MARGIN + PADDING - close_button.height / 2); |
654 | + close_alloc.set_origin (margin_padding - close_button.width / 2, margin_padding - close_button.height / 2); |
655 | close_alloc.set_size (close_button.width, close_button.height); |
656 | close_button.allocate (close_alloc, flags); |
657 | |
658 | float content_height; |
659 | update_allocation (out content_height, flags); |
660 | - box.set_size (MARGIN * 2 + WIDTH, (MARGIN + PADDING) * 2 + content_height); |
661 | + box.set_size (scaled_margin * 2 + scaled_width, margin_padding * 2 + content_height); |
662 | |
663 | base.allocate (box, flags); |
664 | |
665 | @@ -331,7 +355,7 @@ |
666 | |
667 | public override void get_preferred_height (float for_width, out float min_height, out float nat_height) |
668 | { |
669 | - min_height = nat_height = ICON_SIZE + (MARGIN + PADDING) * 2; |
670 | + min_height = nat_height = (ICON_SIZE + (MARGIN + PADDING) * 2) * style_context.get_scale (); |
671 | } |
672 | |
673 | protected void play_update_transition (float slide_height) |
674 | @@ -346,7 +370,8 @@ |
675 | |
676 | old_texture = new Clutter.Texture (); |
677 | icon_container.add_child (old_texture); |
678 | - icon_container.set_clip (0, -PADDING, ICON_SIZE, ICON_SIZE + PADDING * 2); |
679 | + var scale = style_context.get_scale (); |
680 | + icon_container.set_clip (0, -PADDING * scale, ICON_SIZE * scale, (ICON_SIZE + PADDING * 2) * scale); |
681 | |
682 | if (icon != null) { |
683 | try { |
684 | @@ -382,10 +407,12 @@ |
685 | { |
686 | var canvas = (Canvas) content; |
687 | |
688 | - var x = MARGIN; |
689 | - var y = MARGIN; |
690 | - var width = canvas.width - MARGIN * 2; |
691 | - var height = canvas.height - MARGIN * 2; |
692 | + var scale = style_context.get_scale (); |
693 | + var margin_scaled = MARGIN * scale; |
694 | + var x = margin_scaled; |
695 | + var y = margin_scaled; |
696 | + var width = canvas.width - margin_scaled * 2; |
697 | + var height = canvas.height - margin_scaled * 2; |
698 | cr.set_operator (Cairo.Operator.CLEAR); |
699 | cr.paint (); |
700 | cr.set_operator (Cairo.Operator.OVER); |
701 | |
702 | === modified file 'plugins/notify/NotificationStack.vala' |
703 | --- plugins/notify/NotificationStack.vala 2016-07-28 22:19:16 +0000 |
704 | +++ plugins/notify/NotificationStack.vala 2016-12-18 21:20:25 +0000 |
705 | @@ -29,16 +29,16 @@ |
706 | |
707 | public signal void animations_changed (bool running); |
708 | |
709 | - public Screen screen { get; construct; } |
710 | + public unowned Gala.WindowManager wm { get; construct; } |
711 | |
712 | - public NotificationStack (Screen screen) |
713 | + public NotificationStack (Gala.WindowManager wm) |
714 | { |
715 | - Object (screen: screen); |
716 | + Object (wm: wm); |
717 | } |
718 | |
719 | construct |
720 | { |
721 | - width = Notification.WIDTH + 2 * Notification.MARGIN + ADDITIONAL_MARGIN; |
722 | + width = (Notification.WIDTH + 2 * Notification.MARGIN + ADDITIONAL_MARGIN) * wm.scale_factor; |
723 | clip_to_allocation = true; |
724 | } |
725 | |
726 | @@ -67,16 +67,17 @@ |
727 | }); |
728 | |
729 | float height; |
730 | - notification.get_preferred_height (Notification.WIDTH, out height, null); |
731 | + int scale_factor = wm.scale_factor; |
732 | + notification.get_preferred_height (Notification.WIDTH * scale_factor, out height, null); |
733 | update_positions (height); |
734 | |
735 | - notification.y = TOP_OFFSET; |
736 | + notification.y = TOP_OFFSET * scale_factor; |
737 | insert_child_at_index (notification, 0); |
738 | } |
739 | |
740 | void update_positions (float add_y = 0.0f) |
741 | { |
742 | - var y = add_y + TOP_OFFSET; |
743 | + var y = add_y + TOP_OFFSET * wm.scale_factor; |
744 | var i = get_n_children (); |
745 | var delay_step = i > 0 ? 150 / i : 0; |
746 | foreach (var child in get_children ()) { |
747 | |
748 | === modified file 'plugins/notify/NotifyServer.vala' |
749 | --- plugins/notify/NotifyServer.vala 2016-08-21 13:43:54 +0000 |
750 | +++ plugins/notify/NotifyServer.vala 2016-12-18 21:20:25 +0000 |
751 | @@ -52,6 +52,7 @@ |
752 | const string FALLBACK_APP_ID = "gala-other"; |
753 | |
754 | static Gdk.RGBA? icon_fg_color = null; |
755 | + static Gdk.Pixbuf image_mask_pixbuf = null; |
756 | |
757 | [DBus (visible = false)] |
758 | public signal void show_notification (Notification notification); |
759 | @@ -169,7 +170,8 @@ |
760 | icon = app_info.get_icon ().to_string (); |
761 | |
762 | var id = (replaces_id != 0 ? replaces_id : ++id_counter); |
763 | - var pixbuf = get_pixbuf (app_name, icon, hints); |
764 | + unowned Gala.WindowManager wm = stack.wm; |
765 | + var pixbuf = get_pixbuf (app_name, icon, hints, wm.scale_factor); |
766 | var timeout = (expire_timeout == uint32.MAX ? DEFAULT_TMEOUT : expire_timeout); |
767 | |
768 | var urgency = NotificationUrgency.NORMAL; |
769 | @@ -284,9 +286,10 @@ |
770 | progress ? hints.@get ("value").get_int32 () : -1, |
771 | hints.@get (X_CANONICAL_PRIVATE_SYNCHRONOUS).get_string ()); |
772 | else |
773 | - notification = new NormalNotification (stack.screen, id, summary, body, pixbuf, |
774 | + notification = new NormalNotification (wm, id, summary, body, pixbuf, |
775 | urgency, timeout, pid, actions); |
776 | |
777 | + notification.set_scale_factor (wm.scale_factor); |
778 | notification.action_invoked.connect (notification_action_invoked_callback); |
779 | notification.closed.connect (notification_closed_callback); |
780 | stack.show_notification (notification); |
781 | @@ -325,7 +328,7 @@ |
782 | return icon_fg_color; |
783 | } |
784 | |
785 | - static Gdk.Pixbuf? get_pixbuf (string app_name, string app_icon, HashTable<string, Variant> hints) |
786 | + static Gdk.Pixbuf? get_pixbuf (string app_name, string app_icon, HashTable<string, Variant> hints, int scale_factor) |
787 | { |
788 | // decide on the icon, order: |
789 | // - image-data |
790 | @@ -337,8 +340,8 @@ |
791 | |
792 | Gdk.Pixbuf? pixbuf = null; |
793 | Variant? variant = null; |
794 | - var size = Notification.ICON_SIZE; |
795 | - var mask_offset = 4; |
796 | + var size = Notification.ICON_SIZE * scale_factor; |
797 | + var mask_offset = 4 * scale_factor; |
798 | var mask_size_offset = mask_offset * 2; |
799 | var has_mask = false; |
800 | |
801 | @@ -402,7 +405,7 @@ |
802 | } catch (Error e) { warning (e.message); } |
803 | } |
804 | } else if (has_mask) { |
805 | - var mask_size = Notification.ICON_SIZE; |
806 | + var mask_size = Notification.ICON_SIZE * scale_factor; |
807 | var offset_x = mask_offset; |
808 | var offset_y = mask_offset + 1; |
809 | |
810 | @@ -418,8 +421,15 @@ |
811 | |
812 | cr.reset_clip (); |
813 | |
814 | - var mask = new Cairo.ImageSurface.from_png (Config.PKGDATADIR + "/image-mask.png"); |
815 | - cr.set_source_surface (mask, 0, 0); |
816 | + if (image_mask_pixbuf == null) { |
817 | + try { |
818 | + image_mask_pixbuf = new Gdk.Pixbuf.from_file_at_scale (Config.PKGDATADIR + "/image-mask.svg", -1, 48 * scale_factor, true); |
819 | + } catch (Error e) { |
820 | + warning (e.message); |
821 | + } |
822 | + } |
823 | + |
824 | + Gdk.cairo_set_source_pixbuf (cr, image_mask_pixbuf, 0, 0); |
825 | cr.paint (); |
826 | |
827 | pixbuf = Gdk.pixbuf_get_from_surface (surface, 0, 0, mask_size, mask_size); |
828 | |
829 | === removed file 'plugins/notify/data/image-mask.png' |
830 | Binary files plugins/notify/data/image-mask.png 2014-07-20 19:01:52 +0000 and plugins/notify/data/image-mask.png 1970-01-01 00:00:00 +0000 differ |
831 | === added file 'plugins/notify/data/image-mask.svg' |
832 | --- plugins/notify/data/image-mask.svg 1970-01-01 00:00:00 +0000 |
833 | +++ plugins/notify/data/image-mask.svg 2016-12-18 21:20:25 +0000 |
834 | @@ -0,0 +1,235 @@ |
835 | +<?xml version="1.0" encoding="UTF-8" standalone="no"?> |
836 | +<svg |
837 | + xmlns:dc="http://purl.org/dc/elements/1.1/" |
838 | + xmlns:cc="http://creativecommons.org/ns#" |
839 | + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" |
840 | + xmlns:svg="http://www.w3.org/2000/svg" |
841 | + xmlns="http://www.w3.org/2000/svg" |
842 | + xmlns:xlink="http://www.w3.org/1999/xlink" |
843 | + width="48" |
844 | + height="48" |
845 | + id="svg2" |
846 | + version="1.1"> |
847 | + <defs |
848 | + id="defs4"> |
849 | + <linearGradient |
850 | + x1="45.447727" |
851 | + y1="92.539597" |
852 | + x2="45.447727" |
853 | + y2="7.0165396" |
854 | + id="ButtonShadow-9" |
855 | + gradientUnits="userSpaceOnUse" |
856 | + gradientTransform="scale(1.0058652,0.994169)"> |
857 | + <stop |
858 | + id="stop3750-3" |
859 | + style="stop-color:#000000;stop-opacity:1" |
860 | + offset="0" /> |
861 | + <stop |
862 | + id="stop3752-1" |
863 | + style="stop-color:#000000;stop-opacity:0.58823532" |
864 | + offset="1" /> |
865 | + </linearGradient> |
866 | + <filter |
867 | + id="filter3174-4" |
868 | + style="color-interpolation-filters:sRGB"> |
869 | + <feGaussianBlur |
870 | + id="feGaussianBlur3176-5" |
871 | + stdDeviation="1.71" /> |
872 | + </filter> |
873 | + <linearGradient |
874 | + x1="45.447727" |
875 | + y1="92.539597" |
876 | + x2="45.447727" |
877 | + y2="7.0165396" |
878 | + id="ButtonShadow" |
879 | + gradientUnits="userSpaceOnUse" |
880 | + gradientTransform="scale(1.0058652,0.994169)"> |
881 | + <stop |
882 | + id="stop3750-9" |
883 | + style="stop-color:#000000;stop-opacity:1" |
884 | + offset="0" /> |
885 | + <stop |
886 | + id="stop3752-7" |
887 | + style="stop-color:#000000;stop-opacity:0.58823532" |
888 | + offset="1" /> |
889 | + </linearGradient> |
890 | + <filter |
891 | + id="filter3174" |
892 | + style="color-interpolation-filters:sRGB"> |
893 | + <feGaussianBlur |
894 | + id="feGaussianBlur3176" |
895 | + stdDeviation="1.71" /> |
896 | + </filter> |
897 | + <linearGradient |
898 | + xlink:href="#ButtonShadow-9" |
899 | + id="linearGradient6176" |
900 | + gradientUnits="userSpaceOnUse" |
901 | + gradientTransform="scale(1.0058652,0.994169)" |
902 | + x1="45.447727" |
903 | + y1="92.539597" |
904 | + x2="45.447727" |
905 | + y2="7.0165396" /> |
906 | + <linearGradient |
907 | + xlink:href="#ButtonShadow" |
908 | + id="linearGradient6178" |
909 | + gradientUnits="userSpaceOnUse" |
910 | + gradientTransform="scale(1.0058652,0.994169)" |
911 | + x1="45.447727" |
912 | + y1="92.539597" |
913 | + x2="45.447727" |
914 | + y2="7.0165396" /> |
915 | + <linearGradient |
916 | + id="linearGradient3688-464-309-9-2-4-2"> |
917 | + <stop |
918 | + offset="0" |
919 | + style="stop-color:#181818;stop-opacity:1" |
920 | + id="stop2889-7-9-6-9" /> |
921 | + <stop |
922 | + offset="1" |
923 | + style="stop-color:#181818;stop-opacity:0" |
924 | + id="stop2891-6-6-1-7" /> |
925 | + </linearGradient> |
926 | + <linearGradient |
927 | + id="linearGradient3702-501-757-8-4-1-1-9"> |
928 | + <stop |
929 | + offset="0" |
930 | + style="stop-color:#181818;stop-opacity:0" |
931 | + id="stop2895-8-9-9-1-4" /> |
932 | + <stop |
933 | + offset="0.5" |
934 | + style="stop-color:#181818;stop-opacity:1" |
935 | + id="stop2897-7-8-7-7-3" /> |
936 | + <stop |
937 | + offset="1" |
938 | + style="stop-color:#181818;stop-opacity:0" |
939 | + id="stop2899-4-5-1-5-6" /> |
940 | + </linearGradient> |
941 | + <linearGradient |
942 | + gradientTransform="translate(0,1.0000172)" |
943 | + gradientUnits="userSpaceOnUse" |
944 | + xlink:href="#linearGradient3924-1-7-54" |
945 | + id="linearGradient3028-82" |
946 | + y2="41.978722" |
947 | + x2="40" |
948 | + y1="5.9999828" |
949 | + x1="40" /> |
950 | + <linearGradient |
951 | + id="linearGradient3924-1-7-54"> |
952 | + <stop |
953 | + offset="0" |
954 | + style="stop-color:#ffffff;stop-opacity:1" |
955 | + id="stop3926-3-4-4" /> |
956 | + <stop |
957 | + offset="0.02779419" |
958 | + style="stop-color:#ffffff;stop-opacity:0.23529412" |
959 | + id="stop3928-91-41-8" /> |
960 | + <stop |
961 | + offset="0.97279674" |
962 | + style="stop-color:#ffffff;stop-opacity:0.15686275" |
963 | + id="stop3930-6-6-6" /> |
964 | + <stop |
965 | + offset="1" |
966 | + style="stop-color:#ffffff;stop-opacity:0.39215687" |
967 | + id="stop3932-6-6-7" /> |
968 | + </linearGradient> |
969 | + <linearGradient |
970 | + gradientTransform="matrix(1.1578952,0,0,0.6428571,-3.78948,16.285716)" |
971 | + gradientUnits="userSpaceOnUse" |
972 | + xlink:href="#linearGradient3702-501-757-8-4-1-1-9" |
973 | + id="linearGradient6084-5" |
974 | + y2="39.999443" |
975 | + x2="25.058096" |
976 | + y1="47.027729" |
977 | + x1="25.058096" /> |
978 | + <radialGradient |
979 | + gradientTransform="matrix(2.3201719,0,0,0.89999994,28.617841,5.100003)" |
980 | + gradientUnits="userSpaceOnUse" |
981 | + xlink:href="#linearGradient3688-464-309-9-2-4-2" |
982 | + id="radialGradient3013-3-1" |
983 | + fy="43.5" |
984 | + fx="4.9929786" |
985 | + r="2.5" |
986 | + cy="43.5" |
987 | + cx="4.9929786" /> |
988 | + <radialGradient |
989 | + gradientTransform="matrix(-2.3201719,0,0,0.89999994,19.382159,5.100003)" |
990 | + gradientUnits="userSpaceOnUse" |
991 | + xlink:href="#linearGradient3688-464-309-9-2-4-2" |
992 | + id="radialGradient3013-3-1-8" |
993 | + fy="43.5" |
994 | + fx="4.9929786" |
995 | + r="2.5" |
996 | + cy="43.5" |
997 | + cx="4.9929786" /> |
998 | + </defs> |
999 | + <metadata |
1000 | + id="metadata7"> |
1001 | + <rdf:RDF> |
1002 | + <cc:Work |
1003 | + rdf:about=""> |
1004 | + <dc:format>image/svg+xml</dc:format> |
1005 | + <dc:type |
1006 | + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> |
1007 | + <dc:title></dc:title> |
1008 | + </cc:Work> |
1009 | + </rdf:RDF> |
1010 | + </metadata> |
1011 | + <path |
1012 | + id="path10394" |
1013 | + d="M 44 42 L 44 42.5 C 44 43.885 42.885 45 41.5 45 L 40.210938 45 L 40.210938 46.5 L 46 46.5 L 46 42 L 44 42 z " |
1014 | + style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:0.3;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:url(#radialGradient3013-3-1);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate;filter-blend-mode:normal;filter-gaussianBlur-deviation:0" /> |
1015 | + <path |
1016 | + id="rect3700-4" |
1017 | + d="M 7.7890625 45 L 7.7890625 46.5 L 40.210938 46.5 L 40.210938 45 L 7.7890625 45 z " |
1018 | + style="fill:url(#linearGradient6084-5);fill-opacity:1;stroke:none;color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:0.3;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill-rule:nonzero;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;filter-blend-mode:normal;filter-gaussianBlur-deviation:0;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" /> |
1019 | + <g |
1020 | + transform="translate(906.27272,-452.04544)" |
1021 | + style="display:none" |
1022 | + id="layer2"> |
1023 | + <rect |
1024 | + style="opacity:0.9;fill:url(#linearGradient6178);fill-opacity:1;fill-rule:nonzero;stroke:none;filter:url(#filter3174)" |
1025 | + id="rect3745" |
1026 | + y="7" |
1027 | + x="5" |
1028 | + ry="6" |
1029 | + rx="6" |
1030 | + height="85" |
1031 | + width="86" /> |
1032 | + </g> |
1033 | + <g |
1034 | + transform="translate(903,-452.40908)" |
1035 | + style="display:none" |
1036 | + id="layer2-4"> |
1037 | + <rect |
1038 | + style="opacity:0.9;fill:url(#linearGradient6176);fill-opacity:1;fill-rule:nonzero;stroke:none;filter:url(#filter3174-4)" |
1039 | + id="rect3745-5" |
1040 | + y="7" |
1041 | + x="5" |
1042 | + ry="6" |
1043 | + rx="6" |
1044 | + height="85" |
1045 | + width="86" /> |
1046 | + </g> |
1047 | + <rect |
1048 | + width="37" |
1049 | + height="37" |
1050 | + rx="1" |
1051 | + ry="1" |
1052 | + x="5.5" |
1053 | + y="6.5" |
1054 | + id="rect6741-11-6" |
1055 | + style="opacity:0.4;fill:none;stroke:url(#linearGradient3028-82);stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" /> |
1056 | + <rect |
1057 | + width="39" |
1058 | + height="39" |
1059 | + rx="2" |
1060 | + ry="2" |
1061 | + x="4.5" |
1062 | + y="5.5" |
1063 | + id="rect5505-21-3-2-7-4" |
1064 | + style="color:#000000;display:inline;overflow:visible;visibility:visible;opacity:0.3;fill:none;stroke:#000000;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;enable-background:accumulate" /> |
1065 | + <path |
1066 | + id="path10394-3" |
1067 | + d="m 4,42 0,0.5 C 4,43.885 5.115,45 6.5,45 l 1.289062,0 0,1.5 L 2,46.5 2,42 4,42 Z" |
1068 | + style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:0.3;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:url(#radialGradient3013-3-1-8);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" /> |
1069 | +</svg> |
1070 | |
1071 | === modified file 'src/WindowManager.vala' |
1072 | --- src/WindowManager.vala 2016-11-18 16:57:03 +0000 |
1073 | +++ src/WindowManager.vala 2016-12-18 21:20:25 +0000 |
1074 | @@ -68,6 +68,11 @@ |
1075 | */ |
1076 | public Meta.BackgroundGroup background_group { get; protected set; } |
1077 | |
1078 | + /** |
1079 | + * {@inheritDoc} |
1080 | + */ |
1081 | + public int scale_factor { get; protected set; } |
1082 | + |
1083 | Meta.PluginInfo info; |
1084 | |
1085 | WindowSwitcher? winswitcher = null; |
1086 | @@ -144,6 +149,8 @@ |
1087 | WindowListener.init (screen); |
1088 | KeyboardManager.init (display); |
1089 | |
1090 | + compute_scale_factor (); |
1091 | + |
1092 | // Due to a bug which enables access to the stage when using multiple monitors |
1093 | // in the screensaver, we have to listen for changes and make sure the input area |
1094 | // is set to NONE when we are in locked mode |
1095 | @@ -314,6 +321,68 @@ |
1096 | return false; |
1097 | } |
1098 | |
1099 | + /* DPI constants taken from gnome-settings-daemon/plugins/xsettings/gsd-xsettings-manager.c */ |
1100 | + private const int DPI_FALLBACK = 96; |
1101 | + /* The minimum resolution at which we turn on a window-scale of 2 */ |
1102 | + private const int HIDPI_LIMIT = (DPI_FALLBACK * 2); |
1103 | + /* The minimum screen height at which we turn on a window-scale of 2; |
1104 | + * below this there just isn't enough vertical real estate for GNOME |
1105 | + * apps to work, and it's better to just be tiny */ |
1106 | + private const int HIDPI_MIN_HEIGHT = 1200; |
1107 | + private const int SMALLEST_4K_WIDTH = 3656; |
1108 | + |
1109 | + void compute_scale_factor () |
1110 | + { |
1111 | + var desktop_settings = new GLib.Settings ("org.gnome.desktop.interface"); |
1112 | + var desktop_scale = desktop_settings.get_int ("scaling-factor"); |
1113 | + if (desktop_scale > 0) { |
1114 | + scale_factor = desktop_scale; |
1115 | + } else { |
1116 | + weak Gdk.Display? display = Gdk.Display.get_default (); |
1117 | + weak Gdk.Screen screen = display.get_default_screen (); |
1118 | + var primary = screen.get_primary_monitor (); |
1119 | + var rect = Gdk.Rectangle (); |
1120 | + screen.get_monitor_geometry (primary, out rect); |
1121 | + var monitor_scale = screen.get_monitor_scale_factor (primary); |
1122 | + |
1123 | + int width = rect.width * monitor_scale; |
1124 | + int height = rect.height * monitor_scale; |
1125 | + int width_mm = screen.get_monitor_width_mm (primary); |
1126 | + int height_mm = screen.get_monitor_height_mm (primary); |
1127 | + |
1128 | + if (height < HIDPI_MIN_HEIGHT) |
1129 | + { |
1130 | + scale_factor = 1; |
1131 | + return; |
1132 | + } |
1133 | + |
1134 | + /* Somebody encoded the aspect ratio (16/9 or 16/10) |
1135 | + * instead of the physical size */ |
1136 | + if ((width_mm == 160 && height_mm == 90) || |
1137 | + (width_mm == 160 && height_mm == 100) || |
1138 | + (width_mm == 16 && height_mm == 9) || |
1139 | + (width_mm == 16 && height_mm == 10)) |
1140 | + { |
1141 | + scale_factor = 1; |
1142 | + return; |
1143 | + } |
1144 | + |
1145 | + if (width_mm > 0 && height_mm > 0) { |
1146 | + var dpi_x = (double)width / (width_mm / 25.4); |
1147 | + var dpi_y = (double)height / (height_mm / 25.4); |
1148 | + /* We don't completely trust these values so both |
1149 | + must be high, and never pick higher ratio than |
1150 | + 2 automatically */ |
1151 | + if (dpi_x > HIDPI_LIMIT && dpi_y > HIDPI_LIMIT) { |
1152 | + scale_factor = 2; |
1153 | + return; |
1154 | + } |
1155 | + } |
1156 | + |
1157 | + scale_factor = 1; |
1158 | + } |
1159 | + } |
1160 | + |
1161 | void configure_hotcorners () |
1162 | { |
1163 | var geometry = get_screen ().get_monitor_geometry (get_screen ().get_primary_monitor ()); |
Please rebase on trunk