From 2c65b83fbb2966ce12e2712aa5cf7a4dee2d574f Mon Sep 17 00:00:00 2001 From: Moritz Marquardt Date: Tue, 7 Feb 2017 12:27:21 +0100 Subject: [PATCH] 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 = [