mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-04-13 15:57:14 +03:00
Fix running under Wine
This commit is contained in:
parent
de9760c4d2
commit
a6ce9edc1d
17
prefs.py
17
prefs.py
@ -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()),
|
||||
|
14
protocol.py
14
protocol.py
@ -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),
|
||||
|
18
stats.py
18
stats.py
@ -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()),
|
||||
|
Loading…
x
Reference in New Issue
Block a user