mirror of
https://github.com/kbumsik/VirtScreen.git
synced 2025-03-09 15:40:18 +00:00
#4: Fixed window positioning on HiDPI screen
This commit is contained in:
parent
1d439478bb
commit
0d01fa0816
2 changed files with 8 additions and 22 deletions
|
@ -109,17 +109,14 @@ Item {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// Move window to the corner of the primary display
|
// Move window to the corner of the primary display
|
||||||
var primary = backend.primary;
|
var cursor_x = (backend.cursor_x / window.screen.devicePixelRatio) - window.screen.virtualX;
|
||||||
var width = primary.width;
|
var cursor_y = (backend.cursor_y / window.screen.devicePixelRatio) - window.screen.virtualY;
|
||||||
var height = primary.height;
|
var x_mid = window.screen.width / 2;
|
||||||
var cursor_x = backend.cursor_x - primary.x_offset;
|
var y_mid = window.screen.height / 2;
|
||||||
var cursor_y = backend.cursor_y - primary.y_offset;
|
var x = window.screen.width - window.width; //(cursor_x > x_mid)? width - window.width : 0;
|
||||||
var x_mid = width / 2;
|
var y = (cursor_y > y_mid)? window.screen.height - window.height : 0;
|
||||||
var y_mid = height / 2;
|
x += window.screen.virtualX;
|
||||||
var x = width - window.width; //(cursor_x > x_mid)? width - window.width : 0;
|
y += window.screen.virtualY;
|
||||||
var y = (cursor_y > y_mid)? height - window.height : 0;
|
|
||||||
x += primary.x_offset;
|
|
||||||
y += primary.y_offset;
|
|
||||||
window.x = x;
|
window.x = x;
|
||||||
window.y = y;
|
window.y = y;
|
||||||
window.show();
|
window.show();
|
||||||
|
|
|
@ -395,7 +395,6 @@ class Backend(QObject):
|
||||||
|
|
||||||
# Signals
|
# Signals
|
||||||
onVirtScreenCreatedChanged = pyqtSignal(bool)
|
onVirtScreenCreatedChanged = pyqtSignal(bool)
|
||||||
onVirtScreenIndexChanged = pyqtSignal(int)
|
|
||||||
onVncUsePasswordChanged = pyqtSignal(bool)
|
onVncUsePasswordChanged = pyqtSignal(bool)
|
||||||
onVncStateChanged = pyqtSignal(VNCState)
|
onVncStateChanged = pyqtSignal(VNCState)
|
||||||
onIPAddressesChanged = pyqtSignal()
|
onIPAddressesChanged = pyqtSignal()
|
||||||
|
@ -411,7 +410,6 @@ class Backend(QObject):
|
||||||
self._vncUsePassword: bool = False
|
self._vncUsePassword: bool = False
|
||||||
self._vncState: self.VNCState = self.VNCState.OFF
|
self._vncState: self.VNCState = self.VNCState.OFF
|
||||||
# Primary screen and mouse posistion
|
# Primary screen and mouse posistion
|
||||||
self._primaryProp: DisplayProperty
|
|
||||||
self.vncServer: ProcessProtocol
|
self.vncServer: ProcessProtocol
|
||||||
# Check config file
|
# Check config file
|
||||||
# and initialize if needed
|
# and initialize if needed
|
||||||
|
@ -520,15 +518,6 @@ class Backend(QObject):
|
||||||
if link is not None:
|
if link is not None:
|
||||||
yield link['addr']
|
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)
|
@pyqtProperty(int)
|
||||||
def cursor_x(self):
|
def cursor_x(self):
|
||||||
cursor = QCursor().pos()
|
cursor = QCursor().pos()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue