xpra icon
Bug tracker and wiki

Ticket #2243: fix-wayland-client-offsets.patch

File fix-wayland-client-offsets.patch, 9.6 KB (added by Antoine Martin, 9 months ago)

we have to use a drawing area to get the correct coordinates

  • xpra/client/client_window_base.py

     
    740740        #overriden in GTKClientWindowBase
    741741        return self._id
    742742
    743     def do_motion_notify_event(self, event):
     743    def _do_motion_notify_event(self, event):
    744744        if self._client.readonly or self._client.server_readonly or not self._client.server_pointer:
    745745            return
    746746        pointer, relative_pointer, modifiers, buttons = self._pointer_modifiers(event)
  • xpra/client/gl/gtk2/gl_client_window.py

     
    4040        self.remove_backing()
    4141        widget = GTK2WindowBase.new_backing(self, bw, bh)
    4242        log("new_backing(%s, %s)=%s", bw, bh, widget)
     43        if self.drawing_area:
     44            self.remove(self.drawing_area)
     45            self.drawing_area = None
     46        self.init_widget_events(widget)
    4347        self.add(widget)
    4448
    4549    def freeze(self):
  • xpra/client/gtk2/gtk2_window_base.py

     
    7272        # see: https://bugs.kde.org/show_bug.cgi?id=274485
    7373        self.set_data("_kde_no_window_grab", 1)
    7474
     75    def init_drawing_area(self):
     76        GTKClientWindowBase.init_drawing_area(self)
     77        self.drawing_area.connect("expose-event", self.do_drawing_area_expose_event)
    7578
     79
    7680    def xget_u32_property(self, target, name):
    7781        try:
    7882            if not HAS_X11_BINDINGS:
     
    116120            event = DrawEvent(area=rect)
    117121            self.do_expose_event(event)
    118122
     123    def do_drawing_area_expose_event(self, drawing_area, event):
     124        self.do_expose_event(event)
     125
    119126    def do_expose_event(self, event):
    120127        #cannot use self
    121128        eventslog("do_expose_event(%s) area=%s", event, event.area)
  • xpra/client/gtk3/client_window.py

     
    6060
    6161    def do_init_window(self, window_type):
    6262        Gtk.Window.__init__(self, type = window_type)
    63         # tell KDE/oxygen not to intercept clicks
    64         # see: https://bugs.kde.org/show_bug.cgi?id=274485
    65         # does not work with gtk3? what the??
    66         # they moved it gobject, then removed it, unbelievable:
    67         # https://bugzilla.gnome.org/show_bug.cgi?id=641944
    68         #self.set_data("_kde_no_window_grab", 1)
    69         def motion(_w, event):
    70             self.do_motion_notify_event(event)
    71             return True
    72         self.connect("motion-notify-event", motion)
    73         def press(_w, event):
    74             self.do_button_press_event(event)
    75             return True
    76         self.connect("button-press-event", press)
    77         def release(_w, event):
    78             self.do_button_release_event(event)
    79             return True
    80         self.connect("button-release-event", release)
    81         def scroll(_w, event):
    82             self.do_scroll_event(event)
    83             return True
    84         self.connect("scroll-event", scroll)
    8563
     64    def init_drawing_area(self):
     65        GTKClientWindowBase.init_drawing_area(self)
     66        self.drawing_area.connect("draw", self.drawing_area_draw)
     67
    8668    def get_backing_class(self):
    8769        return CairoBacking
    8870
     
    10688        return self.get_mapped()
    10789
    10890    def get_window_geometry(self):
    109         gdkwindow = self.get_window()
     91        gdkwindow = self.drawing_area.get_window()
    11092        x, y = gdkwindow.get_origin()[1:]
     93        log.warn("get_window_geometry() origin=%s, size=%s", gdkwindow.get_origin(), self.get_size())
    11194        w, h = self.get_size()
    11295        return (x, y, w, h)
    11396
     
    153136        metalog("apply_geometry_hints(%s) geometry=%s, hints=%s", hints, geom, gdk_hints)
    154137        self.set_geometry_hints(None, geom, gdk_hints)
    155138
     139    def queue_draw_area(self, x, y, width, height):
     140        window = self.get_window()
     141        if not window:
     142            log.warn("Warning: ignoring draw packet,")
     143            log.warn(" received for a window which is not realized yet or gone already")
     144            return
     145        rect = Gdk.Rectangle()
     146        rect.x = x
     147        rect.y = y
     148        rect.width = width
     149        rect.height = height
     150        self.drawing_area.get_window().invalidate_rect(rect, False)
     151        window.invalidate_rect(rect, False)
    156152
    157153    def do_draw(self, context):
     154        paintlog("do_draw(%s)", context)
    158155        Gtk.Window.do_draw(self, context)
    159         paintlog("do_draw(%s)", context)
     156
     157    def drawing_area_draw(self, widget, context):
     158        paintlog("drawing_area_draw(%s, %s)", widget, context)
    160159        backing = self._backing
    161160        if self.get_mapped() and backing:
    162161            self.paint_backing_offset_border(backing, context)
    163162            self.clip_to_backing(backing, context)
    164163            backing.cairo_draw(context)
    165         self.cairo_paint_border(context, None)
    166         if not self._client.server_ok():
    167             self.paint_spinner(context)
     164            #context.set_source_surface(self._backing._backing, 0, 0)
     165            #context.paint()
     166        #self.cairo_paint_border(context, None)
     167        #if not self._client.server_ok():
     168        #    self.paint_spinner(context)
    168169
    169170
    170171GObject.type_register(ClientWindow)
  • xpra/client/gtk_base/gtk_client_window_base.py

     
    208208            window_type = WINDOW_TOPLEVEL
    209209        self.on_realize_cb = {}
    210210        self.do_init_window(window_type)
     211        self.init_drawing_area()
    211212        self.set_decorated(self._is_decorated(metadata))
    212213        self.set_app_paintable(True)
    213214        self._window_state = {}
     
    231232        self.init_focus()
    232233        ClientWindowBase.init_window(self, metadata)
    233234
     235    def init_drawing_area(self):
     236        widget = gtk.DrawingArea()
     237        widget.show()
     238        self.drawing_area = widget
     239        self.init_widget_events(widget)
     240        self.add(widget)
    234241
     242    def init_widget_events(self, widget):
     243        widget.add_events(self.WINDOW_EVENT_MASK)
     244        def motion(_w, event):
     245            self._do_motion_notify_event(event)
     246            return True
     247        widget.connect("motion-notify-event", motion)
     248        def press(_w, event):
     249            log.warn("press: %s", event)
     250            self._do_button_press_event(event)
     251            return True
     252        widget.connect("button-press-event", press)
     253        def release(_w, event):
     254            self._do_button_release_event(event)
     255            return True
     256        widget.connect("button-release-event", release)
     257        def scroll(_w, event):
     258            self._do_scroll_event(event)
     259            return True
     260        widget.connect("scroll-event", scroll)
     261
     262
    235263    ######################################################################
    236264    # drag and drop:
    237265    def init_dragndrop(self):
     
    14161444            self.queue_draw_area(x, y, w, h)
    14171445
    14181446
    1419     def do_button_press_event(self, event):
     1447    def _do_button_press_event(self, event):
    14201448        #gtk.Window.do_button_press_event(self, event)
    14211449        self._button_action(event.button, event, True)
    14221450
    1423     def do_button_release_event(self, event):
     1451    def _do_button_release_event(self, event):
    14241452        #gtk.Window.do_button_release_event(self, event)
    14251453        self._button_action(event.button, event, False)
    14261454
     
    14271455    ######################################################################
    14281456    # pointer motion
    14291457
    1430     def do_motion_notify_event(self, event):
     1458    def _do_motion_notify_event(self, event):
    14311459        #gtk.Window.do_motion_notify_event(self, event)
    14321460        if self.moveresize_event:
    14331461            self.motion_moveresize(event)
    1434         ClientWindowBase.do_motion_notify_event(self, event)
     1462        ClientWindowBase._do_motion_notify_event(self, event)
    14351463
    14361464    def motion_moveresize(self, event):
    14371465        x_root, y_root, direction, button, start_buttons, wx, wy, ww, wh = self.moveresize_event
     
    20382066        return ClientWindowBase.get_mouse_event_wid(self, x, y)
    20392067
    20402068
    2041     def do_scroll_event(self, event):
     2069    def _do_scroll_event(self, event):
    20422070        if self._client.readonly:
    20432071            return
    20442072        button_mapping = GDK_SCROLL_MAP.get(event.direction, -1)
  • xpra/platform/xposix/gui.py

     
    550550        window.connect("configure-event", self.configured)
    551551        self.configured()
    552552        #replace event handlers with XI2 version:
    553         self.do_motion_notify_event = window.do_motion_notify_event
    554         window.do_motion_notify_event = self.noop
    555         window.do_button_press_event = self.noop
    556         window.do_button_release_event = self.noop
    557         window.do_scroll_event = self.noop
     553        self._do_motion_notify_event = window._do_motion_notify_event
     554        window._do_motion_notify_event = self.noop
     555        window._do_button_press_event = self.noop
     556        window._do_button_release_event = self.noop
     557        window._do_scroll_event = self.noop
    558558        window.connect("destroy", self.cleanup)
    559559
    560560    def noop(self, *args):