Skip to content

Commit

Permalink
better native wayland support: paint the widget, not the window
Browse files Browse the repository at this point in the history
git-svn-id: https://xpra.org/svn/Xpra/trunk@26314 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed May 11, 2020
1 parent aef14a5 commit fc71365
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 24 deletions.
12 changes: 8 additions & 4 deletions src/xpra/client/client_window_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,11 @@ def magic_key(self, *args):
if b:
b.toggle()
log("magic_key%s border=%s", args, b)
self.queue_draw_area(0, 0, *self._size)
self.repaint(0, 0, *self._size)

def repaint(self, x, y, w, h):
#self.queue_draw_area(0, 0, *self._size)
raise NotImplementedError("no repaint on %s", type(self))

def refresh_window(self, *args):
log("refresh_window(%s) wid=%s", args, self._id)
Expand Down Expand Up @@ -705,7 +709,7 @@ def after_draw_refresh(self, success, message=""):
if backing.repaint_all or self._client.xscale!=1 or self._client.yscale!=1 or is_Wayland():
#easy: just repaint the whole window:
rw, rh = self.get_size()
self.idle_add(self.queue_draw_area, 0, 0, rw, rh)
self.idle_add(self.repaint, 0, 0, rw, rh)
return
pr = self.pending_refresh
self.pending_refresh = []
Expand All @@ -714,7 +718,7 @@ def after_draw_refresh(self, success, message=""):
#if self.window_offset:
# rx -= self.window_offset[0]
# ry -= self.window_offset[1]
self.idle_add(self.queue_draw_area, rx, ry, rw, rh)
self.idle_add(self.repaint, rx, ry, rw, rh)

def eos(self):
""" Note: this runs from the draw thread (not UI thread) """
Expand All @@ -729,7 +733,7 @@ def spinner(self, _ok):
#with normal windows, we just queue a draw request
#and let the expose event paint the spinner
w, h = self.get_size()
self.queue_draw_area(0, 0, w, h)
self.repaint(0, 0, w, h)

def can_have_spinner(self):
if self._backing is None:
Expand Down
8 changes: 4 additions & 4 deletions src/xpra/client/gl/gtk3/gl_client_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def spinner(self, ok):
log("spinner(%s) backing=%s, paint_screen=%s, paint_spinner=%s", ok, b._backing, b.paint_screen, b.paint_spinner)
if b._backing and b.paint_screen:
w, h = self.get_size()
self.queue_draw_area(0, 0, w, h)
self.repaint(0, 0, w, h)


def remove_backing(self):
Expand All @@ -59,7 +59,7 @@ def magic_key(self, *args):
with b.gl_context():
b.gl_init()
b.present_fbo(0, 0, *b.size)
self.queue_draw_area(0, 0, *self._size)
self.repaint(0, 0, *self._size)
log("gl magic_key%s border=%s, backing=%s", args, self.border, b)


Expand Down Expand Up @@ -93,8 +93,8 @@ def new_backing(self, bw, bh):
#maybe redundant?:
self.apply_geometry_hints(self.geometry_hints)

def _do_draw(self, widget, context):
log("do_draw(%s, %s)", widget, context)
def draw_widget(self, widget, context):
log("draw_widget(%s, %s)", widget, context)
if not self.get_mapped():
return False
backing = self._backing
Expand Down
10 changes: 3 additions & 7 deletions src/xpra/client/gtk3/gtk3_client_window.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This file is part of Xpra.
# Copyright (C) 2011 Serviware (Arthur Huillet, <[email protected]>)
# Copyright (C) 2010-2019 Antoine Martin <[email protected]>
# Copyright (C) 2010-2020 Antoine Martin <[email protected]>
# Copyright (C) 2008, 2010 Nathaniel Smith <[email protected]>
# Xpra is released under the terms of the GNU GPL v2, or, at your option, any
# later version. See the file COPYING for details.
Expand Down Expand Up @@ -40,10 +40,6 @@ class GTK3ClientWindow(GTKClientWindowBase):
OR_TYPE_HINTS = GTK3_OR_TYPE_HINTS
NAME_TO_HINT = WINDOW_NAME_TO_HINT

def init_window(self, metadata):
super().init_window(metadata)
self.connect("draw", self._do_draw)

def get_backing_class(self):
raise NotImplementedError()

Expand Down Expand Up @@ -115,8 +111,8 @@ def apply_geometry_hints(self, hints):
self.set_geometry_hints(self.drawing_area, geom, gdk_hints)


def _do_draw(self, widget, context):
paintlog("do_draw(%s, %s)", widget, context)
def draw_widget(self, widget, context):
paintlog("draw_widget(%s, %s)", widget, context)
if not self.get_mapped():
return False
backing = self._backing
Expand Down
29 changes: 20 additions & 9 deletions src/xpra/client/gtk_base/gtk_client_window_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ def init_window(self, metadata):
Gtk.Window.__init__(self, type = window_type)
self.init_drawing_area()
self.set_decorated(self._is_decorated(metadata))
self.set_app_paintable(True)
self._window_state = {}
self._resize_counter = 0
self._can_set_workspace = HAS_X11_BINDINGS and CAN_SET_WORKSPACE
Expand All @@ -217,11 +216,19 @@ def init_window(self, metadata):

def init_drawing_area(self):
widget = Gtk.DrawingArea()
widget.set_app_paintable(True)
widget.show()
self.drawing_area = widget
self.init_widget_events(widget)
self.add(widget)

def repaint(self, x, y, w, h):
#self.queue_draw_area(0, 0, *self._size)
widget = self.drawing_area
if widget:
widget.queue_draw_area(x, y, w, h)


def init_widget_events(self, widget):
widget.add_events(WINDOW_EVENT_MASK)
def motion(_w, event):
Expand All @@ -240,6 +247,10 @@ def scroll(_w, event):
self._do_scroll_event(event)
return True
widget.connect("scroll-event", scroll)
widget.connect("draw", self.draw_widget)

def draw_widget(self, widget, context):
raise NotImplementedError()


######################################################################
Expand Down Expand Up @@ -561,7 +572,7 @@ def setup_window(self, *args):
if self.window_offset:
x += self.window_offset[0]
y += self.window_offset[1]
if not self.is_OR() and self.get_decorated():
elif self.get_decorated():
#try to adjust for window frame size if we can figure it out:
#Note: we cannot just call self.get_window_frame_size() here because
#the window is not realized yet, and it may take a while for the window manager
Expand Down Expand Up @@ -794,7 +805,7 @@ def update_window_state(self, state_updates):
self.window_offset, (w, h), (ww, wh))
if self._backing.offsets!=(0, 0, 0, 0):
self.center_backing(w, h)
self.queue_draw_area(0, 0, ww, wh)
self.repaint(0, 0, ww, wh)
#decide if this is really an update by comparing with our local state vars:
#(could just be a notification of a state change we already know about)
actual_updates = {}
Expand Down Expand Up @@ -1411,7 +1422,7 @@ def abs_coords(x, y, size):
if value:
#repaint the scale value (in window coordinates):
x, y, w, h = abs_coords(*value[2:5])
self.queue_draw_area(x, y, w, h)
self.repaint(x, y, w, h)
#clear it shortly after:
self.cancel_remove_pointer_overlay_timer()
def remove_pointer_overlay():
Expand All @@ -1420,7 +1431,7 @@ def remove_pointer_overlay():
self.remove_pointer_overlay_timer = self.timeout_add(CURSOR_IDLE_TIMEOUT*1000, remove_pointer_overlay)
if prev:
x, y, w, h = abs_coords(*prev[2:5])
self.queue_draw_area(x, y, w, h)
self.repaint(x, y, w, h)


def _do_button_press_event(self, event):
Expand Down Expand Up @@ -1657,7 +1668,7 @@ def spinner(self, _ok):
#with normal windows, we just queue a draw request
#and let the expose event paint the spinner
w, h = self.get_size()
self.queue_draw_area(0, 0, w, h)
self.repaint(0, 0, w, h)


def do_map_event(self, event):
Expand Down Expand Up @@ -1756,7 +1767,7 @@ def process_configure_event(self, skip_geometry=False):
self._set_backing_size(w, h)
elif self._backing and not self._iconified:
geomlog("configure event: size unchanged, queueing redraw")
self.queue_draw_area(0, 0, w, h)
self.repaint(0, 0, w, h)

def send_configure_event(self, skip_geometry=False):
assert skip_geometry or not self.is_OR()
Expand Down Expand Up @@ -1803,7 +1814,7 @@ def resize(self, w, h, resize_counter=0):
self._resize_counter = resize_counter
if (w, h)==(ww, wh):
self._backing.offsets = 0, 0, 0, 0
self.queue_draw_area(0, 0, w, h)
self.repaint(0, 0, w, h)
return
if not self._fullscreen and not self._maximized:
Gtk.Window.resize(self, w, h)
Expand All @@ -1813,7 +1824,7 @@ def resize(self, w, h, resize_counter=0):
self.center_backing(w, h)
geomlog("backing offsets=%s, window offset=%s", self._backing.offsets, self.window_offset)
self._set_backing_size(w, h)
self.queue_draw_area(0, 0, ww, wh)
self.repaint(0, 0, ww, wh)

def center_backing(self, w, h):
ww, wh = self.get_size()
Expand Down

0 comments on commit fc71365

Please sign in to comment.