Coverage for /home/antoine/projects/xpra-git/dist/python3/lib64/python/xpra/client/client_widget_base.py : 78%
Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1# This file is part of Xpra.
2# Copyright (C) 2011 Serviware (Arthur Huillet, <ahuillet@serviware.com>)
3# Copyright (C) 2010-2016 Antoine Martin <antoine@xpra.org>
4# Copyright (C) 2008, 2010 Nathaniel Smith <njs@pobox.com>
5# Xpra is released under the terms of the GNU GPL v2, or, at your option, any
6# later version. See the file COPYING for details.
8#pretend to draw the windows, but don't actually do anything
9from xpra.util import envbool
10from xpra.log import Logger
12log = Logger("window")
13USE_FAKE_BACKING = envbool("XPRA_USE_FAKE_BACKING", False)
16class ClientWidgetBase:
18 def __init__(self, client, watcher_pid, wid, has_alpha):
19 self._id = wid
20 self.watcher_pid = watcher_pid
21 #gobject-like scheduler:
22 self.source_remove = client.source_remove
23 self.idle_add = client.idle_add
24 self.timeout_add = client.timeout_add
25 #tells us if the server-side window has an alpha channel
26 #(whether we are capable of rendering it is down the backing)
27 self._has_alpha = has_alpha
28 #tells us if this window instance can paint with alpha
29 self._window_alpha = False
30 self._client = client
31 self._current_icon = None
32 self._backing = None
33 self.pixel_depth = 24
35 def get_info(self):
36 info = {
37 "has-alpha" : self._has_alpha,
38 "window-alpha" : self._window_alpha,
39 "pixel-depth" : self.pixel_depth,
40 }
41 b = self._backing
42 if b:
43 info["backing"] = b.get_info()
44 return info
46 def make_new_backing(self, backing_class, ww, wh, bw, bh):
47 #size of the backing (same as server window source):
48 bw = max(1, bw)
49 bh = max(1, bh)
50 #actual size of window (may be different when scaling):
51 ww = max(1, ww)
52 wh = max(1, wh)
53 if ww>=32768 or wh>=32768:
54 log.warn("Warning: invalid window dimensions %ix%i", ww, wh)
55 backing = self._backing
56 if backing is None:
57 bc = backing_class
58 if USE_FAKE_BACKING:
59 from xpra.client.fake_window_backing import FakeBacking
60 bc = FakeBacking
61 log("make_new_backing%s effective backing class=%s, server alpha=%s, window alpha=%s",
62 (backing_class, ww, wh, ww, wh), bc, self._has_alpha, self._window_alpha)
63 backing = bc(self._id, self._window_alpha, self.pixel_depth)
64 if self._client.mmap_enabled:
65 backing.enable_mmap(self._client.mmap)
66 backing.init(ww, wh, bw, bh)
67 return backing
69 def freeze(self):
70 pass
72 def unfreeze(self):
73 pass
76 def workspace_changed(self): # pragma: no cover
77 pass
79 def set_cursor_data(self, cursor_data): # pragma: no cover
80 pass
82 def new_backing(self, _w, _h): # pragma: no cover
83 raise NotImplementedError("override me!")
85 def is_OR(self): # pragma: no cover
86 return False
88 def is_tray(self): # pragma: no cover
89 return False
91 def is_GL(self): # pragma: no cover
92 return False