def do_realize(self): self.set_flags(self.flags() | gtk.REALIZED) self.window = gdk.Window(self.get_parent_window(), window_type=gdk.WINDOW_CHILD, x=self.allocation.x, y=self.allocation.y, width=self.allocation.width, height=self.allocation.height, wclass=gdk.INPUT_OUTPUT, colormap=self.get_colormap(), event_mask=gdk.VISIBILITY_NOTIFY_MASK) self.window.set_user_data(self) self._bin_window = gdk.Window( self.window, window_type=gdk.WINDOW_CHILD, x=int(-self._hadj.value), y=int(-self._vadj.value), width=max(self._width, self.allocation.width), height=max(self._height, self.allocation.height), colormap=self.get_colormap(), wclass=gdk.INPUT_OUTPUT, event_mask=(self.get_events() | gdk.EXPOSURE_MASK | gdk.SCROLL_MASK)) self._bin_window.set_user_data(self) self.set_style(self.style.attach(self.window)) self.style.set_background(self.window, gtk.STATE_NORMAL) self.style.set_background(self._bin_window, gtk.STATE_NORMAL) for child in self._children: child.widget.set_parent_window(self._bin_window) self.queue_resize()
def do_realize(self): # The do_realize method is responsible for creating GDK (windowing system) # resources. In this example we will create a new gdk.Window which we # then draw on # First set an internal flag telling that we're realized self.set_flags(gtk.REALIZED) # Create a new gdk.Window which we can draw on. # Also say that we want to receive exposure events by setting # the event_mask self.window = gdk.Window(self.get_parent_window(), width=self.allocation.width, height=self.allocation.height, window_type=gdk.WINDOW_CHILD, wclass=gdk.INPUT_OUTPUT, event_mask=self.get_events() | gdk.EXPOSURE_MASK) # Associate the gdk.Window with ourselves, Gtk+ needs a reference # between the widget and the gdk window self.window.set_user_data(self) # Attach the style to the gdk.Window, a style contains colors and # GC contextes used for drawing self.style.attach(self.window) # The default color of the background should be what # the style (theme engine) tells us. self.style.set_background(self.window, gtk.STATE_NORMAL) self.window.move_resize(*self.allocation)
def do_realize(self): # Internal housekeeping self.set_flags(self.flags() | gtk.REALIZED) self.window = gdk.Window( self.get_parent_window(), x=self.allocation.x, y=self.allocation.y, width=self.allocation.width, height=self.allocation.height, window_type=gdk.WINDOW_CHILD, wclass=gdk.INPUT_OUTPUT, event_mask=(gdk.EXPOSURE_MASK | gdk.LEAVE_NOTIFY_MASK | gdk.BUTTON_PRESS_MASK | gdk.BUTTON_RELEASE_MASK | gdk.POINTER_MOTION_MASK)) self.window.set_user_data(self) self.style.attach(self.window) self.style.set_background(self.window, gtk.STATE_NORMAL) # Set parent window on all child widgets for item in self._items: item.child.set_parent_window(self.window) # Initialize cursors self._hcursor = gdk.Cursor(self.get_display(), gdk.SB_H_DOUBLE_ARROW) self._vcursor = gdk.Cursor(self.get_display(), gdk.SB_V_DOUBLE_ARROW)
def do_realize(self): self.set_flags(self.flags() | gtk.REALIZED) temporary_window = self.get_parent_window() events = (gdk.EXPOSURE_MASK | gdk.BUTTON_PRESS_MASK | gdk.BUTTON_RELEASE_MASK | gdk.MOTION_NOTIFY ) self.window = gdk.Window(temporary_window, width = self.allocation.width, height = self.allocation.height, window_type = gdk.WINDOW_CHILD, event_mask = (self.get_events() | events ), wclass = gdk.INPUT_OUTPUT, x = self.allocation.x, y = self.allocation.y) self.window.set_user_data(self) self.style.attach(self.window) temp_map = gdk.pixmap_colormap_create_from_xpm_d(self.window, self.get_colormap(), None, self._xmp) self.window.set_back_pixmap(temp_map[0], False)
def __create_top_toolbar_window(self): self.top_toolbar_expose_event = None self.__top_toolbar_h = 30 self.__top_toolbar_window = gdk.Window( self.__bin_window, window_type=gdk.WINDOW_CHILD, x=0, y=0, width=self.allocation.width, height=self.__top_toolbar_h, visual=self.get_visual(), colormap=self.get_colormap(), wclass=gdk.INPUT_OUTPUT, event_mask=(self.get_events() | gdk.EXPOSURE_MASK | gdk.BUTTON_MOTION_MASK | gdk.ENTER_NOTIFY_MASK | gdk.LEAVE_NOTIFY_MASK | gdk.POINTER_MOTION_HINT_MASK | gdk.BUTTON_PRESS_MASK)) self.__top_toolbar_window.set_user_data(self) self.style.set_background(self.__top_toolbar_window, gtk.STATE_NORMAL) # if self.__top_child: self.__top_child.set_parent_window(self.__top_toolbar_window)
def do_realize(self): """Realize the widget""" self.set_flags(self.flags() | gtk.REALIZED) self.window = gdk.Window( self.get_parent_window(), width = self.allocation.width, height = self.allocation.height, window_type = gdk.WINDOW_CHILD, wclass = gdk.INPUT_OUTPUT, event_mask = self.get_events() | gdk.EXPOSURE_MASK | gdk.BUTTON1_MOTION_MASK | gdk.BUTTON_PRESS_MASK | gdk.BUTTON_RELEASE_MASK | gdk.POINTER_MOTION_MASK | gdk.POINTER_MOTION_HINT_MASK) self.window.set_user_data(self) self.style.attach(self.window) self.style.set_background(self.window, gtk.STATE_NORMAL) self.window.move_resize(*self.allocation) self.gc = self.window.new_gc() self.connect("motion-notify-event", self.cb_motion_notify) self.connect("button-press-event", self.cb_button_press) self.connect("button-release-event", self.cb_button_release)
def do_realize(self): ident = os.environ.get('XSCREENSAVER_WINDOW') if ident is None: self.window = gdk.Window(self.get_parent_window(), width=self.allocation.width, height=self.allocation.height, window_type=gdk.WINDOW_TOPLEVEL, event_mask=self.get_events() | gdk.EXPOSURE_MASK, wclass=gdk.INPUT_OUTPUT, title=self.__default_title) self.set_size_request(self.__default_width, self.__default_height) self.connect('delete-event', self.on_destroy) else: self.window = gdk.window_foreign_new(int(ident, 16)) self.window.set_events(gdk.EXPOSURE_MASK | gdk.STRUCTURE_MASK) x, y, w, h, depth = self.window.get_geometry() self.size_allocate(gdk.Rectangle(x, y, w, h)) self.set_default_size(w, h) self.set_size_request(w, h) self.set_decorated(False) self.window.set_user_data(self) self.style.attach(self.window) self.set_flags(self.flags() | gtk.REALIZED)
def do_realize(self): self.set_flags(self.flags() | gtk.REALIZED) gtk.EventBox.do_realize(self) temporary_window = self.get_parent_window() events = (gdk.EXPOSURE_MASK | gdk.BUTTON_PRESS_MASK | gdk.BUTTON_RELEASE_MASK | gdk.MOTION_NOTIFY) self.window = gdk.Window(temporary_window, width=self.allocation.width, height=self.allocation.height, window_type=gdk.WINDOW_CHILD, event_mask=(self.get_events() | events), wclass=gdk.INPUT_OUTPUT, visual=self.get_visual(), x=self.allocation.x, y=self.allocation.y) self.window.set_user_data(self) self.window.set_background(self.style.base[self.state]) #self.style.attach(self.window) c = self.get_colormap() color = c.alloc_color(65000, 0, 0) #self.style.set_background(self.window, gtk.STATE_NORMAL) self._draw_gc = gtk.gdk.GC(self.window, line_width=6, foreground=color) x, y, w, h = self.allocation self.window.draw_rectangle(self._draw_gc, True, 0, 0, 30, 30)
def realize(self): if self.flags() & gtk.REALIZED: return ident = os.environ.get('XSCREENSAVER_WINDOW') if not ident is None: print 'if not ident is None:' self.window = gtk.gdk.window_foreign_new(int(ident, 16)) self.window.set_events(gdk.EXPOSURE_MASK | gdk.STRUCTURE_MASK) # added by aja x, y, w, h, depth = self.window.get_geometry() self.size_allocate(gtk.gdk.Rectangle(x, y, w, h)) self.set_default_size(w, h) self.set_decorated(False) # aja - more self.window.set_user_data(self) self.style.attach(self.window) self.set_flags(self.flags() | gtk.REALIZED) #self.window.connect("destroy", self.destroy) if self.window == None: print 'self.window == None:' self.window = gdk.Window(None, 1024, 768, gdk.WINDOW_TOPLEVEL, (gdk.EXPOSURE_MASK | gdk.STRUCTURE_MASK), gdk.INPUT_OUTPUT) if self.window != None: print 'self.window != None:' #self.window.add_filter(lambda *args: self.filter_event(args)) self.set_flags(self.flags() | gtk.REALIZED)
def do_realize(self): # Internal housekeeping self.set_flags(self.flags() | gtk.REALIZED) self.window = gdk.Window( self.get_parent_window(), x=self.allocation.x, y=self.allocation.y, width=self.allocation.width, height=self.allocation.height, window_type=gdk.WINDOW_CHILD, wclass=gdk.INPUT_OUTPUT, event_mask=(gdk.EXPOSURE_MASK | gdk.POINTER_MOTION_MASK | gdk.BUTTON_PRESS_MASK | gdk.BUTTON_RELEASE_MASK)) self.window.set_user_data(self) self.style.attach(self.window) self.style.set_background(self.window, gtk.STATE_NORMAL) # Set parent window on all child widgets for tab in self._tabs: tab.image.set_parent_window(self.window) tab.label.set_parent_window(self.window) tab.button.set_parent_window(self.window) tab.item.set_parent_window(self.window) self._list_button.set_parent_window(self.window) self._min_button.set_parent_window(self.window) self._max_button.set_parent_window(self.window)
def do_realize(self): gtk.Bin.do_realize(self) self.set_realized(True) self.allocation.x = 0 self.allocation.y = 0 self.window = gdk.Window(self.get_parent_window(), window_type=gdk.WINDOW_CHILD, x=self.allocation.x, y=self.allocation.y, width=self.allocation.width, height=self.allocation.height, colormap=self.get_colormap(), wclass=gdk.INPUT_OUTPUT, visual=self.get_visual(), event_mask=(self.get_events() | gdk.EXPOSURE_MASK | gdk.BUTTON_MOTION_MASK | gdk.ENTER_NOTIFY_MASK | gdk.LEAVE_NOTIFY_MASK | gdk.POINTER_MOTION_HINT_MASK | gdk.BUTTON_PRESS_MASK)) self.window.set_user_data(self) #self.style.set_background(self.window, gtk.STATE_NORMAL) self.__init_handle_window() self.__init_top_window() self.__init_bottom_window() if self.__child1: self.__child1.set_parent_window(self.window) if self.__child2: self.__child2.set_parent_window(self.window) if self.mid_child: self.mid_child.set_parent_window(self.window) self.queue_resize()
def do_realize(self): self.set_flags(self.flags() | gtk.REALIZED) self.window = gdk.Window( self.get_parent_window(), width=self.allocation.width, height=self.allocation.height, window_type=gdk.WINDOW_CHILD, wclass=gdk.INPUT_OUTPUT, event_mask=self.get_events() | gdk.EXPOSURE_MASK) colormap = gtk.gdk.colormap_get_system() self.black = colormap.alloc_color(0, 0, 0) self.green = colormap.alloc_color(0, 65535, 0) self.orange = colormap.alloc_color(65535, 32768, 0) self.red = colormap.alloc_color(65535, 0, 0) self.yellow = colormap.alloc_color(65535, 65535, 0) self.black_gc = gdk.GC(self.window, foreground=self.black) self.green_gc = gdk.GC(self.window, foreground=self.green) self.orange_gc = gdk.GC(self.window, foreground=self.orange) self.red_gc = gdk.GC(self.window, foreground=self.red) self.yellow_gc = gdk.GC(self.window, foreground=self.yellow) self.window.set_user_data(self) self.style.attach(self.window) self.style.set_background(self.window, gtk.STATE_NORMAL)
def get_group_leader(self, wid, metadata, override_redirect): transient_for = metadata.intget("transient-for", -1) log("get_group_leader: transient_for=%s", transient_for) if transient_for > 0: client_window = self._id_to_window.get(transient_for) if client_window: gdk_window = client_window.get_window() if gdk_window: return gdk_window pid = metadata.intget("pid", -1) leader_xid = metadata.intget("group-leader-xid", -1) leader_wid = metadata.intget("group-leader-wid", -1) group_leader_window = self._id_to_window.get(leader_wid) if group_leader_window: #leader is another managed window log("found group leader window %s for wid=%s", group_leader_window, leader_wid) return group_leader_window log("get_group_leader: leader pid=%s, xid=%s, wid=%s", pid, leader_xid, leader_wid) reftype = "xid" ref = leader_xid if ref < 0: reftype = "leader-wid" ref = leader_wid if ref < 0: ci = metadata.strlistget("class-instance") if ci: reftype = "class" ref = "|".join(ci) elif pid > 0: reftype = "pid" ref = pid elif transient_for > 0: #this should have matched a client window above.. #but try to use it anyway: reftype = "transient-for" ref = transient_for else: #no reference to use return None refkey = "%s:%s" % (reftype, ref) group_leader_window = self._ref_to_group_leader.get(refkey) if group_leader_window: log("found existing group leader window %s using ref=%s", group_leader_window, refkey) return group_leader_window #we need to create one: title = "%s group leader for %s" % (self.session_name or "Xpra", pid) group_leader_window = gdk.Window(None, 1, 1, gdk.WINDOW_TOPLEVEL, 0, gdk.INPUT_ONLY, title) self._ref_to_group_leader[refkey] = group_leader_window #avoid warning on win32... if not sys.platform.startswith("win"): #X11 spec says window should point to itself: group_leader_window.set_group(group_leader_window) log("new hidden group leader window %s for ref=%s", group_leader_window, refkey) self._group_leader_wids.setdefault(group_leader_window, []).append(wid) return group_leader_window
def _setup_ewmh_window(self): # Set up a 1x1 invisible unmapped window, with which to participate in # EWMH's _NET_SUPPORTING_WM_CHECK protocol. The only important things # about this window are the _NET_SUPPORTING_WM_CHECK property, and # its title (which is supposed to be the name of the window manager). # NB, GDK will do strange things to this window. We don't want to use # it for anything. (In particular, it will call XSelectInput on it, # which is fine normally when GDK is running in a client, but since it # happens to be using the same connection as we the WM, it will # clobber any XSelectInput calls that *we* might have wanted to make # on this window.) Also, GDK might silently swallow all events that # are detected on it, anyway. self._ewmh_window = gdk.Window( self._root, width=1, height=1, window_type=gdk.WINDOW_TOPLEVEL, event_mask=0, # event mask wclass=gdk.INPUT_ONLY, title=self._wm_name) prop_set(self._ewmh_window, "_NET_SUPPORTING_WM_CHECK", "window", self._ewmh_window) self.root_set("_NET_SUPPORTING_WM_CHECK", "window", self._ewmh_window) self.root_set("_NET_WM_NAME", "utf8", self._wm_name.decode("utf8"))
def dock_tray(self, xid): log("dock_tray(%#x)", xid) root = gdk.get_default_root_window() window = gdk.window_foreign_new(xid) if window is None: log.warn("could not find gdk window for tray window %#x", xid) return log("dock_tray: root=%s, window=%s", root, window) w, h = window.get_geometry()[2:4] log("dock_tray: geometry=%s", (w, h)) if w == 0 and h == 0: log("dock_tray: invalid tray geometry, ignoring this request") return event_mask = gdk.STRUCTURE_MASK | gdk.EXPOSURE_MASK | gdk.PROPERTY_CHANGE_MASK window.set_events(event_mask=event_mask) add_event_receiver(window, self) w = max(1, min(128, w)) h = max(1, min(128, h)) title = prop_get(window, "_NET_WM_NAME", "utf8", ignore_errors=True) if title is None: title = prop_get(window, "WM_NAME", "latin1", ignore_errors=True) if title is None: title = "" log( "dock_tray(%#x) gdk window=%#x, geometry=%s, title=%s, visual.depth=%s", xid, window.xid, window.get_geometry(), title, window.get_visual().depth) event_mask = gdk.STRUCTURE_MASK | gdk.EXPOSURE_MASK | gdk.PROPERTY_CHANGE_MASK tray_window = gdk.Window(root, width=w, height=h, window_type=gdk.WINDOW_TOPLEVEL, event_mask=event_mask, wclass=gdk.INPUT_OUTPUT, title=title, x=-200, y=-200, override_redirect=True, visual=window.get_visual(), colormap=window.get_colormap()) log("dock_tray(%#x) setting tray properties", xid) set_tray_window(tray_window, window) tray_window.show() self.tray_windows[window] = tray_window self.window_trays[tray_window] = window log("dock_tray(%#x) resizing and reparenting", xid) window.resize(w, h) xwin = window.xid xtray = tray_window.xid X11Window.Withdraw(xwin) X11Window.Reparent(xwin, xtray, 0, 0) X11Window.MapRaised(xwin) log("dock_tray(%#x) new tray container window %#x", xid, xtray) tray_window.invalidate_rect(gdk.Rectangle(width=w, height=h), True) X11Window.send_xembed_message(xwin, XEMBED_EMBEDDED_NOTIFY, 0, xtray, XEMBED_VERSION)
def setup(self): super(WindowModel, self).setup() x, y, w, h, _ = self.client_window.get_geometry() # We enable PROPERTY_CHANGE_MASK so that we can call # x11_get_server_time on this window. # clamp this window to the desktop size: x, y = self._clamp_to_desktop(x, y, w, h) self.corral_window = gdk.Window(self.parking_window, x=x, y=y, width=w, height=h, window_type=gdk.WINDOW_CHILD, wclass=gdk.INPUT_OUTPUT, event_mask=gdk.PROPERTY_CHANGE_MASK, title = "CorralWindow-%#x" % self.xid) log("setup() corral_window=%#x", self.corral_window.xid) prop_set(self.corral_window, "_NET_WM_NAME", "utf8", u"Xpra-CorralWindow-%#x" % self.xid) X11Window.substructureRedirect(self.corral_window.xid) add_event_receiver(self.corral_window, self) # The child might already be mapped, in case we inherited it from # a previous window manager. If so, we unmap it now, and save the # serial number of the request -- this way, when we get an # UnmapNotify later, we'll know that it's just from us unmapping # the window, not from the client withdrawing the window. if X11Window.is_mapped(self.xid): log("hiding inherited window") self.last_unmap_serial = X11Window.Unmap(self.xid) log("setup() adding to save set") X11Window.XAddToSaveSet(self.xid) self.in_save_set = True log("setup() reparenting") X11Window.Reparent(self.xid, self.corral_window.xid, 0, 0) self.client_reparented = True geomlog("setup() geometry") geom = X11Window.geometry_with_border(self.xid) if geom is None: raise Unmanageable("window %#x disappeared already" % self.xid) w, h = geom[2:4] hints = self.get_property("size-hints") geomlog("setup() hints=%s size=%ix%i", hints, w, h) nw, nh = calc_constrained_size(w, h, hints) if nw>=MAX_WINDOW_SIZE or nh>=MAX_WINDOW_SIZE: #we can't handle windows that big! raise Unmanageable("window constrained size is too large: %sx%s (from client geometry: %s,%s with size hints=%s)" % (nw, nh, w, h, hints)) self._updateprop("geometry", (x, y, nw, nh)) geomlog("setup() resizing windows to %sx%s", nw, nh) self.corral_window.resize(nw, nh) self.client_window.resize(nw, nh) self.client_window.show_unraised() #this is here to trigger X11 errors if any are pending #or if the window is deleted already: self.client_window.get_geometry()
def do_realize(self): self.set_flags(self.flags() | gtk.REALIZED) self.window = gdk.Window(self.get_parent_window(), width=20, height=self.allocation.height, window_type=gdk.WINDOW_CHILD, wclass=gdk.INPUT_OUTPUT, event_mask=self.get_events() | gdk.EXPOSURE_MASK | gdk.BUTTON_PRESS_MASK ) self.window.set_user_data(self) self.style.attach(self.window) self.style.set_background(self.window, gtk.STATE_NORMAL)
def do_realize(self): """Realize the widget""" self.set_flags(self.flags() | gtk.REALIZED) self.window = gdk.Window(self.get_parent_window(), width=self.allocation.width, height=self.allocation.height, window_type=gdk.WINDOW_CHILD, wclass=gdk.INPUT_OUTPUT, event_mask=self.get_events() | gdk.EXPOSURE_MASK | gdk.BUTTON1_MOTION_MASK | gdk.BUTTON_PRESS_MASK | gdk.BUTTON_RELEASE_MASK | gdk.POINTER_MOTION_MASK | gdk.POINTER_MOTION_HINT_MASK) self.window.set_user_data(self) self.style.attach(self.window) self.style.set_background(self.window, gtk.STATE_NORMAL) self.window.move_resize(*self.allocation) self.gc = self.window.new_gc() self.gc_shadow = self.window.new_gc() col = self.gc_shadow.get_colormap().alloc_color( 214 * 257, 214 * 257, 214 * 257) self.gc_shadow.set_foreground(col) self.gc_border = self.window.new_gc() col = self.gc_border.get_colormap().alloc_color(0, 0, 0) self.gc_border.set_foreground(col) self.connect("motion-notify-event", self.cb_motion_notify) self.connect("button-press-event", self.cb_button_press) self.connect("button-release-event", self.cb_button_release) self.connect("scroll-event", self.cb_scroll) self.connect("drag-motion", self.cb_drag_motion) self.connect("drag-leave", self.cb_drag_leave) self.connect("drag-data-delete", self.cb_drag_data_delete) self.connect("drag-end", self.cb_drag_end) self.dnd_helper = ColorDndHelper(self, self.cb_drag_add_color, self.cb_drag_get_color) self.drag_source_unset() #we will manually start drags self.set_tooltip_text( "Click and drag:\n Left: DnD color\n Middle: pan\n\nScroll: pan\nRight click: Remove color" )
def do_realize(self): # Set an internal flag telling that we're realized self.set_flags(self.flags() | gtk.REALIZED) # Create GDK window self.window = gdk.Window(self.get_parent_window(), width=self.allocation.width, height=self.allocation.height, window_type=gdk.WINDOW_CHILD, wclass=gdk.INPUT_OUTPUT, event_mask=self.get_events() | gdk.EXPOSURE_MASK | gdk.BUTTON_PRESS_MASK | gdk.BUTTON_RELEASE_MASK | gdk.BUTTON_MOTION_MASK | gdk.POINTER_MOTION_HINT_MASK | gdk.ENTER_NOTIFY_MASK | gdk.LEAVE_NOTIFY_MASK | gdk.KEY_PRESS_MASK | gdk.SCROLL_MASK) # Connect motion notify event self.connect('motion_notify_event', self._motion_notify_event) # Connect mouse scroll event self.connect("scroll-event", self._mouse_scroll_event) # Make widget capable of grabbing focus self.set_property("can-focus", True) # Check that cairo context can be created if not hasattr(self.window, "cairo_create"): print "no cairo" raise SystemExit # GTK+ stores the widget that owns a gtk.gdk.Window as user data on it. # Custom widgets should do this too self.window.set_user_data(self) # Attach style self.style.attach(self.window) # Set background color if (self._use_widget_bg): self.style.set_background(self.window, gtk.STATE_NORMAL) # Set size and place self.window.move_resize(*self.allocation)
def do_realize(self): '''called when the widget should create its windowing resources''' #self.event_box = gtk.EventBox() #screen = self.event_box.get_screen() #rgba = screen.get_rgba_colormap() #self.event_box.set_colormap(rgba) # First set an internal flag telling that we're realized self.set_flags(self.flags() | gtk.REALIZED) # Create a new gdk.Window which we can draw on. # Also say that we want to receive exposure events # and button click and button press events self.window = gdk.Window( self.get_parent_window(), width=self.width, height=self.height, window_type=gdk.WINDOW_CHILD, wclass=gdk.INPUT_OUTPUT, event_mask=(self.get_events() | gdk.EXPOSURE_MASK | gdk.BUTTON1_MOTION_MASK | gdk.BUTTON_PRESS_MASK | gtk.gdk.POINTER_MOTION_MASK | gtk.gdk.POINTER_MOTION_HINT_MASK)) # Associate the gdk.Window with ourselves, Gtk+ needs a reference # between the widget and the gdk window self.window.set_user_data(self) # Attach the style to the gdk.Window, a style contains colors and # GC contextes used for drawing self.style.attach(self.window) # The default color of the background should be what # the style (theme engine) tells us. self.style.set_background(self.window, gtk.STATE_NORMAL) self.window.move_resize(*self.allocation) # self.style is a gtk.Style object, self.style.fg_gc is # an array or graphic contexts used for drawing the forground # colours self.gc = self.style.fg_gc[gtk.STATE_NORMAL] self.window.set_composited(True) self.connect("motion_notify_event", self.motion_notify_event)
def setup_tray_window(self): display = gdk.display_get_default() root = gdk.get_default_root_window() screen = root.get_screen() if TRANSPARENCY: colormap, visual = screen.get_rgba_colormap( ), screen.get_rgba_visual() if colormap is None or visual is None: log.warn("setup tray: using rgb visual fallback") colormap, visual = screen.get_rgb_colormap( ), screen.get_rgb_visual() assert colormap is not None and visual is not None, "failed to obtain visual or colormap" owner = X11Window.XGetSelectionOwner(SELECTION) log("setup tray: current selection owner=%#x", owner) if owner != XNone: raise Exception("%s already owned by %s" % (SELECTION, owner)) self.tray_window = gdk.Window(root, width=1, height=1, window_type=gdk.WINDOW_TOPLEVEL, event_mask=0, wclass=gdk.INPUT_OUTPUT, title="Xpra-SystemTray", visual=visual, colormap=colormap) xtray = self.tray_window.xid set_tray_visual(self.tray_window, visual) set_tray_orientation(self.tray_window, TRAY_ORIENTATION_HORZ) log("setup tray: tray window %#x", xtray) display.request_selection_notification(SELECTION) try: with xsync: setsel = X11Window.XSetSelectionOwner(xtray, SELECTION) log("setup tray: set selection owner returned %s, owner=%#x", setsel, X11Window.XGetSelectionOwner(SELECTION)) event_mask = StructureNotifyMask log("setup tray: sending client message") X11Window.sendClientMessage(root.xid, root.xid, False, event_mask, "MANAGER", CurrentTime, SELECTION, xtray) owner = X11Window.XGetSelectionOwner(SELECTION) assert owner == xtray, "we failed to get ownership of the tray selection" add_event_receiver(self.tray_window, self) log("setup tray: done") except Exception: log("setup_tray failure", exc_info=True) self.cleanup() raise
def do_realize(self): """ Called when the widget should create all of its windowing resources. We will create our gtk.gdk.Window and load our star pixmap. """ # For some reason pylint says that a VBox doesn't have a set_spacing or pack_start member. # pylint: disable-msg=E1101 # Mapper.do_realize: Class 'style' has no 'attach' member # Mapper.do_realize: Class 'style' has no 'set_background' member # Mapper.do_realize: Class 'style' has no 'fg_gc' member # First set an internal flag telling that we're realized self.set_flags(self.flags() | gtk.REALIZED) # Create a new gdk.Window which we can draw on. # Also say that we want to receive exposure events # and button click and button press events self.window = gdk.Window( self.get_parent_window(), width=self.allocation.width, height=self.allocation.height, window_type=gdk.WINDOW_CHILD, wclass=gdk.INPUT_OUTPUT, event_mask=self.get_events() | gdk.EXPOSURE_MASK | gdk.BUTTON1_MOTION_MASK | gdk.BUTTON_PRESS_MASK | gtk.gdk.POINTER_MOTION_MASK | gtk.gdk.POINTER_MOTION_HINT_MASK) # Associate the gdk.Window with ourselves, Gtk+ needs a reference # between the widget and the gdk window self.window.set_user_data(self) # Attach the style to the gdk.Window, a style contains colors and # GC contextes used for drawing self.style.attach(self.window) # The default color of the background should be what # the style (theme engine) tells us. self.style.set_background(self.window, gtk.STATE_NORMAL) self.window.move_resize(*self.allocation) # self.style is a gtk.Style object, self.style.fg_gc is # an array or graphic contexts used for drawing the forground # colours self.gc = self.style.fg_gc[gtk.STATE_NORMAL]
def do_realize(self): self.set_flags(self.flags() | gtk.REALIZED) self.window = gdk.Window( self.get_parent_window(), width=self.allocation.width, height=self.allocation.height, window_type=gdk.WINDOW_CHILD, wclass=gdk.INPUT_OUTPUT, event_mask=self.get_events() | gdk.EXPOSURE_MASK) self.window.set_user_data(self) self.style.attach(self.window) self.style.set_background(self.window, gtk.STATE_NORMAL) self.window.move_resize(*self.allocation) # initialize resources needed for fast map dragging support self.initGCandBackingPixmap(self.allocation.width, self.allocation.height)
def do_realize(self): gtk.Widget.do_realize(self) self._input_window = gdk.Window( self.get_parent_window(), x=self.allocation.x, y=self.allocation.y, width=self.allocation.width, height=self.allocation.height, window_type=gdk.WINDOW_CHILD, wclass=gdk.INPUT_ONLY, visual=self.get_visual(), colormap=self.get_colormap(), event_mask=(gdk.ENTER_NOTIFY_MASK | gdk.LEAVE_NOTIFY_MASK | gdk.BUTTON_PRESS_MASK | gdk.BUTTON_RELEASE_MASK)) self._input_window.set_user_data(self) self._refresh_icons()
def __create_bin_window(self): self.__bin_window = gdk.Window( self.get_parent_window(), window_type=gdk.WINDOW_CHILD, x=self.allocation.x, y=self.allocation.y, width=self.allocation.width, height=self.allocation.height, colormap=self.get_colormap(), wclass=gdk.INPUT_OUTPUT, visual=self.get_visual(), event_mask=(self.get_events() | gdk.EXPOSURE_MASK | gdk.VISIBILITY_NOTIFY_MASK)) self.__bin_window.set_user_data(self) self.style.set_background(self.__bin_window, gtk.STATE_NORMAL)
def do_realize(self): """ Realize the widget """ self.set_flags(self.flags() | gtk.REALIZED) self.window = gdk.Window(self.get_parent_window(), width=self.allocation.width, height=self.allocation.height, window_type=gdk.WINDOW_CHILD, wclass=gdk.INPUT_OUTPUT, event_mask=self.get_events() | gdk.EXPOSURE_MASK | gdk.BUTTON1_MOTION_MASK | gdk.BUTTON_PRESS_MASK | gdk.BUTTON_RELEASE_MASK | gdk.POINTER_MOTION_MASK | gdk.POINTER_MOTION_HINT_MASK) self.window.set_user_data(self) self.style.attach(self.window) self.style.set_background(self.window, gtk.STATE_NORMAL) self.window.move_resize(*self.allocation) self.gc = self.window.new_gc() self.color_changed(self.color) pbuf = gdk.pixbuf_new_from_file( os.path.join(self.icon_path, "dropper.png")) if pbuf: self.cursor = gdk.Cursor(self.window.get_display(), pbuf, 8, 21) self.set_tooltip_text( 'Click and drag:\n Left: drag-n-drop color\n\nLeft click: add to palette' ) self.connect("motion-notify-event", self.cb_motion_notify) self.connect("button-press-event", self.cb_button_press) self.connect("button-release-event", self.cb_button_release) self.connect("drag-begin", self.cb_drag_begin) self.dnd_helper = ColorDndHelper(self, self.cb_drag_set_color, self.cb_drag_get_color, gtk.gdk.BUTTON1_MASK) self.raw_width = 1 self.raw_height = 1 self.raw_pixbuf = gdk.Pixbuf(gdk.COLORSPACE_RGB, False, 8, self.raw_width, self.raw_height)
def get_group_leader(self, metadata, override_redirect): if not self.supports_group_leader: return None wid = metadata.get("transient-for") if wid > 0: client_window = self._id_to_window.get(wid) if client_window: gdk_window = client_window.gdk_window() if gdk_window: return gdk_window pid = metadata.get("pid", -1) leader_xid = metadata.get("group-leader-xid") leader_wid = metadata.get("group-leader-wid") group_leader_window = self._id_to_window.get(leader_wid) if group_leader_window: #leader is another managed window log("found group leader window %s for wid=%s", group_leader_window, pid) return group_leader_window reftype = "xid" ref = leader_xid if ref is None: reftype = "pid" ref = pid if ref is None: #no reference to use! invent a unique one for this window: #(use its wid) reftype = "wid" ref = wid refkey = "%s:%s" % (reftype, ref) group_leader_window = self._ref_to_group_leader.get(refkey) if group_leader_window: log("found existing group leader window %s using ref=%s", group_leader_window, refkey) return group_leader_window #we need to create one: title = "%s group leader for %s" % (self.session_name or "Xpra", pid) group_leader_window = gdk.Window(None, 1, 1, self.WINDOW_TOPLEVEL, 0, self.INPUT_ONLY, title) self._ref_to_group_leader[refkey] = group_leader_window #spec says window should point to itself group_leader_window.set_group(group_leader_window) log("new hidden group leader window %s for ref=%s", group_leader_window, refkey) self._group_leader_wids.setdefault(group_leader_window, []).append(wid) return group_leader_window
def do_realize(self): self.set_flags(self.flags() | gtk.REALIZED) self.window = gdk.Window(self.get_parent_window(), width=self.allocation.width, height=self.allocation.height, window_type=gdk.WINDOW_CHILD, wclass=gdk.INPUT_OUTPUT, event_mask=self.get_events() | gdk.EXPOSURE_MASK) if not hasattr(self.window, "cairo_create"): self.draw_gc = gdk.GC(self.window, line_width=5, line_style=gdk.SOLID, join_style=gdk.JOIN_ROUND) self.window.set_user_data(self) self.style.attach(self.window) self.style.set_background(self.window, gtk.STATE_NORMAL) self.window.move_resize(*self.allocation)
def do_realize(self): """ Called when the widget should create all of its windowing resources. We will create our gtk.gdk.Window. """ # Set an internal flag telling that we're realized self.set_flags(self.flags() | gtk.REALIZED) # Create a new gdk.Window which we can draw on. # Also say that we want to receive exposure events # and button click and button press events self.window = gdk.Window( self.get_parent_window(), x=self.allocation.x, y=self.allocation.y, width=self.allocation.width, height=self.allocation.height, window_type=gdk.WINDOW_CHILD, wclass=gdk.INPUT_OUTPUT, visual=self.get_visual(), colormap=self.get_colormap(), event_mask=gdk.EXPOSURE_MASK | gdk.BUTTON_PRESS_MASK | gdk.BUTTON_RELEASE_MASK | gdk.POINTER_MOTION_MASK | gdk.POINTER_MOTION_HINT_MASK | gdk.ENTER_NOTIFY_MASK | gdk.LEAVE_NOTIFY_MASK) # Associate the gdk.Window with ourselves, Gtk+ needs a reference # between the widget and the gdk window self.window.set_user_data(self) # Attach the style to the gdk.Window, a style contains colors and # GC contextes used for drawing self.style.attach(self.window) # The default color of the background should be what # the style (theme engine) tells us. self.style.set_background(self.window, gtk.STATE_NORMAL) self.window.move_resize(*self.allocation) # Font font_desc = self.style.font_desc.copy() size = font_desc.get_size() font_desc.set_size(int(size * self.DEFAULT_FONT_SCALE)) self.modify_font(font_desc)
def do_realize(self): assert not (self.flags() & gtk.NO_WINDOW) self.set_flags(self.flags() | gtk.REALIZED) self.window = gdk.Window(self.get_parent_window(), width=self.allocation.width, height=self.allocation.height, window_type=gdk.WINDOW_CHILD, wclass=gdk.INPUT_OUTPUT, event_mask=(self.get_events() | gdk.EXPOSURE_MASK | gdk.BUTTON_PRESS_MASK)) self.window.set_user_data(self) self.style.attach(self.window) self.style.set_background(self.window, gtk.STATE_NORMAL) self._draw_gc = gdk.GC(self.window, line_width=self._selection_width, line_style=gdk.SOLID, foreground=self.style.bg[gtk.STATE_SELECTED])