def test_process_all_updates(): ''' Calling ``gdk.window_process_all_updates`` clears the update area of all windows. ''' window = gdk.Window(None, 20, 20, gdk.WINDOW_TOPLEVEL, 0, gdk.INPUT_OUTPUT) window.show() assert window.get_update_area() gdk.window_process_all_updates() assert not window.get_update_area()
def test_invalidate_mapped_window(): ''' Ensure that a mapped ``gdk.Window`` can be invalidated as expected. ''' window = gdk.Window(None, 100, 100, gdk.WINDOW_TOPLEVEL, 0, gdk.INPUT_OUTPUT) window.show() gdk.window_process_all_updates() window.invalidate_rect(gdk.Rectangle(0, 0, 50, 50), False) region = window.get_update_area() area = region.get_clipbox() assert area.x == 0 assert area.y == 0 assert area.width == 50 assert area.height == 50
def set_window_always_on_top(title): # we need the GDK module, if not available - ignroe this command try: if sys.version_info < (3, 0): from gtk import gdk else: #from gi.repository import Gdk as gdk return except ImportError: return # search the window and set it as above root = gdk.get_default_root_window() for id in root.property_get('_NET_CLIENT_LIST')[2]: w = gdk.window_foreign_new(id) if w: name = w.property_get('WM_NAME')[2] if title in name: w.set_keep_above(True) gdk.window_process_all_updates() break
def set_window_always_on_top (title): # we need the GDK module, if not available - ignroe this command try: if sys.version_info < (3,0): from gtk import gdk else: #from gi.repository import Gdk as gdk return except ImportError: return # search the window and set it as above root = gdk.get_default_root_window() for id in root.property_get('_NET_CLIENT_LIST')[2]: w = gdk.window_foreign_new(id) if w: name = w.property_get('WM_NAME')[2] if name == title: w.set_keep_above(True) gdk.window_process_all_updates() break
def gdk_window_settings(win, x=None, y=None, width=None, height=None, decoration=None, maximized=False, centered=False): ''' Applies appeareance and position modifications to the Window identified by win ''' # Screen dimensions scr_width = gdk.screen_width() scr_height = gdk.screen_height() - BOTTOM_BAR_HEIGHT # Window dimensions and position old_x, old_y = win.get_root_origin() old_width, old_height = win.get_geometry()[2:4] # Sort out the decorations if decoration is not None: if decoration is False: # Resize if the window was decorated before if _is_decorated(win): dw, dh = _get_decoration_size(win) old_width += dw old_height += dh win.set_decorations(0) gdk.window_process_all_updates() gdk.flush() else: # Resize if the window was not decorated before if not _is_decorated(win): win.set_decorations(1) gdk.flush() dw, dh = _get_decoration_size(win) old_width -= dw old_height -= dh # Resizing is irrelevant when maximizing, so just return afterwards if maximized: win.maximize() gdk.window_process_all_updates() gdk.flush() return # Initialize the target values new_x, new_y, new_width, new_height = old_x, old_y, old_width, old_height # Window position if x is not None: if x <= 1: new_x = scr_width * x else: new_x = x if y is not None: if y <= 1: new_y = scr_height * y else: new_y = y # Window dimensions if width is not None: if width <= 1: new_width = scr_width * width else: new_width = width if decoration is True: new_width -= _get_decoration_size(win)[0] if height is not None: if height <= 1: new_height = scr_height * height else: new_height = height if decoration is True: new_height -= _get_decoration_size(win)[1] # Should the window be centered? if centered: dec_w, dec_h = _get_decoration_size(win) new_x = (scr_width - new_width - dec_w) / 2 new_y = (scr_height - new_height - dec_h) / 2 # Do all the resizing at once win.move_resize(int(new_x), int(new_y), int(new_width), int(new_height)) gdk.window_process_all_updates() gdk.flush()
def sleep(self, seconds): gdk.window_process_all_updates() time.sleep(seconds)