Skip to content

Commit

Permalink
#3317 forward opaque-region
Browse files Browse the repository at this point in the history
  • Loading branch information
totaam committed Oct 19, 2021
1 parent 48b799d commit 66c4cd3
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 6 deletions.
7 changes: 7 additions & 0 deletions xpra/client/client_window_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def __init__(self, client, group_leader, watcher_pid, wid,
self._skip_taskbar = False
self._iconified = False
self._focused = False
self._opaque_region = ()
self.window_gravity = OVERRIDE_GRAVITY or DEFAULT_GRAVITY
self.border = border
self.cursor_data = None
Expand Down Expand Up @@ -469,6 +470,12 @@ def set_metadata(self, metadata):
self._skip_pager = skip_pager
self.set_skip_pager_hint(skip_pager)

if "opaque-region" in metadata:
opaque_region = metadata.inttupleget("opaque-region", None, 0, 4)
if self._opaque_region!=opaque_region:
self._opaque_region = opaque_region
self.set_opaque_region(opaque_region)

if "workspace" in metadata:
self.set_workspace(metadata.intget("workspace"))

Expand Down
15 changes: 14 additions & 1 deletion xpra/client/gtk_base/gtk_client_window_base.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# This file is part of Xpra.
# Copyright (C) 2011 Serviware (Arthur Huillet, <ahuillet@serviware.com>)
# Copyright (C) 2010-2020 Antoine Martin <antoine@xpra.org>
# Copyright (C) 2010-2021 Antoine Martin <antoine@xpra.org>
# Copyright (C) 2008, 2010 Nathaniel Smith <njs@pobox.com>
# Xpra is released under the terms of the GNU GPL v2, or, at your option, any
# later version. See the file COPYING for details.

import math
import cairo
import os.path
from time import monotonic
from urllib.parse import unquote
Expand Down Expand Up @@ -1137,6 +1138,18 @@ def do_set_fullscreen():
self.set_size_constraints(self.size_constraints, self.max_window_size)
self.when_realized("fullscreen", do_set_fullscreen)

def set_opaque_region(self, region=None):
if region and len(region)==4:
rect = cairo.RectangleInt(*self._client.srect(*region))
v = cairo.Region(rect)
else:
v = None
def do_set_region():
log("set_opaque_region(%s)", v)
self.get_window().set_opaque_region(v)
self.when_realized("set-opaque-region", do_set_region)


def set_xid(self, xid):
if not HAS_X11_BINDINGS:
return
Expand Down
1 change: 1 addition & 0 deletions xpra/server/source/windows_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ def parse_client_caps(self, c):
self.send_bell = c.boolget("bell")
self.system_tray = c.boolget("system_tray")
self.metadata_supported = c.strtupleget("metadata.supported", DEFAULT_METADATA_SUPPORTED)
log("metadata supported=%s", self.metadata_supported)
self.window_frame_sizes = typedict(c.dictget("window.frame_sizes", {}))
self.window_min_size = c.inttupleget("window.min-size", (0, 0))
self.window_max_size = c.inttupleget("window.max-size", (0, 0))
Expand Down
2 changes: 1 addition & 1 deletion xpra/server/window/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def raw():
#the properties below are not actually exported to the client (yet?)
#it was just easier to handle them here
#(convert to a type that can be encoded for xpra info):
if propname in ("state", "protocols"):
if propname in ("state", "protocols", "opaque-region"):
return {propname : tuple(raw() or [])}
if propname == "allowed-actions":
return {propname : tuple(raw())}
Expand Down
4 changes: 3 additions & 1 deletion xpra/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@
"transient-for", "window-type",
"fullscreen", "maximized", "decorations", "skip-taskbar", "skip-pager",
"has-alpha", "override-redirect", "tray", "modal",
"role", "opacity", "xid", "group-leader")
"role", "opacity", "xid", "group-leader",
"opaque-region",
)


#initiate-moveresize X11 constants
Expand Down
19 changes: 16 additions & 3 deletions xpra/x11/models/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@

#these properties are not handled, and we don't want to spam the log file
#whenever an app decides to change them:
PROPERTIES_IGNORED = os.environ.get("XPRA_X11_PROPERTIES_IGNORED", "_NET_WM_OPAQUE_REGION").split(",")
PROPERTIES_IGNORED = [x for x in os.environ.get("XPRA_X11_PROPERTIES_IGNORED", "").split(",") if x]
#make it easier to debug property changes, just add them here:
#ie: {"WM_PROTOCOLS" : ["atom"]}
X11_PROPERTIES_DEBUG = {}
Expand Down Expand Up @@ -176,6 +176,10 @@ class CoreX11WindowModel(WindowModelStub):
"allowed-actions": (GObject.TYPE_PYOBJECT,
"Supported WM actions", "",
GObject.ParamFlags.READWRITE),
#synced to "_NET_WM_OPAQUE_REGION"
"opaque-region": (GObject.TYPE_PYOBJECT,
"Compositor can assume that there is no transparency for this region", "",
GObject.ParamFlags.READWRITE),
}

__common_signals__ = {
Expand Down Expand Up @@ -208,15 +212,18 @@ class CoreX11WindowModel(WindowModelStub):
"title", "role",
"command", "shape",
"class-instance", "protocols",
"opaque-region",
]
#exposed and changing (should be watched for notify signals):
_dynamic_property_names = ["title", "command", "shape", "class-instance", "protocols"]
_dynamic_property_names = ["title", "command", "shape", "class-instance", "protocols", "opaque-region"]
#should not be exported to the clients:
_internal_property_names = ["frame", "allowed-actions"]
_initial_x11_properties = ["_NET_WM_PID", "WM_CLIENT_MACHINE",
#_NET_WM_NAME is redundant, as it calls the same handler as "WM_NAME"
"WM_NAME", "_NET_WM_NAME",
"WM_PROTOCOLS", "WM_CLASS", "WM_WINDOW_ROLE"]
"WM_PROTOCOLS", "WM_CLASS", "WM_WINDOW_ROLE",
"_NET_WM_OPAQUE_REGION",
]
_DEFAULT_NET_WM_ALLOWED_ACTIONS = []
_MODELTYPE = "Core"
_scrub_x11_properties = [
Expand Down Expand Up @@ -606,6 +613,11 @@ def _handle_class_change(self):
metalog("WM_CLASS=%s", class_instance)
self._updateprop("class-instance", class_instance)

def _handle_opaque_region_change(self):
region = tuple(self.prop_get("_NET_WM_OPAQUE_REGION", ["u32"]) or [])
metalog("_NET_WM_OPAQUE_REGION=%s", region)
self._updateprop("opaque-region", region)

#these handlers must not generate X11 errors (must use XSync)
_x11_property_handlers = {
"_NET_WM_PID" : _handle_pid_change,
Expand All @@ -616,6 +628,7 @@ def _handle_class_change(self):
"WM_PROTOCOLS" : _handle_protocols_change,
"WM_COMMAND" : _handle_command_change,
"WM_CLASS" : _handle_class_change,
"_NET_WM_OPAQUE_REGION" : _handle_opaque_region_change,
}


Expand Down

0 comments on commit 66c4cd3

Please sign in to comment.