Skip to content

Commit

Permalink
OR windows, fix button events, disable pings with older servers
Browse files Browse the repository at this point in the history
  • Loading branch information
totaam committed Aug 4, 2024
1 parent b3a8f77 commit 3247d07
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
15 changes: 15 additions & 0 deletions xpra/client/qt6/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def send_hello(self):
"keyboard": True,
"mouse": True,
"encodings": ("rgb32", "rgb24", "png", "jpg", "webp"),
"network-state": False, # tell older server that we don't have "ping"
}
self.send("hello", hello)

Expand Down Expand Up @@ -143,9 +144,17 @@ def _process_encodings(self, packet: tuple):
log(f"server encodings: {packet[1]}")

def _process_new_window(self, packet):
self.new_window(packet)

def _process_new_override_redirect(self, packet):
self.new_window(packet, True)

def new_window(self, packet, is_or=False):
from xpra.client.qt6.window import ClientWindow
wid, x, y, w, h = (int(item) for item in packet[1:6])
metadata = packet[6]
if is_or:
metadata["override-redirect"] = is_or
window = ClientWindow(self, wid, x, y, w, h, metadata)
self.windows[wid] = window
window.show()
Expand All @@ -157,6 +166,12 @@ def _process_lost_window(self, packet):
window.close()
del self.windows[wid]

def _process_raise_window(self, packet):
wid = int(packet[1])
window = self.windows.get(wid)
if window:
window.raise_()

def _process_draw(self, packet):
wid, x, y, width, height, coding, data, packet_sequence, rowstride = packet[1:10]
window = self.windows.get(wid)
Expand Down
8 changes: 6 additions & 2 deletions xpra/client/qt6/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def send_mouse_button_event(self, event, pressed=True):
if button < 0:
return
pos = get_pointer_position(event)
self.send("pointer-button", -1, self.seq, self.wid, button, True, pos, props)
self.send("pointer-button", -1, self.seq, self.wid, button, pressed, pos, props)
self.seq += 1

def mousePressEvent(self, event):
Expand Down Expand Up @@ -105,6 +105,9 @@ def __init__(self, client, wid: int, x: int, y: int, w: int, h: int, metadata: d
self.client = client
self.send = client.send
self.wid = wid
self.metadata = metadata
if metadata.get("override-redirect"):
self.setWindowFlags(Qt.WindowType.FramelessWindowHint | Qt.WindowType.Window | Qt.WindowType.X11BypassWindowManagerHint)
self.setWindowTitle(metadata.get("title", ""))
self.label = DrawingArea(client, wid)
self.label.setSizePolicy(QSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding))
Expand Down Expand Up @@ -133,7 +136,8 @@ def eventFilter(self, object, event):
x = self.pos().x() + self.label.pos().x()
y = self.pos().y() + self.label.pos().y()
w, h = self.get_canvas_size()
self.send("map-window", self.wid, x, y, w, h)
if not self.metadata.get("override-redirect"):
self.send("map-window", self.wid, x, y, w, h)
elif etype == QEvent.Type.Hide:
log("hidden - iconified?")
elif etype == QEvent.Type.Move:
Expand Down

0 comments on commit 3247d07

Please sign in to comment.