PyQt5-Frameless-Window 0.6.0__tar.gz → 0.7.2__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. {pyqt5_frameless_window-0.6.0 → pyqt5_frameless_window-0.7.2}/PKG-INFO +2 -1
  2. {pyqt5_frameless_window-0.6.0 → pyqt5_frameless_window-0.7.2}/PyQt5_Frameless_Window.egg-info/PKG-INFO +2 -1
  3. {pyqt5_frameless_window-0.6.0 → pyqt5_frameless_window-0.7.2}/README.md +1 -0
  4. {pyqt5_frameless_window-0.6.0 → pyqt5_frameless_window-0.7.2}/qframelesswindow/__init__.py +1 -1
  5. {pyqt5_frameless_window-0.6.0 → pyqt5_frameless_window-0.7.2}/qframelesswindow/linux/window_effect.py +25 -0
  6. {pyqt5_frameless_window-0.6.0 → pyqt5_frameless_window-0.7.2}/qframelesswindow/mac/window_effect.py +24 -0
  7. {pyqt5_frameless_window-0.6.0 → pyqt5_frameless_window-0.7.2}/qframelesswindow/titlebar/__init__.py +1 -1
  8. {pyqt5_frameless_window-0.6.0 → pyqt5_frameless_window-0.7.2}/qframelesswindow/utils/win32_utils.py +18 -2
  9. {pyqt5_frameless_window-0.6.0 → pyqt5_frameless_window-0.7.2}/qframelesswindow/windows/__init__.py +16 -10
  10. {pyqt5_frameless_window-0.6.0 → pyqt5_frameless_window-0.7.2}/qframelesswindow/windows/c_structures.py +8 -7
  11. {pyqt5_frameless_window-0.6.0 → pyqt5_frameless_window-0.7.2}/qframelesswindow/windows/window_effect.py +43 -3
  12. {pyqt5_frameless_window-0.6.0 → pyqt5_frameless_window-0.7.2}/setup.py +1 -1
  13. {pyqt5_frameless_window-0.6.0 → pyqt5_frameless_window-0.7.2}/LICENSE +0 -0
  14. {pyqt5_frameless_window-0.6.0 → pyqt5_frameless_window-0.7.2}/PyQt5_Frameless_Window.egg-info/SOURCES.txt +0 -0
  15. {pyqt5_frameless_window-0.6.0 → pyqt5_frameless_window-0.7.2}/PyQt5_Frameless_Window.egg-info/dependency_links.txt +0 -0
  16. {pyqt5_frameless_window-0.6.0 → pyqt5_frameless_window-0.7.2}/PyQt5_Frameless_Window.egg-info/requires.txt +0 -0
  17. {pyqt5_frameless_window-0.6.0 → pyqt5_frameless_window-0.7.2}/PyQt5_Frameless_Window.egg-info/top_level.txt +0 -0
  18. {pyqt5_frameless_window-0.6.0 → pyqt5_frameless_window-0.7.2}/qframelesswindow/_rc/__init__.py +0 -0
  19. {pyqt5_frameless_window-0.6.0 → pyqt5_frameless_window-0.7.2}/qframelesswindow/_rc/resource.py +0 -0
  20. {pyqt5_frameless_window-0.6.0 → pyqt5_frameless_window-0.7.2}/qframelesswindow/linux/__init__.py +0 -0
  21. {pyqt5_frameless_window-0.6.0 → pyqt5_frameless_window-0.7.2}/qframelesswindow/mac/__init__.py +0 -0
  22. {pyqt5_frameless_window-0.6.0 → pyqt5_frameless_window-0.7.2}/qframelesswindow/titlebar/title_bar_buttons.py +0 -0
  23. {pyqt5_frameless_window-0.6.0 → pyqt5_frameless_window-0.7.2}/qframelesswindow/utils/__init__.py +0 -0
  24. {pyqt5_frameless_window-0.6.0 → pyqt5_frameless_window-0.7.2}/qframelesswindow/utils/linux_utils.py +0 -0
  25. {pyqt5_frameless_window-0.6.0 → pyqt5_frameless_window-0.7.2}/qframelesswindow/utils/mac_utils.py +0 -0
  26. {pyqt5_frameless_window-0.6.0 → pyqt5_frameless_window-0.7.2}/qframelesswindow/webengine/__init__.py +0 -0
  27. {pyqt5_frameless_window-0.6.0 → pyqt5_frameless_window-0.7.2}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PyQt5-Frameless-Window
