Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix flashing on HiDPI screens #27

Open
wants to merge 4 commits into
base: app
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions pick/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,24 @@ 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 = 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:
# 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 = [
Expand Down Expand Up @@ -858,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
Expand Down