Skip to content

Commit

Permalink
#4: Fixed window positioning on HiDPI screen
Browse files Browse the repository at this point in the history
  • Loading branch information
kbumsik committed Jun 6, 2018
1 parent 1d43947 commit 0d01fa0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 22 deletions.
19 changes: 8 additions & 11 deletions virtscreen/assets/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
11 changes: 0 additions & 11 deletions virtscreen/virtscreen.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,6 @@ class VNCState:

# Signals
onVirtScreenCreatedChanged = pyqtSignal(bool)
onVirtScreenIndexChanged = pyqtSignal(int)
onVncUsePasswordChanged = pyqtSignal(bool)
onVncStateChanged = pyqtSignal(VNCState)
onIPAddressesChanged = pyqtSignal()
Expand All @@ -411,7 +410,6 @@ def __init__(self, parent=None):
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
Expand Down Expand Up @@ -520,15 +518,6 @@ def ipAddresses(self):
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()
Expand Down

0 comments on commit 0d01fa0

Please sign in to comment.