Fix running under Wine

This commit is contained in:
Jonathan Harris committed 2019-06-19 12:09:26 +01:00
1 parent de9760c4d2
commit a6ce9edc1d
3 files changed
+30 -19

No files matched your search

+10 -7
View File
@@ -52,12 +52,15 @@ elif platform=='win32':
class BROWSEINFO(ctypes.Structure):
_fields_ = [("hwndOwner", HWND), ("pidlRoot", LPVOID), ("pszDisplayName", LPWSTR), ("lpszTitle", LPCWSTR), ("ulFlags", UINT), ("lpfn", BrowseCallbackProc), ("lParam", LPCWSTR), ("iImage", ctypes.c_int)]
GetParent = ctypes.windll.user32.GetParent
GetParent.argtypes = [HWND]
GetWindowRect = ctypes.windll.user32.GetWindowRect
GetWindowRect.argtypes = [HWND, ctypes.POINTER(RECT)]
CalculatePopupWindowPosition = ctypes.windll.user32.CalculatePopupWindowPosition
CalculatePopupWindowPosition.argtypes = [ctypes.POINTER(POINT), ctypes.POINTER(SIZE), UINT, ctypes.POINTER(RECT), ctypes.POINTER(RECT)]
try:
CalculatePopupWindowPosition = ctypes.windll.user32.CalculatePopupWindowPosition
CalculatePopupWindowPosition.argtypes = [ctypes.POINTER(POINT), ctypes.POINTER(SIZE), UINT, ctypes.POINTER(RECT), ctypes.POINTER(RECT)]
GetParent = ctypes.windll.user32.GetParent
GetParent.argtypes = [HWND]
GetWindowRect = ctypes.windll.user32.GetWindowRect
GetWindowRect.argtypes = [HWND, ctypes.POINTER(RECT)]
except: # Not supported under Wine 4.0
CalculatePopupWindowPosition = None
class PreferencesDialog(tk.Toplevel):
@@ -305,7 +308,7 @@ class PreferencesDialog(tk.Toplevel):
self.grab_set()
# Ensure fully on-screen
if platform == 'win32':
if platform == 'win32' and CalculatePopupWindowPosition:
position = RECT()
GetWindowRect(GetParent(self.winfo_id()), position)
if CalculatePopupWindowPosition(POINT(parent.winfo_rootx(), parent.winfo_rooty()),
+10 -4
View File
@@ -8,6 +8,15 @@ import sys
from config import appname
if sys.platform == 'win32':
from ctypes import *
from ctypes.wintypes import *
try:
is_wine = windll.ntdll.wine_get_version
except:
is_wine = False
class GenericProtocolHandler:
def __init__(self):
@@ -62,10 +71,7 @@ if sys.platform == 'darwin' and getattr(sys, 'frozen', False):
protocolhandler.master.after(ProtocolHandler.POLL, protocolhandler.poll)
elif sys.platform == 'win32' and getattr(sys, 'frozen', False):
from ctypes import *
from ctypes.wintypes import *
elif sys.platform == 'win32' and getattr(sys, 'frozen', False) and not is_wine:
class WNDCLASS(Structure):
_fields_ = [('style', UINT),
+10 -8
View File
@@ -19,13 +19,15 @@ import prefs
if platform=='win32':
import ctypes
from ctypes.wintypes import *
GetParent = ctypes.windll.user32.GetParent
GetParent.argtypes = [HWND]
GetWindowRect = ctypes.windll.user32.GetWindowRect
GetWindowRect.argtypes = [HWND, ctypes.POINTER(RECT)]
CalculatePopupWindowPosition = ctypes.windll.user32.CalculatePopupWindowPosition
CalculatePopupWindowPosition.argtypes = [ctypes.POINTER(POINT), ctypes.POINTER(SIZE), UINT, ctypes.POINTER(RECT), ctypes.POINTER(RECT)]
try:
CalculatePopupWindowPosition = ctypes.windll.user32.CalculatePopupWindowPosition
CalculatePopupWindowPosition.argtypes = [ctypes.POINTER(POINT), ctypes.POINTER(SIZE), UINT, ctypes.POINTER(RECT), ctypes.POINTER(RECT)]
GetParent = ctypes.windll.user32.GetParent
GetParent.argtypes = [HWND]
GetWindowRect = ctypes.windll.user32.GetWindowRect
GetWindowRect.argtypes = [HWND, ctypes.POINTER(RECT)]
except: # Not supported under Wine 4.0
CalculatePopupWindowPosition = None
def status(data):
@@ -270,7 +272,7 @@ class StatsResults(tk.Toplevel):
self.grab_set()
# Ensure fully on-screen
if platform == 'win32':
if platform == 'win32' and CalculatePopupWindowPosition:
position = RECT()
GetWindowRect(GetParent(self.winfo_id()), position)
if CalculatePopupWindowPosition(POINT(parent.winfo_rootx(), parent.winfo_rooty()),