[mate-utils] 01/01: debian/patches: Add 0001_hidpi_screenshot_support.patch: Fix the screenshot tool so that it works when HiDPI is enabled.
Martin Wimpress
flexiondotorg-guest at moszumanska.debian.org
Sat Jan 27 23:45:45 UTC 2018
This is an automated email from the git hooks/post-receive script.
flexiondotorg-guest pushed a commit to branch ubuntu/bionic
in repository mate-utils.
commit 15fef69c713b3c0afcb8fd7cf75f1a513093e040
Author: Martin Wimpress <martin.wimpress at ubuntu.com>
Date: Sat Jan 27 23:45:29 2018 +0000
debian/patches: Add 0001_hidpi_screenshot_support.patch: Fix the screenshot tool so that it works when HiDPI is enabled.
---
debian/patches/0001_hidpi_screenshot_support.patch | 139 +++++++++++++++++++++
debian/patches/series | 1 +
2 files changed, 140 insertions(+)
diff --git a/debian/patches/0001_hidpi_screenshot_support.patch b/debian/patches/0001_hidpi_screenshot_support.patch
new file mode 100644
index 0000000..175ed9b
--- /dev/null
+++ b/debian/patches/0001_hidpi_screenshot_support.patch
@@ -0,0 +1,139 @@
+diff --git a/mate-screenshot/src/screenshot-utils.c b/mate-screenshot/src/screenshot-utils.c
+index 5bc7557..b6539c8 100644
+--- a/mate-screenshot/src/screenshot-utils.c
++++ b/mate-screenshot/src/screenshot-utils.c
+@@ -628,15 +628,17 @@ mask_monitors (GdkPixbuf *pixbuf, GdkWindow *root_window)
+ cairo_region_t *region_with_monitors;
+ cairo_region_t *invisible_region;
+ cairo_rectangle_int_t rect;
++ gint scale;
+
+ screen = gdk_window_get_screen (root_window);
++ scale = gdk_window_get_scale_factor (root_window);
+
+ region_with_monitors = make_region_with_monitors (screen);
+
+ rect.x = 0;
+ rect.y = 0;
+- rect.width = WidthOfScreen (gdk_x11_screen_get_xscreen (screen));
+- rect.height = HeightOfScreen (gdk_x11_screen_get_xscreen (screen));
++ rect.width = WidthOfScreen (gdk_x11_screen_get_xscreen (screen)) / scale;
++ rect.height = HeightOfScreen (gdk_x11_screen_get_xscreen (screen)) / scale;
+
+ invisible_region = cairo_region_create_rectangle (&rect);
+ cairo_region_subtract (invisible_region, region_with_monitors);
+@@ -658,6 +660,7 @@ screenshot_get_pixbuf (GdkWindow *window,
+ GdkPixbuf *screenshot;
+ gint x_real_orig, y_real_orig, x_orig, y_orig;
+ gint width, real_width, height, real_height;
++ gint screen_width, screen_height, scale;
+
+ /* If the screenshot should include the border, we look for the WM window. */
+
+@@ -675,9 +678,13 @@ screenshot_get_pixbuf (GdkWindow *window,
+ }
+
+ root = gdk_get_default_root_window ();
++ scale = gdk_window_get_scale_factor (root);
+
+- real_width = gdk_window_get_width(window);
+- real_height = gdk_window_get_height(window);
++ real_width = gdk_window_get_width (window);
++ real_height = gdk_window_get_height (window);
++
++ screen_width = WidthOfScreen (gdk_x11_screen_get_xscreen (gdk_screen_get_default ())) / scale;
++ screen_height = HeightOfScreen (gdk_x11_screen_get_xscreen (gdk_screen_get_default ())) / scale;
+
+ gdk_window_get_origin (window, &x_real_orig, &y_real_orig);
+
+@@ -698,11 +705,11 @@ screenshot_get_pixbuf (GdkWindow *window,
+ y_orig = 0;
+ }
+
+- if (x_orig + width > WidthOfScreen (gdk_x11_screen_get_xscreen (gdk_screen_get_default ())))
+- width = WidthOfScreen (gdk_x11_screen_get_xscreen (gdk_screen_get_default ())) - x_orig;
++ if (x_orig + width > screen_width)
++ width = screen_width - x_orig;
+
+- if (y_orig + height > HeightOfScreen (gdk_x11_screen_get_xscreen (gdk_screen_get_default ())))
+- height = HeightOfScreen (gdk_x11_screen_get_xscreen (gdk_screen_get_default ())) - y_orig;
++ if (y_orig + height > screen_height)
++ height = screen_height - y_orig;
+
+ if (rectangle)
+ {
+@@ -742,6 +749,12 @@ screenshot_get_pixbuf (GdkWindow *window,
+ {
+ gboolean has_alpha = gdk_pixbuf_get_has_alpha (screenshot);
+
++ if (scale)
++ {
++ width *= scale;
++ height *= scale;
++ }
++
+ tmp = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, width, height);
+ gdk_pixbuf_fill (tmp, 0);
+
+@@ -753,8 +766,8 @@ screenshot_get_pixbuf (GdkWindow *window,
+
+ rec_x = rectangles[i].x;
+ rec_y = rectangles[i].y;
+- rec_width = rectangles[i].width;
+- rec_height = rectangles[i].height;
++ rec_width = rectangles[i].width / scale;
++ rec_height = rectangles[i].height / scale;
+
+ if (x_real_orig < 0)
+ {
+@@ -770,11 +783,17 @@ screenshot_get_pixbuf (GdkWindow *window,
+ rec_height += y_real_orig;
+ }
+
+- if (x_orig + rec_x + rec_width > WidthOfScreen (gdk_x11_screen_get_xscreen (gdk_screen_get_default ())))
+- rec_width = WidthOfScreen (gdk_x11_screen_get_xscreen (gdk_screen_get_default ())) - x_orig - rec_x;
++ if (x_orig + rec_x + rec_width > screen_width)
++ rec_width = screen_width - x_orig - rec_x;
++
++ if (y_orig + rec_y + rec_height > screen_height)
++ rec_height = screen_height - y_orig - rec_y;
+
+- if (y_orig + rec_y + rec_height > HeightOfScreen (gdk_x11_screen_get_xscreen (gdk_screen_get_default ())))
+- rec_height = HeightOfScreen (gdk_x11_screen_get_xscreen (gdk_screen_get_default ())) - y_orig - rec_y;
++ if (scale)
++ {
++ rec_width *= scale;
++ rec_height *= scale;
++ }
+
+ for (y = rec_y; y < rec_y + rec_height; y++)
+ {
+@@ -782,7 +801,7 @@ screenshot_get_pixbuf (GdkWindow *window,
+ gint x;
+
+ src_pixels = gdk_pixbuf_get_pixels (screenshot)
+- + y * gdk_pixbuf_get_rowstride(screenshot)
++ + y * gdk_pixbuf_get_rowstride (screenshot)
+ + rec_x * (has_alpha ? 4 : 3);
+ dest_pixels = gdk_pixbuf_get_pixels (tmp)
+ + y * gdk_pixbuf_get_rowstride (tmp)
+@@ -842,11 +861,17 @@ screenshot_get_pixbuf (GdkWindow *window,
+ sscanf (gdk_pixbuf_get_option (cursor_pixbuf, "x_hot"), "%d", &xhot);
+ sscanf (gdk_pixbuf_get_option (cursor_pixbuf, "y_hot"), "%d", &yhot);
+
++ if (scale)
++ {
++ cx *= scale;
++ cy *= scale;
++ }
++
+ /* in r1 we have the window coordinates */
+ r1.x = x_real_orig;
+ r1.y = y_real_orig;
+- r1.width = real_width;
+- r1.height = real_height;
++ r1.width = real_width * scale;
++ r1.height = real_height * scale;
+
+ /* in r2 we have the cursor window coordinates */
+ r2.x = cx + x_real_orig;
diff --git a/debian/patches/series b/debian/patches/series
new file mode 100644
index 0000000..e36fc9e
--- /dev/null
+++ b/debian/patches/series
@@ -0,0 +1 @@
+0001_hidpi_screenshot_support.patch
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mate/mate-utils.git
More information about the pkg-mate-commits
mailing list