mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-04-13 15:57:14 +03:00
Fix vertical window resize on macOS
Disable zoom button on Windows and macOS.
This commit is contained in:
parent
e11224ea27
commit
33b435e556
@ -156,7 +156,7 @@ class AppWindow:
|
||||
if platform=='darwin':
|
||||
# Can't handle (de)iconify if topmost is set, so suppress iconify button
|
||||
# http://wiki.tcl.tk/13428 and p15 of https://developer.apple.com/legacy/library/documentation/Carbon/Conceptual/HandlingWindowsControls/windowscontrols.pdf
|
||||
root.call('tk::unsupported::MacWindowStyle', 'style', root, 'document', 'closeBox horizontalZoom resizable')
|
||||
root.call('tk::unsupported::MacWindowStyle', 'style', root, 'document', 'closeBox resizable')
|
||||
|
||||
# https://www.tcl.tk/man/tcl/TkCmd/menu.htm
|
||||
self.system_menu = tk.Menu(self.menubar, name='apple')
|
||||
@ -187,6 +187,7 @@ class AppWindow:
|
||||
self.w.createcommand("::tk::mac::ShowPreferences", lambda:prefs.PreferencesDialog(self.w, self.postprefs))
|
||||
self.w.createcommand("::tk::mac::ReopenApplication", self.w.deiconify) # click on app in dock = restore
|
||||
self.w.protocol("WM_DELETE_WINDOW", self.w.withdraw) # close button shouldn't quit app
|
||||
self.w.resizable(tk.FALSE, tk.FALSE) # Can't be only resizable on one axis
|
||||
else:
|
||||
self.file_menu = self.view_menu = tk.Menu(self.menubar, tearoff=tk.FALSE)
|
||||
self.file_menu.add_command(command=lambda:stats.StatsDialog(self))
|
||||
@ -248,6 +249,7 @@ class AppWindow:
|
||||
tk.Label(self.blank_menubar).grid()
|
||||
tk.Label(self.blank_menubar).grid()
|
||||
theme.register_alternate((self.menubar, self.theme_menubar, self.blank_menubar), {'row':0, 'columnspan':2, 'sticky':tk.NSEW})
|
||||
self.w.resizable(tk.TRUE, tk.FALSE)
|
||||
|
||||
# update geometry
|
||||
if config.get('geometry'):
|
||||
@ -267,7 +269,6 @@ class AppWindow:
|
||||
else:
|
||||
self.w.geometry(config.get('geometry'))
|
||||
self.w.attributes('-topmost', config.getint('always_ontop') and 1 or 0)
|
||||
self.w.resizable(tk.TRUE, tk.FALSE)
|
||||
|
||||
theme.register(frame)
|
||||
theme.apply(self.w)
|
||||
@ -310,7 +311,7 @@ class AppWindow:
|
||||
tkMessageBox.showerror(applongname,
|
||||
_('This app requires accurate timestamps.') + '\n' + # Error message shown if system time is wrong
|
||||
(TZ_THRESHOLD < drift < CLOCK_THRESHOLD and
|
||||
_("Check your system's Time Zone setting.") or # Error message shown if system time is wrong
|
||||
_("Check your system's Time Zone setting.") or # Error message shown if system time is wrong
|
||||
_("Check your system's Date and Time settings.")), # Error message shown if system time is wrong
|
||||
parent = self.w)
|
||||
self.w.destroy()
|
||||
|
28
theme.py
28
theme.py
@ -161,40 +161,36 @@ class _Theme:
|
||||
self.active = theme
|
||||
|
||||
if platform == 'darwin':
|
||||
from AppKit import NSApplication, NSAppearance, NSColor
|
||||
from AppKit import NSApplication, NSAppearance, NSMiniaturizableWindowMask, NSResizableWindowMask
|
||||
root.update_idletasks() # need main window to be created
|
||||
appearance = NSAppearance.appearanceNamed_(theme and
|
||||
'NSAppearanceNameVibrantDark' or
|
||||
'NSAppearanceNameAqua')
|
||||
for window in NSApplication.sharedApplication().windows():
|
||||
window.setStyleMask_(window.styleMask() & ~(NSMiniaturizableWindowMask | NSResizableWindowMask)) # disable zoom
|
||||
window.setAppearance_(appearance)
|
||||
|
||||
if not self.minwidth:
|
||||
self.minwidth = root.winfo_width() # Minimum width = width on first creation
|
||||
# resizable(0,0) doesn't do anything on OSX
|
||||
root.minsize(self.minwidth, root.winfo_height())
|
||||
root.maxsize(-1, root.winfo_height())
|
||||
|
||||
elif platform == 'win32':
|
||||
# tk8.5.9/win/tkWinWm.c:342
|
||||
import ctypes
|
||||
GWL_STYLE = -16
|
||||
WS_MAXIMIZEBOX = 0x00010000
|
||||
# tk8.5.9/win/tkWinWm.c:342
|
||||
GWL_EXSTYLE = -20
|
||||
WS_EX_APPWINDOW = 0x00040000
|
||||
WS_EX_LAYERED = 0x00080000
|
||||
GetWindowLongW = ctypes.windll.user32.GetWindowLongW
|
||||
SetWindowLongW = ctypes.windll.user32.SetWindowLongW
|
||||
|
||||
root.overrideredirect(theme and 1 or 0)
|
||||
root.attributes("-transparentcolor", theme > 1 and 'grey4' or '')
|
||||
root.withdraw()
|
||||
root.update_idletasks() # Size and windows styles get recalculated here
|
||||
hwnd = ctypes.windll.user32.GetParent(root.winfo_id())
|
||||
ctypes.windll.user32.SetWindowLongW(hwnd, GWL_EXSTYLE, theme > 1 and WS_EX_APPWINDOW|WS_EX_LAYERED or WS_EX_APPWINDOW) # Add to taskbar
|
||||
SetWindowLongW(hwnd, GWL_STYLE, GetWindowLongW(hwnd, GWL_STYLE) & ~WS_MAXIMIZEBOX) # disable maximize
|
||||
SetWindowLongW(hwnd, GWL_EXSTYLE, theme > 1 and WS_EX_APPWINDOW|WS_EX_LAYERED or WS_EX_APPWINDOW) # Add to taskbar
|
||||
root.deiconify()
|
||||
root.wait_visibility() # need main window to be displayed before returning
|
||||
|
||||
if not self.minwidth:
|
||||
self.minwidth = root.winfo_width() # Minimum width = width on first creation
|
||||
root.minsize(self.minwidth, -1)
|
||||
|
||||
else:
|
||||
root.overrideredirect(theme and 1 or 0)
|
||||
root.withdraw()
|
||||
@ -202,9 +198,9 @@ class _Theme:
|
||||
root.deiconify()
|
||||
root.wait_visibility() # need main window to be displayed before returning
|
||||
|
||||
if not self.minwidth:
|
||||
self.minwidth = root.winfo_width() # Minimum width = width on first creation
|
||||
root.minsize(self.minwidth, -1)
|
||||
if not self.minwidth:
|
||||
self.minwidth = root.winfo_width() # Minimum width = width on first creation
|
||||
root.minsize(self.minwidth, -1)
|
||||
|
||||
# singleton
|
||||
theme = _Theme()
|
||||
|
Loading…
x
Reference in New Issue
Block a user