1
0
Fork 0
mirror of https://github.com/kbumsik/VirtScreen.git synced 2025-02-14 12:21:50 +00:00

#4: Fixed window positioning on HiDPI screen

This commit is contained in:
Bumsik Kim 2018-06-05 21:18:52 -04:00
parent 1d439478bb
commit 0d01fa0816
No known key found for this signature in database
GPG key ID: E31041C8EC5B01C6
2 changed files with 8 additions and 22 deletions

View file

@ -109,17 +109,14 @@ Item {
}
});
// Move window to the corner of the primary display
var primary = backend.primary;
var width = primary.width;
var height = primary.height;
var cursor_x = backend.cursor_x - primary.x_offset;
var cursor_y = backend.cursor_y - primary.y_offset;
var x_mid = width / 2;
var y_mid = height / 2;
var x = width - window.width; //(cursor_x > x_mid)? width - window.width : 0;
var y = (cursor_y > y_mid)? height - window.height : 0;
x += primary.x_offset;
y += primary.y_offset;
var cursor_x = (backend.cursor_x / window.screen.devicePixelRatio) - window.screen.virtualX;
var cursor_y = (backend.cursor_y / window.screen.devicePixelRatio) - window.screen.virtualY;
var x_mid = window.screen.width / 2;
var y_mid = window.screen.height / 2;
var x = window.screen.width - window.width; //(cursor_x > x_mid)? width - window.width : 0;
var y = (cursor_y > y_mid)? window.screen.height - window.height : 0;
x += window.screen.virtualX;
y += window.screen.virtualY;
window.x = x;
window.y = y;
window.show();

View file

@ -395,7 +395,6 @@ class Backend(QObject):
# Signals
onVirtScreenCreatedChanged = pyqtSignal(bool)
onVirtScreenIndexChanged = pyqtSignal(int)
onVncUsePasswordChanged = pyqtSignal(bool)
onVncStateChanged = pyqtSignal(VNCState)
onIPAddressesChanged = pyqtSignal()
@ -411,7 +410,6 @@ class Backend(QObject):
self._vncUsePassword: bool = False
self._vncState: self.VNCState = self.VNCState.OFF
# Primary screen and mouse posistion
self._primaryProp: DisplayProperty
self.vncServer: ProcessProtocol
# Check config file
# and initialize if needed
@ -520,15 +518,6 @@ class Backend(QObject):
if link is not None:
yield link['addr']
@pyqtProperty(DisplayProperty)
def primary(self):
try:
self._primaryProp = DisplayProperty(self.xrandr.get_primary_screen())
except RuntimeError as e:
self.onError.emit(str(e))
return
return self._primaryProp
@pyqtProperty(int)
def cursor_x(self):
cursor = QCursor().pos()