def start_drag(self, point = None): self._monitor_rects = None # Find the pointer position for the occasions when we are # not being called from an event (move button). if not point: rootwin = Gdk.get_default_root_window() dunno, x_root, y_root, mask = rootwin.get_pointer() point = (x_root, y_root) # rmember pointer and window positions window = self.get_drag_window() x, y = window.get_position() self._drag_start_pointer = point self._drag_start_offset = [point[0] - x, point[1] - y] self._drag_start_rect = Rect.from_position_size(window.get_position(), window.get_size()) # not yet actually moving the window self._drag_active = False # get the threshold self._drag_threshold = self.get_drag_threshold() # check if the temporary threshold unlocking has expired if not self.drag_protection or \ not self._temporary_unlock_time is None and \ time.time() - self._temporary_unlock_time > \ self.temporary_unlock_delay: self._temporary_unlock_time = None # give keyboard window a chance to react self.on_drag_initiated()
def start_drag(self, point = None): # Find the pointer position for the occasions when we are # not being called from an event (move button). if not point: rootwin = Gdk.get_default_root_window() dunno, x_root, y_root, mask = rootwin.get_pointer() point = (x_root, y_root) # rmember pointer and window positions window = self.get_drag_window() x, y = window.get_position() self._drag_start_pointer = point self._drag_start_offset = [point[0] - x, point[1] - y] self._drag_start_rect = Rect.from_position_size(window.get_position(), window.get_size()) # not yet actually moving the window self._drag_active = False # get the threshold self._drag_threshold = self.get_drag_threshold() # check if the temporary threshold unlocking has expired if not self.drag_protection or \ not self._temporary_unlock_time is None and \ time.time() - self._temporary_unlock_time > \ self.temporary_unlock_delay: self._temporary_unlock_time = None # give keyboard window a chance to react self.on_drag_initiated()
def update_window_rect(self): """ Call this on configure event, the only time when get_position, get_size, etc. can be trusted. """ visible = self.is_visible() if visible: pos = Gtk.Window.get_position(self) size = Gtk.Window.get_size(self) origin = self.get_window().get_origin() if len(origin) == 3: # What is the first parameter for? Gdk bug? origin = origin[1:] if _logger.isEnabledFor(logging.DEBUG): _logger.debug( "update_window_rect1: pos {}, size {}, origin {}".format( pos, size, origin)) pos = self._apply_window_scaling_factor(pos) self._window_rect = Rect.from_position_size(pos, size) self._origin = origin self._client_offset = (origin[0] - pos[0], origin[1] - pos[1]) self._screen_orientation = self.get_screen_orientation() if _logger.isEnabledFor(logging.DEBUG): _logger.debug("update_window_rect2: pos {}, client_offset {}, " "screen_orientation {}".format( pos, self._client_offset, self._screen_orientation))
def position_at(self, x, y, x_align, y_align): """ Align the window with the given point. x, y in root window coordinates. """ rect = Rect.from_position_size(self.get_position(), self.get_size()) rect = rect.align_at_point(x, y, x_align, y_align) rect = self.limit_to_workarea(rect) x, y = rect.get_position() self.move(x, y)
def update_window_rect(self): """ Call this on configure event, the only time when get_position, get_size, etc. can be trusted. """ visible = self.is_visible() if visible: self._window_rect = Rect.from_position_size(Gtk.Window.get_position(self), Gtk.Window.get_size(self)) self._origin = self.get_window().get_origin() self._screen_orientation = self.get_screen_orientation()
def get_monitor_rects(screen): """ Screen limits, one rect per monitor. Monitors may have different sizes and arbitrary relative positions. """ rects = [] if screen: for i in range(screen.get_n_monitors()): r = screen.get_monitor_geometry(i) rects.append(Rect(r.x, r.y, r.width, r.height)) else: rootwin = Gdk.get_default_root_window() r = Rect.from_position_size(rootwin.get_position(), (rootwin.get_width(), rootwin.get_height())) rects.append(r) return rects
def update_window_rect(self): """ Call this on configure event, the only time when get_position, get_size, etc. can be trusted. """ visible = self.is_visible() if visible: pos = Gtk.Window.get_position(self) size = Gtk.Window.get_size(self) origin = self.get_window().get_origin() if len(origin) == 3: # What is the first parameter for? Gdk bug? origin = origin[1:] self._window_rect = Rect.from_position_size(pos, size) self._origin = origin self._client_offset = (origin[0] - pos[0], origin[1] - pos[1]) self._screen_orientation = self.get_screen_orientation()
def get_display_limits(self): rootwin = Gdk.get_default_root_window() return Rect.from_position_size(rootwin.get_position(), (rootwin.get_width(), rootwin.get_height()))
def get_rootwin_rect(): rootwin = Gdk.get_default_root_window() return Rect.from_position_size( rootwin.get_position(), (rootwin.get_width(), rootwin.get_height()))
def get_rootwin_rect(): rootwin = Gdk.get_default_root_window() return Rect.from_position_size(rootwin.get_position(), (rootwin.get_width(), rootwin.get_height()))