Skip to content

Commit

Permalink
- Fix placement window in GTK Scale above 1
Browse files Browse the repository at this point in the history
- Fixes #189
  • Loading branch information
trigg committed Apr 15, 2022
1 parent fa5a948 commit 3239f4d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions discover_overlay/draggable_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@
"""An X11 window which can be moved and resized"""
import gi
import cairo
import logging
gi.require_version("Gtk", "3.0")
# pylint: disable=wrong-import-position
from gi.repository import Gtk, Gdk # nopep8

log = logging.getLogger(__name__)

class DraggableWindow(Gtk.Window):
"""An X11 window which can be moved and resized"""
Expand Down Expand Up @@ -54,13 +56,12 @@ def __init__(self, pos_x=0, pos_y=0, width=300, height=300, message="Message", s
self.drag_y = 0
self.force_location()
self.show_all()

def force_location(self):
"""
Move the window to previously given co-ords.
Also double check sanity on layer & decorations
"""

self.set_decorated(False)
self.set_keep_above(True)
self.move(self.pos_x, self.pos_y)
Expand Down Expand Up @@ -137,6 +138,9 @@ def dodraw(self, _widget, context):

def get_coords(self):
"""Return window position and size"""
scale = self.get_scale_factor()
(pos_x, pos_y) = self.get_position()
(width, height) = self.get_size()
pos_x = pos_x / scale
pos_y = pos_y / scale
return (pos_x, pos_y, width, height)
4 changes: 2 additions & 2 deletions discover_overlay/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ def close_window(self, _a=None, _b=None):
Hide for later
"""
if self.placement_window:
(pos_x, pos_y) = self.placement_window.get_position()
(width, height) = self.placement_window.get_size()
(pos_x, pos_y, width, height) = self.placement_window.get_coords()

self.floating_x = pos_x
self.floating_y = pos_y
self.floating_w = width
Expand Down

0 comments on commit 3239f4d

Please sign in to comment.