Skip to content

Commit

Permalink
#826: use ctypes to ensure we call the W version of the SetWindowLong…
Browse files Browse the repository at this point in the history
… and CallWindowProc functions

git-svn-id: https://xpra.org/svn/Xpra/trunk@9137 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Apr 23, 2015
1 parent 0a2fb84 commit 6887349
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/xpra/platform/win32/window_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,16 @@
log = Logger("win32", "window", "util")
vlog = Logger("verbose")

import win32gui, win32con, win32api #@UnresolvedImport
import win32con, win32api #@UnresolvedImport
import ctypes
from ctypes.wintypes import POINT
from ctypes.wintypes import POINT, c_int, c_long
from xpra.platform.win32.wndproc_events import WNDPROC_EVENT_NAMES

#use ctypes to ensure we call the "W" version:
SetWindowLong = ctypes.windll.user32.SetWindowLongW
CallWindowProc = ctypes.windll.user32.CallWindowProcW
WndProcType = ctypes.WINFUNCTYPE(c_int, c_long, c_int, c_int, c_int)


class MINMAXINFO(ctypes.Structure):
_fields_ = [
Expand Down Expand Up @@ -60,7 +65,8 @@ def __init__(self, hwnd):

def setup(self):
assert self._oldwndproc is None
self._oldwndproc = win32gui.SetWindowLong(self._hwnd, win32con.GWL_WNDPROC, self._wndproc)
self._newwndproc = WndProcType(self._wndproc)
self._oldwndproc = SetWindowLong(self._hwnd, win32con.GWL_WNDPROC, self._newwndproc)

def on_getminmaxinfo(self, hwnd, msg, wparam, lparam):
if self.max_size:
Expand All @@ -87,7 +93,7 @@ def cleanup(self, *args):
if not self._oldwndproc or not self._hwnd:
return
try:
win32api.SetWindowLong(self._hwnd, win32con.GWL_WNDPROC, self._oldwndproc)
SetWindowLong(self._hwnd, win32con.GWL_WNDPROC, self._oldwndproc)
self._oldwndproc = None
self._hwnd = None
except:
Expand All @@ -100,6 +106,6 @@ def _wndproc(self, hwnd, msg, wparam, lparam):
if callback:
#run our callback
callback(hwnd, msg, wparam, lparam)
v = win32gui.CallWindowProc(self._oldwndproc, hwnd, msg, wparam, lparam)
v = CallWindowProc(self._oldwndproc, hwnd, msg, wparam, lparam)
vlog("_wndproc%s return value=%s", (hwnd, msg, wparam, lparam), v)
return v

0 comments on commit 6887349

Please sign in to comment.