From 2c65b83fbb2966ce12e2712aa5cf7a4dee2d574f Mon Sep 17 00:00:00 2001 From: Moritz Marquardt Date: Tue, 7 Feb 2017 12:27:21 +0100 Subject: [PATCH 1/4] Fix flashing on HiDPI screens, including configurability should the error exist on no-HiDPI screens too. (Issue #6) --- pick/__main__.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pick/__main__.py b/pick/__main__.py index 5dca3dc..30ad1ac 100644 --- a/pick/__main__.py +++ b/pick/__main__.py @@ -151,6 +151,21 @@ def start_everything_first_time(self, on_window_map=None): if on_window_map: self.w.connect("map-event", on_window_map) + # Get the actual cursor scale from gconf so we don't get over the size limit (issue #6) + try: + cursor_scale = 1.0 + if os.getenv("CURSOR_SCALE") != None: + cursor_scale = float(os.getenv("CURSOR_SCALE")) + else: + cursor_scale = self.w.get_screen().get_display().get_default_cursor_size() / float(Gio.Settings("org.gnome.desktop.interface").get_int("cursor-size")) + if cursor_scale != 1.0: + cursor_scaled_snapsize = int(math.ceil(self.snapsize[0] / 2 / cursor_scale) * 2) + print "Adjusted cursor size: " + str(cursor_scaled_snapsize) + self.snapsize = (cursor_scaled_snapsize, cursor_scaled_snapsize) + except: + # No gnome/dconf?! + print "Couldn't determine correct cursor size. If you experience any flickering, try launching with CURSOR_SCALE=2" + devman = self.w.get_screen().get_display().get_device_manager() self.pointer = devman.get_client_pointer() keyboards = [ From a0795079bd29ce4c83fd2ac145e4b60ccfe943f6 Mon Sep 17 00:00:00 2001 From: Moritz Marquardt Date: Tue, 7 Feb 2017 12:36:27 +0100 Subject: [PATCH 2/4] Limit snapsize to get_maximal_cursor_size() for better compatibility out-of-the-box. --- pick/__main__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pick/__main__.py b/pick/__main__.py index 30ad1ac..8e34de0 100644 --- a/pick/__main__.py +++ b/pick/__main__.py @@ -159,7 +159,10 @@ def start_everything_first_time(self, on_window_map=None): else: cursor_scale = self.w.get_screen().get_display().get_default_cursor_size() / float(Gio.Settings("org.gnome.desktop.interface").get_int("cursor-size")) if cursor_scale != 1.0: - cursor_scaled_snapsize = int(math.ceil(self.snapsize[0] / 2 / cursor_scale) * 2) + cursor_scaled_snapsize = min([ + int(math.ceil(self.snapsize[0] / 2 / cursor_scale) * 2), + self.w.get_screen().get_display().get_maximal_cursor_size().width + ]) print "Adjusted cursor size: " + str(cursor_scaled_snapsize) self.snapsize = (cursor_scaled_snapsize, cursor_scaled_snapsize) except: From 32996ef1621d2fbd13dc9f9ba2b7d01020f01abc Mon Sep 17 00:00:00 2001 From: Moritz Marquardt Date: Tue, 7 Feb 2017 13:00:36 +0100 Subject: [PATCH 3/4] HiDPI-related: Fix center to grab the correct color Not sure what was wrong with the old formula, but I think it had something to do with using the latest_pb instead of pb, which then broke on HiDPI screens again, making not the center center color the one picked but the top center one. --- pick/__main__.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/pick/__main__.py b/pick/__main__.py index 8e34de0..5da2085 100644 --- a/pick/__main__.py +++ b/pick/__main__.py @@ -876,10 +876,7 @@ def magnifier_clicked(self, window, ev): def get_colour_from_pb(self, pb): pixel_data = pb.get_pixels() - offset = ( - (pb.get_rowstride() * (self.snapsize[1] / 2)) + - ((self.latest_pb.get_rowstride() / self.snapsize[0]) * - (self.snapsize[0] / 2))) + offset = pb.get_rowstride() * pb.get_height() / 2 + (pb.get_rowstride() / 2) offset = int(offset) rgb_vals = [] # pixel data gets returned as bytes or int depending From 193515bee6623b6c86d9bd16293bebde53a86327 Mon Sep 17 00:00:00 2001 From: Moritz Marquardt Date: Wed, 18 Nov 2020 18:06:54 +0100 Subject: [PATCH 4/4] Make #27 compatible with Python 3 --- pick/__main__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pick/__main__.py b/pick/__main__.py index 5da2085..f35864c 100644 --- a/pick/__main__.py +++ b/pick/__main__.py @@ -163,11 +163,11 @@ def start_everything_first_time(self, on_window_map=None): int(math.ceil(self.snapsize[0] / 2 / cursor_scale) * 2), self.w.get_screen().get_display().get_maximal_cursor_size().width ]) - print "Adjusted cursor size: " + str(cursor_scaled_snapsize) + print("Adjusted cursor size: " + str(cursor_scaled_snapsize)) self.snapsize = (cursor_scaled_snapsize, cursor_scaled_snapsize) except: # No gnome/dconf?! - print "Couldn't determine correct cursor size. If you experience any flickering, try launching with CURSOR_SCALE=2" + print("Couldn't determine correct cursor size. If you experience any flickering, try launching with CURSOR_SCALE=2") devman = self.w.get_screen().get_display().get_device_manager() self.pointer = devman.get_client_pointer()