Files
fluent_widgets_pyside6/qfluentwidgets/common/screen.py
2025-08-14 18:45:16 +08:00

25 lines
640 B
Python

from PySide6.QtCore import QPoint, QRect
from PySide6.QtGui import QCursor
from PySide6.QtWidgets import QApplication
def getCurrentScreen():
""" get current screen """
cursorPos = QCursor.pos()
for s in QApplication.screens():
if s.geometry().contains(cursorPos):
return s
return None
def getCurrentScreenGeometry(avaliable=True):
""" get current screen geometry """
screen = getCurrentScreen() or QApplication.primaryScreen()
# this should not happen
if not screen:
return QRect(0, 0, 1920, 1080)
return screen.availableGeometry() if avaliable else screen.geometry()