PySide2-Frameless-Window 0.5.1__tar.gz → 0.7.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. {pyside2_frameless_window-0.5.1 → pyside2_frameless_window-0.7.0}/PKG-INFO +2 -1
  2. {pyside2_frameless_window-0.5.1 → pyside2_frameless_window-0.7.0}/PySide2_Frameless_Window.egg-info/PKG-INFO +2 -1
  3. {pyside2_frameless_window-0.5.1 → pyside2_frameless_window-0.7.0}/README.md +1 -0
  4. {pyside2_frameless_window-0.5.1 → pyside2_frameless_window-0.7.0}/qframelesswindow/__init__.py +1 -1
  5. {pyside2_frameless_window-0.5.1 → pyside2_frameless_window-0.7.0}/qframelesswindow/linux/window_effect.py +25 -0
  6. {pyside2_frameless_window-0.5.1 → pyside2_frameless_window-0.7.0}/qframelesswindow/mac/window_effect.py +24 -1
  7. {pyside2_frameless_window-0.5.1 → pyside2_frameless_window-0.7.0}/qframelesswindow/titlebar/__init__.py +1 -1
  8. {pyside2_frameless_window-0.5.1 → pyside2_frameless_window-0.7.0}/qframelesswindow/utils/__init__.py +3 -0
  9. {pyside2_frameless_window-0.5.1 → pyside2_frameless_window-0.7.0}/qframelesswindow/utils/linux_utils.py +22 -3
  10. {pyside2_frameless_window-0.5.1 → pyside2_frameless_window-0.7.0}/qframelesswindow/utils/mac_utils.py +27 -2
  11. {pyside2_frameless_window-0.5.1 → pyside2_frameless_window-0.7.0}/qframelesswindow/utils/win32_utils.py +49 -4
  12. {pyside2_frameless_window-0.5.1 → pyside2_frameless_window-0.7.0}/qframelesswindow/windows/__init__.py +7 -1
  13. {pyside2_frameless_window-0.5.1 → pyside2_frameless_window-0.7.0}/qframelesswindow/windows/c_structures.py +8 -7
  14. {pyside2_frameless_window-0.5.1 → pyside2_frameless_window-0.7.0}/qframelesswindow/windows/window_effect.py +43 -3
  15. {pyside2_frameless_window-0.5.1 → pyside2_frameless_window-0.7.0}/setup.py +1 -1
  16. {pyside2_frameless_window-0.5.1 → pyside2_frameless_window-0.7.0}/LICENSE +0 -0
  17. {pyside2_frameless_window-0.5.1 → pyside2_frameless_window-0.7.0}/PySide2_Frameless_Window.egg-info/SOURCES.txt +0 -0
  18. {pyside2_frameless_window-0.5.1 → pyside2_frameless_window-0.7.0}/PySide2_Frameless_Window.egg-info/dependency_links.txt +0 -0
  19. {pyside2_frameless_window-0.5.1 → pyside2_frameless_window-0.7.0}/PySide2_Frameless_Window.egg-info/requires.txt +0 -0
  20. {pyside2_frameless_window-0.5.1 → pyside2_frameless_window-0.7.0}/PySide2_Frameless_Window.egg-info/top_level.txt +0 -0
  21. {pyside2_frameless_window-0.5.1 → pyside2_frameless_window-0.7.0}/qframelesswindow/_rc/__init__.py +0 -0
  22. {pyside2_frameless_window-0.5.1 → pyside2_frameless_window-0.7.0}/qframelesswindow/_rc/resource.py +0 -0
  23. {pyside2_frameless_window-0.5.1 → pyside2_frameless_window-0.7.0}/qframelesswindow/linux/__init__.py +0 -0
  24. {pyside2_frameless_window-0.5.1 → pyside2_frameless_window-0.7.0}/qframelesswindow/mac/__init__.py +0 -0
  25. {pyside2_frameless_window-0.5.1 → pyside2_frameless_window-0.7.0}/qframelesswindow/titlebar/title_bar_buttons.py +0 -0
  26. {pyside2_frameless_window-0.5.1 → pyside2_frameless_window-0.7.0}/qframelesswindow/webengine/__init__.py +0 -0
  27. {pyside2_frameless_window-0.5.1 → pyside2_frameless_window-0.7.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PySide2-Frameless-Window
3
- Version: 0.5.1
3
+ Version: 0.7.0
4
4
  Summary: A cross-platform frameless window based on pyside2, support Win32, Linux and macOS.
5
5
  Home-page: https://github.com/zhiyiYo/PyQt-Frameless-Window/tree/Pyside2
6
6
  Author: zhiyiYo
@@ -53,6 +53,7 @@ Requires-Dist: PyCocoa; platform_system == "Darwin"
53
53
  * Win11 mica blur
54
54
  * Win7 Aero blur
55
55
  * MacOS blur
56
+ * Disable screen capture
56
57
 
57
58
  ## Install
58
59
  To install use pip:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PySide2-Frameless-Window
3
- Version: 0.5.1
3
+ Version: 0.7.0
4
4
  Summary: A cross-platform frameless window based on pyside2, support Win32, Linux and macOS.
5
5
  Home-page: https://github.com/zhiyiYo/PyQt-Frameless-Window/tree/Pyside2
6
6
  Author: zhiyiYo
@@ -53,6 +53,7 @@ Requires-Dist: PyCocoa; platform_system == "Darwin"
53
53
  * Win11 mica blur
54
54
  * Win7 Aero blur
55
55
  * MacOS blur
56
+ * Disable screen capture
56
57
 
57
58
  ## Install
58
59
  To install use pip:
@@ -35,6 +35,7 @@
35
35
  * Win11 mica blur
36
36
  * Win7 Aero blur
37
37
  * MacOS blur
38
+ * Disable screen capture
38
39
 
39
40
  ## Install
40
41
  To install use pip:
@@ -12,7 +12,7 @@ Examples are available at https://github.com/zhiyiYo/PyQt-Frameless-Window/tree/
12
12
  :license: LGPLv3, see LICENSE for more details.
13
13
  """
14
14
 
15
- __version__ = "0.5.1"
15
+ __version__ = "0.7.0"
16
16
  __author__ = "zhiyiYo"
17
17
 
18
18
  import sys
@@ -1,4 +1,6 @@
1
1
  # coding:utf-8
2
+ from PySide2.QtGui import QColor
3
+
2
4
 
3
5
  class LinuxWindowEffect:
4
6
  """ Linux window effect """
@@ -25,6 +27,29 @@ class LinuxWindowEffect:
25
27
  """
26
28
  pass
27
29
 
30
+ def setBorderAccentColor(self, hWnd, color: QColor):
31
+ """ Set the border color of the window
32
+
33
+ Parameters
34
+ ----------
35
+ hWnd: int or `sip.voidptr`
36
+ Window handle
37
+
38
+ color: QColor
39
+ Border Accent color
40
+ """
41
+ pass
42
+
43
+ def removeBorderAccentColor(self, hWnd):
44
+ """ Remove the border color of the window
45
+
46
+ Parameters
47
+ ----------
48
+ hWnd: int or `sip.voidptr`
49
+ Window handle
50
+ """
51
+ pass
52
+
28
53
  def setMicaEffect(self, hWnd, isDarkMode=False, isAlt=False):
29
54
  """ Add mica effect to the window (Win11 only)
30
55
 
@@ -2,7 +2,7 @@
2
2
  import Cocoa
3
3
  from PySide2.QtCore import Qt
4
4
  from PySide2.QtWidgets import QWidget
5
-
5
+ from PySide2.QtGui import QColor
6
6
  from ..utils.mac_utils import getNSWindow
7
7
 
8
8
 
@@ -55,6 +55,29 @@ class MacWindowEffect:
55
55
  content.addSubview_positioned_relativeTo_(
56
56
  visualEffectView, Cocoa.NSWindowBelow, container)
57
57
 
58
+ def setBorderAccentColor(self, hWnd, color: QColor):
59
+ """ Set the border color of the window
60
+
61
+ Parameters
62
+ ----------
63
+ hWnd: int or `sip.voidptr`
64
+ Window handle
65
+
66
+ color: QColor
67
+ Border Accent color
68
+ """
69
+ pass
70
+
71
+ def removeBorderAccentColor(self, hWnd):
72
+ """ Remove the border color of the window
73
+
74
+ Parameters
75
+ ----------
76
+ hWnd: int or `sip.voidptr`
77
+ Window handle
78
+ """
79
+ pass
80
+
58
81
  def setMicaEffect(self, hWnd, isDarkMode=False, isAlt=False):
59
82
  """ Add mica effect to the window (Win11 only)
60
83
 
@@ -131,7 +131,7 @@ class StandardTitleBar(TitleBar):
131
131
  self.titleLabel.setStyleSheet("""
132
132
  QLabel{
133
133
  background: transparent;
134
- font: 13px 'Segoe UI';
134
+ font: 13px 'Segoe UI', 'Microsoft YaHei', 'PingFang SC';
135
135
  padding: 0 4px
136
136
  }
137
137
  """)
@@ -4,12 +4,15 @@ import sys
4
4
  if sys.platform == "win32":
5
5
  from .win32_utils import WindowsMoveResize as MoveResize
6
6
  from .win32_utils import getSystemAccentColor
7
+ from .win32_utils import WindowsScreenCaptureFilter as ScreenCaptureFilter
7
8
  elif sys.platform == "darwin":
8
9
  from .mac_utils import MacMoveResize as MoveResize
9
10
  from .mac_utils import getSystemAccentColor
11
+ from .mac_utils import MacScreenCaptureFilter as ScreenCaptureFilter
10
12
  else:
11
13
  from .linux_utils import LinuxMoveResize as MoveResize
12
14
  from .linux_utils import getSystemAccentColor
15
+ from .linux_utils import LinuxScreenCaptureFilter as ScreenCaptureFilter
13
16
 
14
17
 
15
18
  def startSystemMove(window, globalPos):
@@ -1,7 +1,7 @@
1
1
  # coding: utf-8
2
- from PySide2.QtCore import QEvent, QPoint, Qt
2
+ from PySide2.QtCore import QEvent, QPoint, Qt, QObject
3
3
  from PySide2.QtGui import QMouseEvent, QColor
4
- from PySide2.QtWidgets import QApplication
4
+ from PySide2.QtWidgets import QApplication, QWidget
5
5
 
6
6
 
7
7
  class LinuxMoveResize:
@@ -53,4 +53,23 @@ def getSystemAccentColor():
53
53
  color: QColor
54
54
  accent color
55
55
  """
56
- return QColor()
56
+ return QColor()
57
+
58
+
59
+ class LinuxScreenCaptureFilter(QObject):
60
+ """ Filter for screen capture """
61
+
62
+ def __init__(self, parent: QWidget):
63
+ super().__init__(parent)
64
+ self.setScreenCaptureEnabled(False)
65
+
66
+ def eventFilter(self, watched, event):
67
+ if watched == self.parent():
68
+ if event.type() == QEvent.Type.WinIdChange:
69
+ self.setScreenCaptureEnabled(self.isScreenCaptureEnabled)
70
+
71
+ return super().eventFilter(watched, event)
72
+
73
+ def setScreenCaptureEnabled(self, enabled: bool):
74
+ """ Set screen capture enabled """
75
+ self.isScreenCaptureEnabled = enabled
@@ -3,7 +3,7 @@ from ctypes import c_void_p
3
3
 
4
4
  import Cocoa
5
5
  import objc
6
- from PySide2.QtCore import qVersion
6
+ from PySide2.QtCore import qVersion, QEvent, QObject
7
7
  from PySide2.QtGui import QColor
8
8
  from PySide2.QtWidgets import QWidget
9
9
  from Quartz.CoreGraphics import (CGEventCreateMouseEvent,
@@ -86,4 +86,29 @@ def getSystemAccentColor():
86
86
  r = int(color.redComponent() * 255)
87
87
  g = int(color.greenComponent() * 255)
88
88
  b = int(color.blueComponent() * 255)
89
- return QColor(r, g, b)
89
+ return QColor(r, g, b)
90
+
91
+
92
+ class MacScreenCaptureFilter(QObject):
93
+ """ Filter for screen capture """
94
+
95
+ def __init__(self, parent: QWidget):
96
+ super().__init__(parent)
97
+ self.setScreenCaptureEnabled(False)
98
+
99
+ def eventFilter(self, watched, event):
100
+ if watched == self.parent():
101
+ if event.type() == QEvent.Type.WinIdChange:
102
+ self.setScreenCaptureEnabled(self.isScreenCaptureEnabled)
103
+
104
+ return super().eventFilter(watched, event)
105
+
106
+ def setScreenCaptureEnabled(self, enabled: bool):
107
+ """ Set screen capture enabled """
108
+ self.isScreenCaptureEnabled = enabled
109
+
110
+ nsWindow = getNSWindow(self.parent().winId())
111
+ if nsWindow:
112
+ NSWindowSharingNone = 0
113
+ NSWindowSharingReadOnly = 1
114
+ nsWindow.setSharingType_(NSWindowSharingReadOnly if enabled else NSWindowSharingNone)
@@ -1,16 +1,18 @@
1
1
  # coding:utf-8
2
- from ctypes import Structure, byref, sizeof, windll, c_ulong, c_bool, POINTER
3
- from ctypes.wintypes import DWORD, HWND, LPARAM, RECT, UINT
4
- from platform import platform
5
2
  import sys
6
3
  import warnings
4
+ from ctypes import Structure, byref, sizeof, windll, c_ulong, c_bool, POINTER, WinDLL, wintypes
5
+ from ctypes.wintypes import DWORD, HWND, LPARAM, RECT, UINT
6
+ from platform import platform
7
+ from winreg import OpenKey, HKEY_CURRENT_USER, KEY_READ, QueryValueEx, CloseKey
7
8
 
8
9
  import win32api
9
10
  import win32con
10
11
  import win32gui
11
12
  import win32print
12
- from PySide2.QtCore import QOperatingSystemVersion, QVersionNumber
13
+ from PySide2.QtCore import QOperatingSystemVersion, QObject, QEvent, QVersionNumber
13
14
  from PySide2.QtGui import QGuiApplication, QColor
15
+ from PySide2.QtWidgets import QWidget
14
16
  from PySide2.QtWinExtras import QtWin
15
17
  from win32comext.shell import shellcon
16
18
 
@@ -37,6 +39,21 @@ def getSystemAccentColor():
37
39
  return QColor(color.value)
38
40
 
39
41
 
42
+ def isSystemBorderAccentEnabled():
43
+ """ Check whether the border accent is enabled """
44
+ if not isGreaterEqualWin11():
45
+ return False
46
+
47
+ try:
48
+ key = OpenKey(HKEY_CURRENT_USER, r"SOFTWARE\Microsoft\Windows\DWM", 0, KEY_READ)
49
+ value, _ = QueryValueEx(key, "ColorPrevalence")
50
+ CloseKey(key)
51
+
52
+ return bool(value)
53
+ except:
54
+ return False
55
+
56
+
40
57
  def isMaximized(hWnd):
41
58
  """ Determine whether the window is maximized
42
59
 
@@ -337,3 +354,31 @@ class WindowsMoveResize:
337
354
  window edges
338
355
  """
339
356
  pass
357
+
358
+
359
+ class WindowsScreenCaptureFilter(QObject):
360
+ """ Filter for screen capture """
361
+
362
+ def __init__(self, parent: QWidget):
363
+ super().__init__(parent)
364
+ self.setScreenCaptureEnabled(False)
365
+
366
+ def eventFilter(self, watched, event):
367
+ if watched == self.parent():
368
+ if event.type() == QEvent.Type.WinIdChange:
369
+ self.setScreenCaptureEnabled(self.isScreenCaptureEnabled)
370
+
371
+ return super().eventFilter(watched, event)
372
+
373
+ def setScreenCaptureEnabled(self, enabled: bool):
374
+ """ Set screen capture enabled """
375
+ self.isScreenCaptureEnabled = enabled
376
+ WDA_NONE = 0x00000000
377
+ WDA_EXCLUDEFROMCAPTURE = 0x00000011
378
+
379
+ user32 = WinDLL('user32', use_last_error=True)
380
+ SetWindowDisplayAffinity = user32.SetWindowDisplayAffinity
381
+ SetWindowDisplayAffinity.argtypes = (wintypes.HWND, wintypes.DWORD)
382
+ SetWindowDisplayAffinity.restype = wintypes.BOOL
383
+
384
+ SetWindowDisplayAffinity(int(self.parent().winId()), WDA_NONE if enabled else WDA_EXCLUDEFROMCAPTURE)
@@ -13,7 +13,7 @@ from PySide2.QtWinExtras import QtWin
13
13
 
14
14
  from ..titlebar import TitleBar
15
15
  from ..utils import win32_utils as win_utils
16
- from ..utils.win32_utils import Taskbar
16
+ from ..utils.win32_utils import Taskbar, isSystemBorderAccentEnabled, getSystemAccentColor
17
17
  from .c_structures import LPNCCALCSIZE_PARAMS
18
18
  from .window_effect import WindowsWindowEffect
19
19
 
@@ -182,6 +182,12 @@ class WindowsFramelessWindow(QWidget):
182
182
 
183
183
  result = 0 if not msg.wParam else win32con.WVR_REDRAW
184
184
  return True, result
185
+ elif msg.message == win32con.WM_SETFOCUS and isSystemBorderAccentEnabled():
186
+ self.windowEffect.setBorderAccentColor(self.winId(), getSystemAccentColor())
187
+ return True, 0
188
+ elif msg.message == win32con.WM_KILLFOCUS:
189
+ self.windowEffect.removeBorderAccentColor(self.winId())
190
+ return True, 0
185
191
 
186
192
  return super().nativeEvent(eventType, message)
187
193
 
@@ -94,13 +94,14 @@ class DWMWINDOWATTRIBUTE(Enum):
94
94
  DWMWA_FREEZE_REPRESENTATION = 15
95
95
  DWMWA_PASSIVE_UPDATE_MODE = 16
96
96
  DWMWA_USE_HOSTBACKDROPBRUSH = 17
97
- DWMWA_USE_IMMERSIVE_DARK_MODE = 18
98
- DWMWA_WINDOW_CORNER_PREFERENCE = 19
99
- DWMWA_BORDER_COLOR = 20
100
- DWMWA_CAPTION_COLOR = 21
101
- DWMWA_TEXT_COLOR = 22
102
- DWMWA_VISIBLE_FRAME_BORDER_THICKNESS = 23
103
- DWMWA_LAST = 24
97
+ DWMWA_USE_IMMERSIVE_DARK_MODE = 20
98
+ DWMWA_WINDOW_CORNER_PREFERENCE = 33
99
+ DWMWA_BORDER_COLOR = 34
100
+ DWMWA_CAPTION_COLOR = 35
101
+ DWMWA_TEXT_COLOR = 36
102
+ DWMWA_VISIBLE_FRAME_BORDER_THICKNESS = 37
103
+ DWMWA_SYSTEMBACKDROP_TYPE = 38
104
+ DWMWA_LAST = 39
104
105
 
105
106
 
106
107
  class MARGINS(Structure):
@@ -8,6 +8,7 @@ import win32api
8
8
  import win32con
9
9
  import win32gui
10
10
  from PySide2.QtWinExtras import QtWin
11
+ from PySide2.QtGui import QColor
11
12
 
12
13
  from .c_structures import (ACCENT_POLICY, ACCENT_STATE, DWMNCRENDERINGPOLICY,
13
14
  DWMWINDOWATTRIBUTE, MARGINS,
@@ -78,6 +79,44 @@ class WindowsWindowEffect:
78
79
  self.winCompAttrData.Attribute = WINDOWCOMPOSITIONATTRIB.WCA_ACCENT_POLICY.value
79
80
  self.SetWindowCompositionAttribute(hWnd, pointer(self.winCompAttrData))
80
81
 
82
+ def setBorderAccentColor(self, hWnd, color: QColor):
83
+ """ Set the border color of the window
84
+
85
+ Parameters
86
+ ----------
87
+ hWnd: int or `sip.voidptr`
88
+ Window handle
89
+
90
+ color: QColor
91
+ Border Accent color
92
+ """
93
+ if not isGreaterEqualWin11():
94
+ return
95
+
96
+ hWnd = int(hWnd)
97
+ colorref = DWORD(color.red() | (color.green() << 8) | (color.blue() << 16))
98
+ self.DwmSetWindowAttribute(hWnd,
99
+ DWMWINDOWATTRIBUTE.DWMWA_BORDER_COLOR.value,
100
+ byref(colorref),
101
+ 4)
102
+
103
+ def removeBorderAccentColor(self, hWnd):
104
+ """ Remove the border color of the window
105
+
106
+ Parameters
107
+ ----------
108
+ hWnd: int or `sip.voidptr`
109
+ Window handle
110
+ """
111
+ if not isGreaterEqualWin11():
112
+ return
113
+
114
+ hWnd = int(hWnd)
115
+ self.DwmSetWindowAttribute(hWnd,
116
+ DWMWINDOWATTRIBUTE.DWMWA_BORDER_COLOR.value,
117
+ byref(DWORD(0xFFFFFFFF)),
118
+ 4)
119
+
81
120
  def setMicaEffect(self, hWnd, isDarkMode=False, isAlt=False):
82
121
  """ Add the mica effect to the window (Win11 only)
83
122
 
@@ -97,7 +136,8 @@ class WindowsWindowEffect:
97
136
  return
98
137
 
99
138
  hWnd = int(hWnd)
100
- margins = MARGINS(-1, -1, -1, -1)
139
+ # fix issue #125
140
+ margins = MARGINS(16777215, 16777215, 0, 0)
101
141
  self.DwmExtendFrameIntoClientArea(hWnd, byref(margins))
102
142
 
103
143
  self.winCompAttrData.Attribute = WINDOWCOMPOSITIONATTRIB.WCA_ACCENT_POLICY.value
@@ -111,9 +151,9 @@ class WindowsWindowEffect:
111
151
  if sys.getwindowsversion().build < 22523:
112
152
  self.DwmSetWindowAttribute(hWnd, 1029, byref(c_int(1)), 4)
113
153
  else:
114
- self.DwmSetWindowAttribute(hWnd, 38, byref(c_int(4 if isAlt else 2)), 4)
154
+ self.DwmSetWindowAttribute(hWnd, DWMWINDOWATTRIBUTE.DWMWA_SYSTEMBACKDROP_TYPE.value, byref(c_int(4 if isAlt else 2)), 4)
115
155
 
116
- self.DwmSetWindowAttribute(hWnd, 20, byref(c_int(1*isDarkMode)), 4)
156
+ self.DwmSetWindowAttribute(hWnd, DWMWINDOWATTRIBUTE.DWMWA_USE_IMMERSIVE_DARK_MODE.value, byref(c_int(1*isDarkMode)), 4)
117
157
 
118
158
  def setAeroEffect(self, hWnd):
119
159
  """ Add the aero effect to the window
@@ -6,7 +6,7 @@ with open('README.md', encoding='utf-8') as f:
6
6
 
7
7
  setuptools.setup(
8
8
  name="PySide2-Frameless-Window",
9
- version="0.5.1",
9
+ version="0.7.0",
10
10
  keywords="pyside2 frameless",
11
11
  author="zhiyiYo",
12
12
  author_email="shokokawaii@outlook.com",