3
- Version: 0.6.0
3
+ Version: 0.7.2
4
4
  Summary: A cross-platform frameless window based on pyqt5, support Win32, X11, Wayland and macOS.
5
5
  Home-page: https://github.com/zhiyiYo/PyQt-Frameless-Window
6
6
  Author: zhiyiYo
@@ -56,6 +56,7 @@ Requires-Dist: PyCocoa; platform_system == "Darwin"
56
56
  * MacOS blur
57
57
  * Disable screen capture
58
58
 
59
+
59
60
  ## Install
60
61
  To install use pip:
61
62
  ```shell
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PyQt5-Frameless-Window
3
- Version: 0.6.0
3
+ Version: 0.7.2
4
4
  Summary: A cross-platform frameless window based on pyqt5, support Win32, X11, Wayland and macOS.
5
5
  Home-page: https://github.com/zhiyiYo/PyQt-Frameless-Window
6
6
  Author: zhiyiYo
@@ -56,6 +56,7 @@ Requires-Dist: PyCocoa; platform_system == "Darwin"
56
56
  * MacOS blur
57
57
  * Disable screen capture
58
58
 
59
+
59
60
  ## Install
60
61
  To install use pip:
61
62
  ```shell
@@ -37,6 +37,7 @@
37
37
  * MacOS blur
38
38
  * Disable screen capture
39
39
 
40
+
40
41
  ## Install
41
42
  To install use pip:
42
43
  ```shell
@@ -12,7 +12,7 @@ Examples are available at https://github.com/zhiyiYo/PyQt-Frameless-Window/tree/
12
12
  :license: GPLv3, see LICENSE for more details.
13
13
  """
14
14
 
15
- __version__ = "0.6.0"
15
+ __version__ = "0.7.2"
16
16
  __author__ = "zhiyiYo"
17
17
 
18
18
  import sys
@@ -1,4 +1,6 @@
1
1
  # coding:utf-8
2
+ from PyQt5.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,6 +2,7 @@
2
2
  import objc
3
3
  import Cocoa
4
4
  from PyQt5.QtWidgets import QMacCocoaViewContainer
5
+ from PyQt5.QtGui import QColor
5
6
  from ..utils.mac_utils import getNSWindow
6
7
 
7
8
  class MacWindowEffect:
@@ -46,6 +47,29 @@ class MacWindowEffect:
46
47
  content.addSubview_positioned_relativeTo_(
47
48
  visualEffectView, Cocoa.NSWindowBelow, container)
48
49
 
50
+ def setBorderAccentColor(self, hWnd, color: QColor):
51
+ """ Set the border color of the window
52
+
53
+ Parameters
54
+ ----------
55
+ hWnd: int or `sip.voidptr`
56
+ Window handle
57
+
58
+ color: QColor
59
+ Border Accent color
60
+ """
61
+ pass
62
+
63
+ def removeBorderAccentColor(self, hWnd):
64
+ """ Remove the border color of the window
65
+
66
+ Parameters
67
+ ----------
68
+ hWnd: int or `sip.voidptr`
69
+ Window handle
70
+ """
71
+ pass
72
+
49
73
  def setMicaEffect(self, hWnd, isDarkMode=False, isAlt=False):
50
74
  """ Add mica effect to the window (Win11 only)
51
75
 
@@ -133,7 +133,7 @@ class StandardTitleBar(TitleBar):
133
133
  self.titleLabel.setStyleSheet("""
134
134
  QLabel{
135
135
  background: transparent;
136
- font: 13px 'Segoe UI';
136
+ font: 13px 'Segoe UI', 'Microsoft YaHei', 'PingFang SC';
137
137
  padding: 0 4px
138
138
  }
139
139
  """)
@@ -1,9 +1,10 @@
1
1
  # coding:utf-8
2
+ import sys
3
+ import warnings
2
4
  from ctypes import Structure, byref, sizeof, windll, c_int, c_ulong, c_bool, POINTER, WinDLL, wintypes
3
5
  from ctypes.wintypes import DWORD, HWND, LPARAM, RECT, UINT
4
6
  from platform import platform
5
- import sys
6
- import warnings
7
+ from winreg import OpenKey, HKEY_CURRENT_USER, KEY_READ, QueryValueEx, CloseKey
7
8
 
8
9
  import win32api
9
10
  import win32con
@@ -37,6 +38,21 @@ def getSystemAccentColor():
37
38
  return QColor(color.value)
38
39
 
39
40
 
41
+ def isSystemBorderAccentEnabled():
42
+ """ Check whether the border accent is enabled """
43
+ if not isGreaterEqualWin11():
44
+ return False
45
+
46
+ try:
47
+ key = OpenKey(HKEY_CURRENT_USER, r"SOFTWARE\Microsoft\Windows\DWM", 0, KEY_READ)
48
+ value, _ = QueryValueEx(key, "ColorPrevalence")
49
+ CloseKey(key)
50
+
51
+ return bool(value)
52
+ except:
53
+ return False
54
+
55
+
40
56
  def isMaximized(hWnd):
41
57
  """ Determine whether the window is maximized
42
58
 
@@ -12,7 +12,7 @@ from PyQt5.QtWidgets import QApplication, QWidget
12
12
 
13
13
  from ..titlebar import TitleBar
14
14
  from ..utils import win32_utils as win_utils
15
- from ..utils.win32_utils import Taskbar
15
+ from ..utils.win32_utils import Taskbar, isSystemBorderAccentEnabled, getSystemAccentColor
16
16
  from .c_structures import LPNCCALCSIZE_PARAMS
17
17
  from .window_effect import WindowsWindowEffect
18
18
 
@@ -117,18 +117,18 @@ class WindowsFramelessWindow(QWidget):
117
117
  return super().nativeEvent(eventType, message)
118
118
 
119
119
  if msg.message == win32con.WM_NCHITTEST and self._isResizeEnabled:
120
- pos = QCursor.pos()
121
- xPos = pos.x() - self.x()
122
- yPos = pos.y() - self.y()
123
- w = self.frameGeometry().width()
124
- h = self.frameGeometry().height()
120
+ xPos, yPos = win32gui.ScreenToClient(msg.hWnd, (msg.lParam & 65535, msg.lParam >> 16))
121
+ clientRect = win32gui.GetClientRect(msg.hWnd)
122
+
123
+ w = clientRect[2] - clientRect[0]
124
+ h = clientRect[3] - clientRect[1]
125
125
 
126
126
  # fixes issue https://github.com/zhiyiYo/PyQt-Frameless-Window/issues/98
127
127
  bw = 0 if win_utils.isMaximized(msg.hWnd) or win_utils.isFullScreen(msg.hWnd) else self.BORDER_WIDTH
128
- lx = xPos < bw
129
- rx = xPos > w - bw
130
- ty = yPos < bw
131
- by = yPos > h - bw
128
+ lx = xPos < bw # left
129
+ rx = xPos > w - bw # right
130
+ ty = yPos < bw # top
131
+ by = yPos > h - bw # bottom
132
132
  if lx and ty:
133
133
  return True, win32con.HTTOPLEFT
134
134
  elif rx and by:
@@ -178,6 +178,12 @@ class WindowsFramelessWindow(QWidget):
178
178
 
179
179
  result = 0 if not msg.wParam else win32con.WVR_REDRAW
180
180
  return True, result
181
+ elif msg.message == win32con.WM_SETFOCUS and isSystemBorderAccentEnabled():
182
+ self.windowEffect.setBorderAccentColor(self.winId(), getSystemAccentColor())
183
+ return True, 0
184
+ elif msg.message == win32con.WM_KILLFOCUS:
185
+ self.windowEffect.removeBorderAccentColor(self.winId())
186
+ return True, 0
181
187
 
182
188
  return super().nativeEvent(eventType, message)
183
189
 
@@ -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):
@@ -7,6 +7,7 @@ from ctypes.wintypes import DWORD, LONG, LPCVOID
7
7
  import win32api
8
8
  import win32con
9
9
  import win32gui
10
+ from PyQt5.QtGui import QColor
10
11
 
11
12
  from .c_structures import (ACCENT_POLICY, ACCENT_STATE, DWMNCRENDERINGPOLICY,
12
13
  DWMWINDOWATTRIBUTE, MARGINS,
@@ -82,6 +83,44 @@ class WindowsWindowEffect:
82
83
  self.winCompAttrData.Attribute = WINDOWCOMPOSITIONATTRIB.WCA_ACCENT_POLICY.value
83
84
  self.SetWindowCompositionAttribute(hWnd, pointer(self.winCompAttrData))
84
85
 
86
+ def setBorderAccentColor(self, hWnd, color: QColor):
87
+ """ Set the border color of the window
88
+
89
+ Parameters
90
+ ----------
91
+ hWnd: int or `sip.voidptr`
92
+ Window handle
93
+
94
+ color: QColor
95
+ Border Accent color
96
+ """
97
+ if not isGreaterEqualWin11():
98
+ return
99
+
100
+ hWnd = int(hWnd)
101
+ colorref = DWORD(color.red() | (color.green() << 8) | (color.blue() << 16))
102
+ self.DwmSetWindowAttribute(hWnd,
103
+ DWMWINDOWATTRIBUTE.DWMWA_BORDER_COLOR.value,
104
+ byref(colorref),
105
+ 4)
106
+
107
+ def removeBorderAccentColor(self, hWnd):
108
+ """ Remove the border color of the window
109
+
110
+ Parameters
111
+ ----------
112
+ hWnd: int or `sip.voidptr`
113
+ Window handle
114
+ """
115
+ if not isGreaterEqualWin11():
116
+ return
117
+
118
+ hWnd = int(hWnd)
119
+ self.DwmSetWindowAttribute(hWnd,
120
+ DWMWINDOWATTRIBUTE.DWMWA_BORDER_COLOR.value,
121
+ byref(DWORD(0xFFFFFFFF)),
122
+ 4)
123
+
85
124
  def setMicaEffect(self, hWnd, isDarkMode=False, isAlt=False):
86
125
  """ Add the mica effect to the window (Win11 only)
87
126
 
@@ -101,7 +140,8 @@ class WindowsWindowEffect:
101
140
  return
102
141
 
103
142
  hWnd = int(hWnd)
104
- margins = MARGINS(-1, -1, -1, -1)
143
+ # fix issue #125
144
+ margins = MARGINS(16777215, 16777215, 0, 0)
105
145
  self.DwmExtendFrameIntoClientArea(hWnd, byref(margins))
106
146
 
107
147
  self.winCompAttrData.Attribute = WINDOWCOMPOSITIONATTRIB.WCA_ACCENT_POLICY.value
@@ -115,9 +155,9 @@ class WindowsWindowEffect:
115
155
  if sys.getwindowsversion().build < 22523:
116
156
  self.DwmSetWindowAttribute(hWnd, 1029, byref(c_int(1)), 4)
117
157
  else:
118
- self.DwmSetWindowAttribute(hWnd, 38, byref(c_int(4 if isAlt else 2)), 4)
158
+ self.DwmSetWindowAttribute(hWnd, DWMWINDOWATTRIBUTE.DWMWA_SYSTEMBACKDROP_TYPE.value, byref(c_int(4 if isAlt else 2)), 4)
119
159
 
120
- self.DwmSetWindowAttribute(hWnd, 20, byref(c_int(1*isDarkMode)), 4)
160
+ self.DwmSetWindowAttribute(hWnd, DWMWINDOWATTRIBUTE.DWMWA_USE_IMMERSIVE_DARK_MODE.value, byref(c_int(1*isDarkMode)), 4)
121
161
 
122
162
  def setAeroEffect(self, hWnd):
123
163
  """ 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="PyQt5-Frameless-Window",
9
- version="0.6.0",
9
+ version="0.7.2",
10
10
  keywords="pyqt frameless",
11
11
  author="zhiyiYo",
12
12
  author_email="shokokawaii@outlook.com",