Skip to content

Commit

Permalink
#2141 / #1284 more reliable detection of non-visible areas of the scr…
Browse files Browse the repository at this point in the history
…een, clamp the window to the monitor which already has more pixels than the others

git-svn-id: https://xpra.org/svn/Xpra/trunk@21631 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Feb 11, 2019
1 parent 5a9ea04 commit 3cf0eae
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 30 deletions.
13 changes: 7 additions & 6 deletions src/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -999,7 +999,7 @@ def convert_templates(subdirs=[]):
"xpra/gtk_common/gdk_atoms.c",
"xpra/client/gtk3/cairo_workaround.c",
"xpra/server/cystats.c",
"xpra/server/window/region.c",
"xpra/rectangle.c",
"xpra/server/window/motion.c",
"xpra/server/pam.c",
"etc/xpra/xpra.conf",
Expand Down Expand Up @@ -2030,20 +2030,21 @@ def osx_pkgconfig(*pkgs_options, **ekw):
**pkgconfig(*PYGTK_PACKAGES, ignored_tokens=gtk2_ignored_tokens)
))

O3_pkgconfig = pkgconfig(optimize=3)
toggle_packages(client_ENABLED or server_ENABLED, "xpra.codecs.xor")
if client_ENABLED or server_ENABLED:
cython_add(Extension("xpra.codecs.xor.cyxor",
["xpra/codecs/xor/cyxor.pyx"],
**pkgconfig(optimize=3)))
**O3_pkgconfig))
if client_ENABLED or server_ENABLED or shadow_ENABLED:
cython_add(Extension("xpra.rectangle",
["xpra/rectangle.pyx"],
**O3_pkgconfig))

if server_ENABLED or shadow_ENABLED:
O3_pkgconfig = pkgconfig(optimize=3)
cython_add(Extension("xpra.server.cystats",
["xpra/server/cystats.pyx"],
**O3_pkgconfig))
cython_add(Extension("xpra.server.window.region",
["xpra/server/window/region.pyx"],
**O3_pkgconfig))
cython_add(Extension("xpra.server.window.motion",
["xpra/server/window/motion.pyx"],
**O3_pkgconfig))
Expand Down
2 changes: 1 addition & 1 deletion src/tests/xpra/server/test_region.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import gobject
gobject.threads_init()

from xpra.server.window.region import rectangle, add_rectangle, remove_rectangle, merge_all, contains_rect #@UnresolvedImport (cython)
from xpra.rectangle import rectangle, add_rectangle, remove_rectangle, merge_all, contains_rect #@UnresolvedImport (cython)


#collected with the server "-d encoding"
Expand Down
2 changes: 1 addition & 1 deletion src/unittests/unit/server/video_subregion_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def assertiswin():

def test_cases(self):
from xpra.server.window.video_subregion import scoreinout #, sslog
from xpra.server.window.region import rectangle #@UnresolvedImport
from xpra.rectangle import rectangle #@UnresolvedImport
#sslog.enable_debug()
r = rectangle(35, 435, 194, 132)
score = scoreinout(1200, 1024, r, 1466834, 21874694)
Expand Down
44 changes: 27 additions & 17 deletions src/xpra/client/gtk_base/gtk_client_window_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -620,26 +620,36 @@ def calculate_window_offset(self, wx, wy, ww, wh):
if not monitors:
geomlog("screen %s lacks monitors information: %s", screen0)
return None
distances = {}
geometries = []
def remove_visible(rects):
""" removes any area found on a monitor """
return rects
from xpra.rectangle import rectangle #@UnresolvedImport
wrect = rectangle(wx, wy, ww, wh)
rects = [wrect]
pixels_in_monitor = {}
for i, monitor in enumerate(monitors):
plug_name, x, y, w, h = monitor[:5]
if wx>=x and wx+ww<=x+w and wy+wh<=y+h:
geomlog("window fits in monitor %i: %s", i, plug_name)
new_rects = []
for rect in rects:
new_rects += rect.substract(x, y, w, h)
geomlog("after removing areas visible on %s from %s: %s", plug_name, rects, new_rects)
rects = new_rects
if not rects:
#the whole window is visible
return None
xdists = (wx-x, wx+ww-x, wx-(x+w), wx+ww-(x+w))
ydists = (wy-y, wy+wh-y, wy-(y+h), wy+wh-(y+h))
if wx>=x and wx+ww<x+w:
xdists = [0]
if wy>=y and wy+wh<y+h:
ydists = [0]
distance = min((abs(v) for v in xdists))+min((abs(v) for v in ydists))
geometries.append((x,y,w,h))
distances[distance] = i
#so it doesn't fit... choose the closest monitor and make it fit
geomlog("OR window distances (%s) to (%s): %s", (wx, wy, ww, wh), geometries, distances)
closest = min(distances.keys())
i = distances[closest]
#keep track of how many pixels would be on this monitor:
inter = wrect.intersection(x, y, w, h)
if inter:
pixels_in_monitor[inter.width*inter.height] = i
#if we're here, then some of the window would land on an area
#not show on any monitors
#choose the monitor that had most of the pixels and make it fit:
geomlog("pixels in monitor=%s", pixels_in_monitor)
if not pixels_in_monitor:
i = 0
else:
best = max(pixels_in_monitor.keys())
i = pixels_in_monitor[best]
monitor = monitors[i]
plug_name, x, y, w, h = monitor[:5]
geomlog("calculating OR offset for monitor %i: %s", i, plug_name)
Expand Down
2 changes: 1 addition & 1 deletion src/xpra/platform/darwin/shadow_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def screen_refresh_callback(self, count, rects, info):

