Skip to content

Commit

Permalink
gtk3 only supports one screen per display
Browse files Browse the repository at this point in the history
git-svn-id: https://xpra.org/svn/Xpra/trunk@19698 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Jun 24, 2018
1 parent c838746 commit 212ea48
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 36 deletions.
2 changes: 1 addition & 1 deletion src/xpra/client/gtk_base/gtk_client_window_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
MOVERESIZE_X11 = envbool("XPRA_MOVERESIZE_X11", POSIX)
CURSOR_IDLE_TIMEOUT = envint("XPRA_CURSOR_IDLE_TIMEOUT", 6)
DISPLAY_HAS_SCREEN_INDEX = POSIX and os.environ.get("DISPLAY", "").split(":")[-1].find(".")>=0
HONOUR_SCREEN_MAPPING = envbool("XPRA_HONOUR_SCREEN_MAPPING", POSIX and not DISPLAY_HAS_SCREEN_INDEX)
HONOUR_SCREEN_MAPPING = envbool("XPRA_HONOUR_SCREEN_MAPPING", POSIX and not DISPLAY_HAS_SCREEN_INDEX) and not is_gtk3()
DRAGNDROP = envbool("XPRA_DRAGNDROP", True)
CLAMP_WINDOW_TO_SCREEN = envbool("XPRA_CLAMP_WINDOW_TO_SCREEN", True)

Expand Down
115 changes: 80 additions & 35 deletions src/xpra/gtk_common/gtk_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -739,56 +739,101 @@ def ys(v):
def swork(*workarea):
return xs(workarea[0]), ys(workarea[1]), xs(workarea[2]), ys(workarea[3])
display = display_get_default()
i=0
screen_sizes = []
n_screens = display.get_n_screens()
screenlog("get_screen_sizes(%f, %f) found %s screens", xscale, yscale, n_screens)
while i<n_screens:
screen = display.get_screen(i)
j = 0
get_n_monitors = getattr(display, "get_n_monitors", None)
if get_n_monitors:
#GTK 3.22: always just one screen
n_monitors = get_n_monitors()
workareas = get_workareas()
if workareas and len(workareas)!=n_monitors:
screenlog(" workareas: %s", workareas)
screenlog(" number of monitors does not match number of workareas!")
workareas = []
monitors = []
workareas = []
#native "get_workareas()" is only valid for a single screen (but describes all the monitors)
#and it is only implemented on win32 right now
#other platforms only implement "get_workarea()" instead, which is reported against the screen
n_monitors = screen.get_n_monitors()
screenlog(" screen %s has %s monitors", i, n_monitors)
if n_screens==1:
workareas = get_workareas()
if workareas and len(workareas)!=n_monitors:
screenlog(" workareas: %s", workareas)
screenlog(" number of monitors does not match number of workareas!")
workareas = []
while j<screen.get_n_monitors():
geom = screen.get_monitor_geometry(j)
plug_name = ""
if hasattr(screen, "get_monitor_plug_name"):
plug_name = screen.get_monitor_plug_name(j) or ""
wmm = -1
if hasattr(screen, "get_monitor_width_mm"):
wmm = screen.get_monitor_width_mm(j)
hmm = -1
if hasattr(screen, "get_monitor_height_mm"):
hmm = screen.get_monitor_height_mm(j)
for j in range(n_monitors):
monitor = display.get_monitor(j)
geom = monitor.get_geometry()
manufacturer, model = monitor.get_manufacturer(), monitor.get_model()
if manufacturer and model:
plug_name = "%s %s" % (manufacturer, model)
elif manufacturer:
plug_name = manufacturer
elif model:
plug_name = model
else:
plug_name = "%i" % j
wmm, hmm = monitor.get_width_mm(), monitor.get_height_mm()
monitor = [plug_name, xs(geom.x), ys(geom.y), xs(geom.width), ys(geom.height), wmm, hmm]
screenlog(" monitor %s: %s", j, monitor)
if workareas:
w = workareas[j]
monitor += list(swork(*w))
monitors.append(tuple(monitor))
j += 1
work_x, work_y, work_width, work_height = swork(0, 0, screen.get_width(), screen.get_height())
screen = display.get_default_screen()
sw, sh = screen.get_width(), screen.get_height()
work_x, work_y, work_width, work_height = swork(0, 0, sw, sh)
workarea = get_workarea()
if workarea:
work_x, work_y, work_width, work_height = swork(*workarea)
screenlog(" workarea=%s", workarea)
item = (screen.make_display_name(), xs(screen.get_width()), ys(screen.get_height()),
item = (screen.make_display_name(), xs(sw), ys(sh),
screen.get_width_mm(), screen.get_height_mm(),
monitors,
work_x, work_y, work_width, work_height)
screenlog(" screen %s: %s", i, item)
screen_sizes.append(item)
i += 1
screenlog(" screen: %s", item)
screen_sizes = [item]
else:
i=0
screen_sizes = []
#GTK2 or GTK3<3.22:
screenlog("get_screen_sizes(%f, %f) found %s screens", xscale, yscale, n_screens)
while i<n_screens:
screen = display.get_screen(i)
j = 0
monitors = []
workareas = []
#native "get_workareas()" is only valid for a single screen (but describes all the monitors)
#and it is only implemented on win32 right now
#other platforms only implement "get_workarea()" instead, which is reported against the screen
n_monitors = screen.get_n_monitors()
screenlog(" screen %s has %s monitors", i, n_monitors)
if n_screens==1:
workareas = get_workareas()
if workareas and len(workareas)!=n_monitors:
screenlog(" workareas: %s", workareas)
screenlog(" number of monitors does not match number of workareas!")
workareas = []
while j<screen.get_n_monitors():
monitor = display.get_monitor(j)
geom = screen.get_monitor_geometry(j)
plug_name = ""
if hasattr(screen, "get_monitor_plug_name"):
plug_name = screen.get_monitor_plug_name(j) or ""
wmm = -1
if hasattr(screen, "get_monitor_width_mm"):
wmm = screen.get_monitor_width_mm(j)
hmm = -1
if hasattr(screen, "get_monitor_height_mm"):
hmm = screen.get_monitor_height_mm(j)
monitor = [plug_name, xs(geom.x), ys(geom.y), xs(geom.width), ys(geom.height), wmm, hmm]
screenlog(" monitor %s: %s", j, monitor)
if workareas:
w = workareas[j]
monitor += list(swork(*w))
monitors.append(tuple(monitor))
j += 1
work_x, work_y, work_width, work_height = swork(0, 0, screen.get_width(), screen.get_height())
workarea = get_workarea()
if workarea:
work_x, work_y, work_width, work_height = swork(*workarea)
screenlog(" workarea=%s", workarea)
item = (screen.make_display_name(), xs(screen.get_width()), ys(screen.get_height()),
screen.get_width_mm(), screen.get_height_mm(),
monitors,
work_x, work_y, work_width, work_height)
screenlog(" screen %s: %s", i, item)
screen_sizes.append(item)
i += 1
return screen_sizes

def get_screen_info(display, screen):
Expand Down

0 comments on commit 212ea48

Please sign in to comment.