xpra icon
Bug tracker and wiki

This bug tracker and wiki are being discontinued
please use https://github.com/Xpra-org/xpra instead.


Ticket #972: fullscreen-scaling.patch

File fullscreen-scaling.patch, 5.6 KB (added by Antoine Martin, 5 years ago)

use scaling to fullscreen fixed size windows

  • xpra/client/gtk_base/gtk_client_window_base.py

     
    168168        self.moveresize_timer = None
    169169        self.moveresize_event = None
    170170        self.window_offset = None   #actual vs reported coordinates
     171        self.window_scaling = None
    171172        #add platform hooks
    172173        self.on_realize_cb = {}
    173174        self.connect_after("realize", self.on_realize)
     
    479480                statelog("%s=%s (was %s)", var, value, cur)
    480481        statelog("window_state_updated(..) state updates: %s, actual updates: %s", state_updates, actual_updates)
    481482        self._window_state.update(actual_updates)
     483        if actual_updates.get("fullscreen") is False:
     484            #unfullscreened, re-apply any geometry hints we may have suspended:
     485            self.apply_geometry_hints(self.geometry_hints)
    482486        #iconification is handled a bit differently...
    483487        iconified = actual_updates.get("iconified")
    484488        if iconified is not None:
     
    905909            self.pointer_grab()
    906910
    907911    def toggle_fullscreen(self):
    908         geomlog("toggle_fullscreen()")
     912        geomlog("toggle_fullscreen() geometry hints=%s", self.geometry_hints)
     913        #ie: toggle_fullscreen() geometry hints={'max_height': 1024, 'min_height': 1024, 'base_width': 1280, 'max_width': 1280, 'min_width': 1280, 'base_height': 1024}
     914        minw, minh, maxw, maxh = self.geometry_hints.get("min_width"), self.geometry_hints.get("min_height"), self.geometry_hints.get("max_width"), self.geometry_hints.get("max_height")
     915        fixed_size = minw is not None and minh is not None and minw==maxw and minh==maxh
     916        if fixed_size:
     917            if self._fullscreen:
     918                geomlog("toggle_fullscreen() was fullscreen, going back to fixed size %ix%i", minw, minh)
     919                self.apply_geometry_hints(self.geometry_hints)
     920                self.window_scaling = None
     921                self.unfullscreen()
     922                b = self._backing
     923                if b:
     924                    bw, bh = self._backing.size
     925                    self._set_backing_size(bw, bh)
     926                    self._client.control_refresh(self._id, False, refresh=True)
     927            else:
     928                geomlog("toggle_fullscreen() fixed size %ix%i, scaling to fullscreen", minw, minh)
     929                #suspend geometry hints:
     930                self.apply_geometry_hints({})
     931                b = self._backing
     932                def after_wm_updated():
     933                    self.fullscreen()
     934                    bw, bh = b.size
     935                    screen = self.get_screen()
     936                    sw, sh = screen.get_width(), screen.get_height()
     937                    xscale, yscale = None, None
     938                    if bw!=sw or bh!=sh:
     939                        xscale = float(sw)/bw
     940                        yscale = float(sh)/bh
     941                    self._set_backing_size(sw, sh, xscale, yscale)
     942                    self._client.control_refresh(self._id, False, refresh=True)
     943                #do the rest via idle_add,
     944                #because under X11 the window manager needs to see the new geometry hints first,
     945                #or it will deny the fullscreen request
     946                if b:
     947                    self.idle_add(after_wm_updated)
     948            #don't trigger metadata updates, we know about it already:
     949            self._fullscreen = not self._fullscreen
     950            return
    909951        if self._fullscreen:
    910952            self.unfullscreen()
    911953        else:
     
    11681210    def do_configure_event(self, event):
    11691211        eventslog("%s.do_configure_event(%s) OR=%s, iconified=%s", self, event, self._override_redirect, self._iconified)
    11701212        gtk.Window.do_configure_event(self, event)
    1171         if not self._override_redirect and not self._iconified:
     1213        if not self._override_redirect and not self._iconified and not self._fullscreen:
    11721214            self.process_configure_event()
    11731215
    11741216    def process_configure_event(self, skip_geometry=False):
     
    12211263        geomlog("%s", packet)
    12221264        self.send(*packet)
    12231265
    1224     def _set_backing_size(self, ww, wh):
     1266    def _set_backing_size(self, ww, wh, xscale=None, yscale=None):
    12251267        b = self._backing
     1268        bw, bh = ww, wh
     1269        #window scaling (different from desktop-scaling!)
     1270        if xscale:
     1271            assert yscale
     1272            bw = float(ww)/(xscale or 1)
     1273            bh = float(wh)/(yscale or 1)
     1274            self.window_scaling = xscale, yscale
     1275        else:
     1276            self.window_scaling = None
     1277        sbw, sbh = self._client.cx(bw), self._client.cy(bh)
     1278        geomlog("set_backing_size%s window scaled: %s,%s, client scaled: %s,%s", bw, bh, sbw, sbh)
    12261279        if b:
    1227             b.init(ww, wh, self._client.cx(ww), self._client.cy(wh))
     1280            b.init(ww, wh, sbw, sbh)
    12281281        else:
    1229             self.new_backing(self._client.cx(ww), self._client.cy(wh))
     1282            self.new_backing(sbw, sbh)
    12301283
    12311284    def resize(self, w, h, resize_counter=0):
    12321285        ww, wh = self.get_size()
     
    13311384
    13321385
    13331386    def _pointer(self, x, y):
     1387        mouselog("pointer%s window offset=%s, window scaling=%s", (x, y), self.window_offset, self.window_scaling)
    13341388        if self.window_offset:
    13351389            x -= self.window_offset[0]
    13361390            y -= self.window_offset[1]
     1391        if self.window_scaling:
     1392            xscale, yscale = self.window_scaling
     1393            x /= xscale
     1394            y /= yscale
    13371395        return self._client.cp(x, y)
    13381396
    13391397    def _get_pointer(self, event):