def do_screen_refresh(self, rlist):
#TODO: improve damage method to handle lists directly:
from xpra.server.window.region import rectangle #@UnresolvedImport
from xpra.rectangle import rectangle #@UnresolvedImport
model_rects = {}
for model in self._id_to_window.values():
model_rects[model] = rectangle(*model.geometry)
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/xpra/server/window/motion.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ from xpra.log import Logger
log = Logger("encoding", "scroll")

from xpra.buffers.membuf cimport memalign, object_as_buffer, xxh64
from xpra.server.window.region import rectangle
from xpra.rectangle import rectangle


cdef int DEBUG = envbool("XPRA_SCROLL_DEBUG", False)
Expand Down
2 changes: 1 addition & 1 deletion src/xpra/server/window/video_subregion.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from xpra.os_util import monotonic_time
from xpra.util import envint, envbool
from xpra.server.window.region import rectangle, add_rectangle, remove_rectangle, merge_all #@UnresolvedImport
from xpra.rectangle import rectangle, add_rectangle, remove_rectangle, merge_all #@UnresolvedImport
from xpra.log import Logger

sslog = Logger("regiondetect")
Expand Down
2 changes: 1 addition & 1 deletion src/xpra/server/window/window_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from xpra.server.window.batch_config import DamageBatchConfig
from xpra.server.window.batch_delay_calculator import calculate_batch_delay, get_target_speed, get_target_quality
from xpra.server.cystats import time_weighted_average, logp #@UnresolvedImport
from xpra.server.window.region import rectangle, add_rectangle, remove_rectangle, merge_all #@UnresolvedImport
from xpra.rectangle import rectangle, add_rectangle, remove_rectangle, merge_all #@UnresolvedImport
from xpra.server.picture_encode import rgb_encode, webp_encode, mmap_send
from xpra.simple_stats import get_list_stats
from xpra.codecs.xor.cyxor import xor_str #@UnresolvedImport
Expand Down
2 changes: 1 addition & 1 deletion src/xpra/server/window/window_video_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from xpra.net.compression import Compressed, LargeStructure
from xpra.codecs.codec_constants import TransientCodecException, RGB_FORMATS, PIXEL_SUBSAMPLING
from xpra.server.window.window_source import WindowSource, DelayedRegions, STRICT_MODE, AUTO_REFRESH_SPEED, AUTO_REFRESH_QUALITY, MAX_RGB
from xpra.server.window.region import merge_all #@UnresolvedImport
from xpra.rectangle import merge_all #@UnresolvedImport
from xpra.server.window.motion import ScrollData #@UnresolvedImport
from xpra.server.window.video_subregion import VideoSubregion, VIDEO_SUBREGION
from xpra.server.window.video_scoring import get_pipeline_score
Expand Down

0 comments on commit 3cf0eae

Please sign in to comment.