Status: | Merged | ||||
---|---|---|---|---|---|
Merged at revision: | 1008 | ||||
Proposed branch: | lp:~ricotz/plank/hidpi | ||||
Merge into: | lp:plank | ||||
Diff against target: |
259 lines (+88/-23) 6 files modified
configure.ac (+10/-0) lib/DockRenderer.vala (+25/-5) lib/Factories/AbstractMain.vala (+3/-0) lib/HideManager.vala (+13/-0) lib/PositionManager.vala (+33/-18) vapi/compat.vapi (+4/-0) |
||||
To merge this branch: | bzr merge lp:~ricotz/plank/hidpi | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Cassidy James Blaede (community) | Approve | ||
Docky Core | Pending | ||
Review via email: mp+210035@code.launchpad.net |
Commit message
Description of the change
Simple hack to figure out what needs to be done to support HiDPI
The main problem are Pixbuf based drawings with need to be upscaled by the scale-factor and downscaled for the dock-rendering again. The Gdk-API is providing scaled coords automatically. On the other hand Wnck is working with the real unscaled dimensions.
Run with "GDK_SCALE=2 src/plank"
To post a comment you must log in.
lp:~ricotz/plank/hidpi
updated
- 1008. By Rico Tzschichholz
-
Add support for GTK's HiDPI
The main problem are Pixbuf based drawings which need to be upscaled
by the scale-factor and downscaled for the dock-rendering again.The Gdk-API is providing scaled coords automatically while Wnck is
working with and returning the real unscaled dimensions. So we are
adjusting those accordingly.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'configure.ac' | |||
2 | --- configure.ac 2014-01-29 10:37:49 +0000 | |||
3 | +++ configure.ac 2014-03-20 10:19:57 +0000 | |||
4 | @@ -141,6 +141,15 @@ | |||
5 | 141 | # Optional Dependencies | 141 | # Optional Dependencies |
6 | 142 | # ----------------------------------------------------------- | 142 | # ----------------------------------------------------------- |
7 | 143 | 143 | ||
8 | 144 | # Check for HiDPI support of Gtk+ | ||
9 | 145 | GTK_MIN_VERSION=3.10.0 | ||
10 | 146 | GTK_PKGS="gtk+-3.0 >= $GTK_MIN_VERSION" | ||
11 | 147 | PKG_CHECK_MODULES(GTK, $GTK_PKGS, [enable_hidpi=yes], [enable_hidpi=no]) | ||
12 | 148 | if test "x$enable_hidpi" = "xyes" ; then | ||
13 | 149 | VALAFLAGS="$VALAFLAGS --define HAVE_GTK_3_10" | ||
14 | 150 | fi | ||
15 | 151 | AM_CONDITIONAL([HAVE_hidpi], [test "x$enable_hidpi" = "xyes"]) | ||
16 | 152 | |||
17 | 144 | # Check for newer BAMF | 153 | # Check for newer BAMF |
18 | 145 | BAMF_MIN_VERSION=0.4.0 | 154 | BAMF_MIN_VERSION=0.4.0 |
19 | 146 | BAMF_PKGS="libbamf3 >= $BAMF_MIN_VERSION" | 155 | BAMF_PKGS="libbamf3 >= $BAMF_MIN_VERSION" |
20 | @@ -310,6 +319,7 @@ | |||
21 | 310 | 319 | ||
22 | 311 | Use gee-0.8.................: ${enable_gee_0_8} | 320 | Use gee-0.8.................: ${enable_gee_0_8} |
23 | 312 | Dbusmenu support............: ${enable_dbusmenu} | 321 | Dbusmenu support............: ${enable_dbusmenu} |
24 | 322 | HiDPI support...............: ${enable_hidpi} | ||
25 | 313 | 323 | ||
26 | 314 | Apport support..............: ${enable_apport} | 324 | Apport support..............: ${enable_apport} |
27 | 315 | 325 | ||
28 | 316 | 326 | ||
29 | === modified file 'lib/DockRenderer.vala' | |||
30 | --- lib/DockRenderer.vala 2014-02-27 12:27:55 +0000 | |||
31 | +++ lib/DockRenderer.vala 2014-03-20 10:19:57 +0000 | |||
32 | @@ -62,6 +62,7 @@ | |||
33 | 62 | 62 | ||
34 | 63 | bool screen_is_composited = false; | 63 | bool screen_is_composited = false; |
35 | 64 | uint reset_position_manager_timer = 0; | 64 | uint reset_position_manager_timer = 0; |
36 | 65 | int window_scale_factor = 1; | ||
37 | 65 | 66 | ||
38 | 66 | /** | 67 | /** |
39 | 67 | * Create a new dock renderer for a dock. | 68 | * Create a new dock renderer for a dock. |
40 | @@ -242,6 +243,13 @@ | |||
41 | 242 | */ | 243 | */ |
42 | 243 | public void draw_dock (Context cr) | 244 | public void draw_dock (Context cr) |
43 | 244 | { | 245 | { |
44 | 246 | #if HAVE_GTK_3_10 | ||
45 | 247 | #if VALA_0_22 | ||
46 | 248 | window_scale_factor = controller.window.get_window ().get_scale_factor (); | ||
47 | 249 | #else | ||
48 | 250 | window_scale_factor = gdk_window_get_scale_factor (controller.window.get_window ()); | ||
49 | 251 | #endif | ||
50 | 252 | #endif | ||
51 | 245 | // take the previous frame values into account to decide if we | 253 | // take the previous frame values into account to decide if we |
52 | 246 | // can bail a full draw to not miss a finishing animation-frame | 254 | // can bail a full draw to not miss a finishing animation-frame |
53 | 247 | var no_full_draw_needed = (hide_progress == 1.0 && opacity == 1.0); | 255 | var no_full_draw_needed = (hide_progress == 1.0 && opacity == 1.0); |
54 | @@ -380,7 +388,7 @@ | |||
55 | 380 | #if BENCHMARK | 388 | #if BENCHMARK |
56 | 381 | var start = new DateTime.now_local (); | 389 | var start = new DateTime.now_local (); |
57 | 382 | #endif | 390 | #endif |
59 | 383 | var icon_surface = item.get_surface_copy (icon_size, icon_size, main_buffer); | 391 | var icon_surface = item.get_surface_copy (icon_size * window_scale_factor, icon_size * window_scale_factor, main_buffer); |
60 | 384 | unowned Context icon_cr = icon_surface.Context; | 392 | unowned Context icon_cr = icon_surface.Context; |
61 | 385 | 393 | ||
62 | 386 | DockSurface? icon_shadow_surface = null; | 394 | DockSurface? icon_shadow_surface = null; |
63 | @@ -532,14 +540,26 @@ | |||
64 | 532 | 540 | ||
65 | 533 | // draw the icon shadow | 541 | // draw the icon shadow |
66 | 534 | if (icon_shadow_surface != null) { | 542 | if (icon_shadow_surface != null) { |
67 | 543 | if (window_scale_factor > 1) { | ||
68 | 544 | shadow_cr.save (); | ||
69 | 545 | shadow_cr.scale (1.0 / window_scale_factor, 1.0 / window_scale_factor); | ||
70 | 546 | } | ||
71 | 535 | shadow_cr.set_operator (Cairo.Operator.OVER); | 547 | shadow_cr.set_operator (Cairo.Operator.OVER); |
73 | 536 | shadow_cr.set_source_surface (icon_shadow_surface.Internal, draw_value.draw_region.x - shadow_size, draw_value.draw_region.y - shadow_size); | 548 | shadow_cr.set_source_surface (icon_shadow_surface.Internal, (draw_value.draw_region.x - shadow_size) * window_scale_factor, (draw_value.draw_region.y - shadow_size) * window_scale_factor); |
74 | 537 | shadow_cr.paint (); | 549 | shadow_cr.paint (); |
75 | 550 | if (window_scale_factor > 1) | ||
76 | 551 | shadow_cr.restore (); | ||
77 | 538 | } | 552 | } |
78 | 539 | 553 | ||
79 | 540 | // draw the icon | 554 | // draw the icon |
81 | 541 | main_cr.set_source_surface (icon_surface.Internal, draw_value.draw_region.x, draw_value.draw_region.y); | 555 | if (window_scale_factor > 1) { |
82 | 556 | main_cr.save (); | ||
83 | 557 | main_cr.scale (1.0 / window_scale_factor, 1.0 / window_scale_factor); | ||
84 | 558 | } | ||
85 | 559 | main_cr.set_source_surface (icon_surface.Internal, draw_value.draw_region.x * window_scale_factor, draw_value.draw_region.y * window_scale_factor); | ||
86 | 542 | main_cr.paint (); | 560 | main_cr.paint (); |
87 | 561 | if (window_scale_factor > 1) | ||
88 | 562 | main_cr.restore (); | ||
89 | 543 | 563 | ||
90 | 544 | // draw indicators | 564 | // draw indicators |
91 | 545 | if (item.Indicator != IndicatorState.NONE) | 565 | if (item.Indicator != IndicatorState.NONE) |
92 | @@ -559,7 +579,7 @@ | |||
93 | 559 | Logger.verbose ("DockItem.draw_item_overlay (width = %i, height = %i)", width, height); | 579 | Logger.verbose ("DockItem.draw_item_overlay (width = %i, height = %i)", width, height); |
94 | 560 | var surface = new DockSurface.with_dock_surface (width, height, icon_surface); | 580 | var surface = new DockSurface.with_dock_surface (width, height, icon_surface); |
95 | 561 | 581 | ||
97 | 562 | var icon_size = position_manager.IconSize; | 582 | var icon_size = position_manager.IconSize * window_scale_factor; |
98 | 563 | var urgent_color = get_styled_color (); | 583 | var urgent_color = get_styled_color (); |
99 | 564 | urgent_color.add_hue (theme.UrgentHueShift); | 584 | urgent_color.add_hue (theme.UrgentHueShift); |
100 | 565 | 585 | ||
101 | @@ -576,7 +596,7 @@ | |||
102 | 576 | 596 | ||
103 | 577 | DockSurface draw_item_shadow (DockItem item, DockSurface icon_surface, DockSurface? current_surface) | 597 | DockSurface draw_item_shadow (DockItem item, DockSurface icon_surface, DockSurface? current_surface) |
104 | 578 | { | 598 | { |
106 | 579 | var shadow_size = controller.position_manager.IconShadowSize; | 599 | var shadow_size = controller.position_manager.IconShadowSize * window_scale_factor; |
107 | 580 | 600 | ||
108 | 581 | // Inflate size to fit shadow | 601 | // Inflate size to fit shadow |
109 | 582 | var width = icon_surface.Width + 2 * shadow_size; | 602 | var width = icon_surface.Width + 2 * shadow_size; |
110 | 583 | 603 | ||
111 | === modified file 'lib/Factories/AbstractMain.vala' | |||
112 | --- lib/Factories/AbstractMain.vala 2013-11-15 15:14:36 +0000 | |||
113 | +++ lib/Factories/AbstractMain.vala 2014-03-20 10:19:57 +0000 | |||
114 | @@ -175,6 +175,9 @@ | |||
115 | 175 | message ("Kernel version: %s", Posix.utsname ().release); | 175 | message ("Kernel version: %s", Posix.utsname ().release); |
116 | 176 | message ("GLib version: %u.%u.%u", GLib.Version.major, GLib.Version.minor, GLib.Version.micro); | 176 | message ("GLib version: %u.%u.%u", GLib.Version.major, GLib.Version.minor, GLib.Version.micro); |
117 | 177 | message ("GTK+ version: %u.%u.%u", Gtk.get_major_version (), Gtk.get_minor_version () , Gtk.get_micro_version ()); | 177 | message ("GTK+ version: %u.%u.%u", Gtk.get_major_version (), Gtk.get_minor_version () , Gtk.get_micro_version ()); |
118 | 178 | #if HAVE_GTK_3_10 | ||
119 | 179 | message ("+ HiDPI support enabled"); | ||
120 | 180 | #endif | ||
121 | 178 | message ("Wnck version: %d.%d.%d", Wnck.Version.MAJOR_VERSION, Wnck.Version.MINOR_VERSION, Wnck.Version.MICRO_VERSION); | 181 | message ("Wnck version: %d.%d.%d", Wnck.Version.MAJOR_VERSION, Wnck.Version.MINOR_VERSION, Wnck.Version.MICRO_VERSION); |
122 | 179 | message ("Cairo version: %s", Cairo.version_string ()); | 182 | message ("Cairo version: %s", Cairo.version_string ()); |
123 | 180 | message ("Pango version: %s", Pango.version_string ()); | 183 | message ("Pango version: %s", Pango.version_string ()); |
124 | 181 | 184 | ||
125 | === modified file 'lib/HideManager.vala' | |||
126 | --- lib/HideManager.vala 2014-02-18 07:45:27 +0000 | |||
127 | +++ lib/HideManager.vala 2014-03-20 10:19:57 +0000 | |||
128 | @@ -317,6 +317,19 @@ | |||
129 | 317 | void update_window_intersect () | 317 | void update_window_intersect () |
130 | 318 | { | 318 | { |
131 | 319 | var dock_rect = controller.position_manager.get_static_dock_region (); | 319 | var dock_rect = controller.position_manager.get_static_dock_region (); |
132 | 320 | #if HAVE_GTK_3_10 | ||
133 | 321 | #if VALA_0_22 | ||
134 | 322 | var window_scale_factor = controller.window.get_window ().get_scale_factor (); | ||
135 | 323 | #else | ||
136 | 324 | var window_scale_factor = gdk_window_get_scale_factor (controller.window.get_window ()); | ||
137 | 325 | #endif | ||
138 | 326 | if (window_scale_factor > 1) { | ||
139 | 327 | dock_rect.x *= window_scale_factor; | ||
140 | 328 | dock_rect.y *= window_scale_factor; | ||
141 | 329 | dock_rect.width *= window_scale_factor; | ||
142 | 330 | dock_rect.height *= window_scale_factor; | ||
143 | 331 | } | ||
144 | 332 | #endif | ||
145 | 320 | 333 | ||
146 | 321 | var intersect = false; | 334 | var intersect = false; |
147 | 322 | var dialog_intersect = false; | 335 | var dialog_intersect = false; |
148 | 323 | 336 | ||
149 | === modified file 'lib/PositionManager.vala' | |||
150 | --- lib/PositionManager.vala 2014-02-13 10:40:46 +0000 | |||
151 | +++ lib/PositionManager.vala 2014-03-20 10:19:57 +0000 | |||
152 | @@ -106,6 +106,7 @@ | |||
153 | 106 | Gdk.Rectangle monitor_geo; | 106 | Gdk.Rectangle monitor_geo; |
154 | 107 | 107 | ||
155 | 108 | bool screen_is_composited; | 108 | bool screen_is_composited; |
156 | 109 | int window_scale_factor = 1; | ||
157 | 109 | 110 | ||
158 | 110 | /** | 111 | /** |
159 | 111 | * Creates a new position manager. | 112 | * Creates a new position manager. |
160 | @@ -436,24 +437,31 @@ | |||
161 | 436 | { | 437 | { |
162 | 437 | var cursor_region = static_dock_region; | 438 | var cursor_region = static_dock_region; |
163 | 438 | var progress = 1.0 - controller.renderer.hide_progress; | 439 | var progress = 1.0 - controller.renderer.hide_progress; |
164 | 440 | #if HAVE_GTK_3_10 | ||
165 | 441 | #if VALA_0_22 | ||
166 | 442 | window_scale_factor = controller.window.get_window ().get_scale_factor (); | ||
167 | 443 | #else | ||
168 | 444 | window_scale_factor = gdk_window_get_scale_factor (controller.window.get_window ()); | ||
169 | 445 | #endif | ||
170 | 446 | #endif | ||
171 | 439 | 447 | ||
172 | 440 | switch (controller.prefs.Position) { | 448 | switch (controller.prefs.Position) { |
173 | 441 | default: | 449 | default: |
174 | 442 | case PositionType.BOTTOM: | 450 | case PositionType.BOTTOM: |
177 | 443 | cursor_region.height = int.max (1, (int) (progress * cursor_region.height)); | 451 | cursor_region.height = int.max (1 * window_scale_factor, (int) (progress * cursor_region.height)); |
178 | 444 | cursor_region.y = DockHeight - cursor_region.height; | 452 | cursor_region.y = DockHeight - cursor_region.height + (window_scale_factor - 1); |
179 | 445 | break; | 453 | break; |
180 | 446 | case PositionType.TOP: | 454 | case PositionType.TOP: |
182 | 447 | cursor_region.height = int.max (1, (int) (progress * cursor_region.height)); | 455 | cursor_region.height = int.max (1 * window_scale_factor, (int) (progress * cursor_region.height)); |
183 | 448 | cursor_region.y = 0; | 456 | cursor_region.y = 0; |
184 | 449 | break; | 457 | break; |
185 | 450 | case PositionType.LEFT: | 458 | case PositionType.LEFT: |
187 | 451 | cursor_region.width = int.max (1, (int) (progress * cursor_region.width)); | 459 | cursor_region.width = int.max (1 * window_scale_factor, (int) (progress * cursor_region.width)); |
188 | 452 | cursor_region.x = 0; | 460 | cursor_region.x = 0; |
189 | 453 | break; | 461 | break; |
190 | 454 | case PositionType.RIGHT: | 462 | case PositionType.RIGHT: |
193 | 455 | cursor_region.width = int.max (1, (int) (progress * cursor_region.width)); | 463 | cursor_region.width = int.max (1 * window_scale_factor, (int) (progress * cursor_region.width)); |
194 | 456 | cursor_region.x = DockWidth - cursor_region.width; | 464 | cursor_region.x = DockWidth - cursor_region.width + (window_scale_factor - 1); |
195 | 457 | break; | 465 | break; |
196 | 458 | } | 466 | } |
197 | 459 | 467 | ||
198 | @@ -1065,27 +1073,34 @@ | |||
199 | 1065 | */ | 1073 | */ |
200 | 1066 | public void get_struts (ref ulong[] struts) | 1074 | public void get_struts (ref ulong[] struts) |
201 | 1067 | { | 1075 | { |
202 | 1076 | #if HAVE_GTK_3_10 | ||
203 | 1077 | #if VALA_0_22 | ||
204 | 1078 | window_scale_factor = controller.window.get_window ().get_scale_factor (); | ||
205 | 1079 | #else | ||
206 | 1080 | window_scale_factor = gdk_window_get_scale_factor (controller.window.get_window ()); | ||
207 | 1081 | #endif | ||
208 | 1082 | #endif | ||
209 | 1068 | switch (controller.prefs.Position) { | 1083 | switch (controller.prefs.Position) { |
210 | 1069 | default: | 1084 | default: |
211 | 1070 | case PositionType.BOTTOM: | 1085 | case PositionType.BOTTOM: |
215 | 1071 | struts [Struts.BOTTOM] = VisibleDockHeight + controller.window.get_screen ().get_height () - monitor_geo.y - monitor_geo.height; | 1086 | struts [Struts.BOTTOM] = (VisibleDockHeight + controller.window.get_screen ().get_height () - monitor_geo.y - monitor_geo.height) * window_scale_factor; |
216 | 1072 | struts [Struts.BOTTOM_START] = monitor_geo.x; | 1087 | struts [Struts.BOTTOM_START] = monitor_geo.x * window_scale_factor; |
217 | 1073 | struts [Struts.BOTTOM_END] = monitor_geo.x + monitor_geo.width - 1; | 1088 | struts [Struts.BOTTOM_END] = (monitor_geo.x + monitor_geo.width) * window_scale_factor - 1; |
218 | 1074 | break; | 1089 | break; |
219 | 1075 | case PositionType.TOP: | 1090 | case PositionType.TOP: |
223 | 1076 | struts [Struts.TOP] = monitor_geo.y + VisibleDockHeight; | 1091 | struts [Struts.TOP] = (monitor_geo.y + VisibleDockHeight) * window_scale_factor; |
224 | 1077 | struts [Struts.TOP_START] = monitor_geo.x; | 1092 | struts [Struts.TOP_START] = monitor_geo.x * window_scale_factor; |
225 | 1078 | struts [Struts.TOP_END] = monitor_geo.x + monitor_geo.width - 1; | 1093 | struts [Struts.TOP_END] = (monitor_geo.x + monitor_geo.width) * window_scale_factor - 1; |
226 | 1079 | break; | 1094 | break; |
227 | 1080 | case PositionType.LEFT: | 1095 | case PositionType.LEFT: |
231 | 1081 | struts [Struts.LEFT] = monitor_geo.x + VisibleDockWidth; | 1096 | struts [Struts.LEFT] = (monitor_geo.x + VisibleDockWidth) * window_scale_factor; |
232 | 1082 | struts [Struts.LEFT_START] = monitor_geo.y; | 1097 | struts [Struts.LEFT_START] = monitor_geo.y * window_scale_factor; |
233 | 1083 | struts [Struts.LEFT_END] = monitor_geo.y + monitor_geo.height - 1; | 1098 | struts [Struts.LEFT_END] = (monitor_geo.y + monitor_geo.height) * window_scale_factor - 1; |
234 | 1084 | break; | 1099 | break; |
235 | 1085 | case PositionType.RIGHT: | 1100 | case PositionType.RIGHT: |
239 | 1086 | struts [Struts.RIGHT] = VisibleDockWidth + controller.window.get_screen ().get_width () - monitor_geo.x - monitor_geo.width; | 1101 | struts [Struts.RIGHT] = (VisibleDockWidth + controller.window.get_screen ().get_width () - monitor_geo.x - monitor_geo.width) * window_scale_factor; |
240 | 1087 | struts [Struts.RIGHT_START] = monitor_geo.y; | 1102 | struts [Struts.RIGHT_START] = monitor_geo.y * window_scale_factor; |
241 | 1088 | struts [Struts.RIGHT_END] = monitor_geo.y + monitor_geo.height - 1; | 1103 | struts [Struts.RIGHT_END] = (monitor_geo.y + monitor_geo.height) * window_scale_factor - 1; |
242 | 1089 | break; | 1104 | break; |
243 | 1090 | } | 1105 | } |
244 | 1091 | } | 1106 | } |
245 | 1092 | 1107 | ||
246 | === modified file 'vapi/compat.vapi' | |||
247 | --- vapi/compat.vapi 2014-02-14 07:00:32 +0000 | |||
248 | +++ vapi/compat.vapi 2014-03-20 10:19:57 +0000 | |||
249 | @@ -21,6 +21,10 @@ | |||
250 | 21 | [CCode (cheader_filename = "gdk-pixbuf/gdk-pixbuf.h", cname = "gdk_pixbuf_new_from_resource")] | 21 | [CCode (cheader_filename = "gdk-pixbuf/gdk-pixbuf.h", cname = "gdk_pixbuf_new_from_resource")] |
251 | 22 | public Gdk.Pixbuf gdk_pixbuf_new_from_resource (string resource_path) throws GLib.Error; | 22 | public Gdk.Pixbuf gdk_pixbuf_new_from_resource (string resource_path) throws GLib.Error; |
252 | 23 | #endif | 23 | #endif |
253 | 24 | #if !VALA_0_22 && HAVE_GTK_3_10 | ||
254 | 25 | [CCode (cheader_filename = "gdk/gdk.h", cname = "gdk_window_get_scale_factor")] | ||
255 | 26 | public int gdk_window_get_scale_factor (Gdk.Window window); | ||
256 | 27 | #endif | ||
257 | 24 | #if !VALA_0_24 | 28 | #if !VALA_0_24 |
258 | 25 | [CCode (cheader_filename = "gtk/gtk.h", cname = "gtk_widget_shape_combine_region")] | 29 | [CCode (cheader_filename = "gtk/gtk.h", cname = "gtk_widget_shape_combine_region")] |
259 | 26 | public void gtk_widget_shape_combine_region (Gtk.Widget widget, Cairo.Region? region); | 30 | public void gtk_widget_shape_combine_region (Gtk.Widget widget, Cairo.Region? region); |
This looks to be doing the right thing when run with GDK_SCALE=2.