Merge lp:~fabiozaramella/screenshot-tool/fix-for-1630612 into lp:~elementary-apps/screenshot-tool/trunk

Proposed by Fabio Zaramella
Status: Merged
Approved by: Danielle Foré
Approved revision: 272
Merged at revision: 271
Proposed branch: lp:~fabiozaramella/screenshot-tool/fix-for-1630612
Merge into: lp:~elementary-apps/screenshot-tool/trunk
Diff against target: 52 lines (+15/-5)
1 file modified
src/ScreenshotWindow.vala (+15/-5)
To merge this branch: bzr merge lp:~fabiozaramella/screenshot-tool/fix-for-1630612
Reviewer Review Type Date Requested Status
Danielle Foré Approve
Review via email: mp+315292@code.launchpad.net

Commit message

Fix the dimensions and placement of the mouse cursor for HiDPI displays

Description of the change

This branch should fix the dimensions of the mouse in HiDPI monitors.
Someone test it please.

To post a comment you must log in.
272. By Fabio Zaramella

fix cursor offset

Revision history for this message
Danielle Foré (danrabbit) wrote :

I can confirm that this fixes the issue on HiDPI displays

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/ScreenshotWindow.vala'
2--- src/ScreenshotWindow.vala 2017-01-20 17:55:41 +0000
3+++ src/ScreenshotWindow.vala 2017-01-21 20:54:43 +0000
4@@ -252,6 +252,8 @@
5 }
6
7 Gdk.Pixbuf? screenshot;
8+ int scale_factor = win.get_scale_factor ();
9+
10 if (capture_mode == CaptureType.AREA) {
11 Gdk.Rectangle selection_rect;
12 win.get_frame_extents (out selection_rect);
13@@ -266,7 +268,6 @@
14 } else {
15 int width = win.get_width ();
16 int height = win.get_height ();
17- int scale_factor = win.get_scale_factor ();
18
19 // Check the scaling factor in use, and if greater than 1 scale the image. (for HiDPI displays)
20 if (scale_factor > 1) {
21@@ -295,18 +296,27 @@
22 var manager = Gdk.Display.get_default ().get_device_manager ();
23 var device = manager.get_client_pointer ();
24
25- int cx, cy;
26+ int cx, cy, xhot, yhot;
27 win.get_device_position (device, out cx, out cy, null);
28+ xhot = int.parse (cursor_pixbuf.get_option ("x_hot")); // Left padding in cursor_pixbuf between the margin and the actual pointer
29+ yhot = int.parse (cursor_pixbuf.get_option ("y_hot")); // Top padding in cursor_pixbuf between the margin and the actual pointer
30
31 var cursor_rect = Gdk.Rectangle ();
32
33- cursor_rect.x = cx + win_rect.x;
34- cursor_rect.y = cy + win_rect.y;
35+ cursor_rect.x = cx + win_rect.x - xhot;
36+ cursor_rect.y = cy + win_rect.y - yhot;
37 cursor_rect.width = cursor_pixbuf.get_width ();
38 cursor_rect.height = cursor_pixbuf.get_height ();
39
40+ if (scale_factor > 1) {
41+ cursor_rect.x *= scale_factor;
42+ cursor_rect.y *= scale_factor;
43+ cursor_rect.width *= scale_factor;
44+ cursor_rect.height *= scale_factor;
45+ }
46+
47 if (win_rect.intersect (cursor_rect, out cursor_rect)) {
48- cursor_pixbuf.composite (screenshot, cx, cy, cursor_rect.width, cursor_rect.height, cx, cy, 1.0, 1.0, Gdk.InterpType.BILINEAR, 255);
49+ cursor_pixbuf.composite (screenshot, cursor_rect.x, cursor_rect.y, cursor_rect.width, cursor_rect.height, cursor_rect.x, cursor_rect.y, scale_factor, scale_factor, Gdk.InterpType.BILINEAR, 255);
50 }
51 }
52 }

Subscribers

People subscribed via source and target branches

to all changes: