Skip to content

Commit

Permalink
#2539 use the headerbar in more cases: we can rely on the drawing_are…
Browse files Browse the repository at this point in the history
…a size_request to enforce the min-size

git-svn-id: https://xpra.org/svn/Xpra/trunk@26860 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Jul 2, 2020
1 parent 931651f commit fc8e984
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/xpra/client/gl/gtk3/gl_client_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from xpra.client.gtk3.gtk3_client_window import GTK3ClientWindow
from xpra.gtk_common.gtk_util import set_visual
from xpra.util import typedict
from xpra.log import Logger

log = Logger("opengl", "window")
Expand Down Expand Up @@ -91,6 +92,11 @@ def new_backing(self, bw, bh):
set_visual(widget, self._has_alpha)
widget.show()
self.init_widget_events(widget)
if self.drawing_area and self.size_constraints:
#apply min size to the drawing_area:
thints = typedict(self.size_constraints)
minsize = thints.intpair("minimum-size", (0, 0))
self.drawing_area.set_size_request(*minsize)
self.add(widget)
self.drawing_area = widget
#maybe redundant?:
Expand Down
19 changes: 18 additions & 1 deletion src/xpra/client/gtk3/gtk3_client_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,16 @@ def can_use_header_bar(self, metadata):
return False
if hbl in TRUE_OPTIONS:
sc = metadata.dictget("size-constraints")
return sc is None
if sc is None:
return True
tsc = typedict(sc)
mins = tsc.intpair("minimum-size")
maxs = tsc.intpair("maximum-size")
if maxs and maxs!=(0, 0) and maxs!=mins:
return False
if tsc.intpair("increment", (0, 0))!=(0, 0):
return False
return True
if hbl=="force":
return True
return False
Expand Down Expand Up @@ -175,6 +184,14 @@ def apply_geometry_hints(self, hints):
"min_aspect_ratio" : "min_aspect",
"max_aspect_ratio" : "max_aspect",
}
thints = typedict(hints)
if self.drawing_area:
#apply min size to the drawing_area:
#(for CSD mode, ie: headerbar)
minw = thints.intget("min_width", 0)
minh = thints.intget("min_width", 0)
self.drawing_area.set_size_request(minw, minh)

geom = Gdk.Geometry()
mask = 0
for k,v in hints.items():
Expand Down
6 changes: 6 additions & 0 deletions src/xpra/client/gtk_base/gtk_client_window_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ def init_window(self, metadata):
def init_drawing_area(self):
widget = Gtk.DrawingArea()
widget.set_app_paintable(True)
widget.set_size_request(*self._size)
widget.show()
self.drawing_area = widget
self.init_widget_events(widget)
Expand Down Expand Up @@ -1687,6 +1688,11 @@ def do_map_event(self, event):
if self._iconified:
self.deiconify()
self.process_map_event()
#use the drawing area to enforce the minimum size:
#(as this also honoured correctly with CSD,
# whereas set_geometry_hints is not..)
minw, minh = self.size_constraints.intpair("minimum-size", (0, 0))
self.drawing_area.set_size_request(minw, minh)

def process_map_event(self):
x, y, w, h = self.get_drawing_area_geometry()
Expand Down

0 comments on commit fc8e984

Please sign in to comment.