Skip to content

Commit 5678dca

Browse files
author
Michael Martin
committed
[win32k]
- Modify how non-queued messages are send that originate from the Win23k subsystem. Non-queued messages must go directly to the windows WNDPROC and not through the message pump (previews ROS behavior). More importantly sending these messages must not cause the sending thread to block waiting for a reply. - Add a messaging handling function that always sends message from Win32k to the windows thread without waiting. This will also allow the implementation of message call back later. - Modify PackParam and UnpackParam to accept a BOOL value to determine whether LParam needs to be allocated from NonPagedPool. Use with new message handling as if message sent to another thread have any pointers they must be allocated from NonPagedPool. - Fixed broken logic in can_active_window function and co_WinPosShowWindow. - Fixed broken logic in co_IntSendActivateMessages. The WM_ACTIVATEAPP message was being sent to every window belonging to the desktop twice. Once with flag saying window was activated and again with deactivated. - These changes should fix bugs reactos#969, reactos#3171, reactos#4501, reactos#4676, reactos#4677, reactos#4948. svn path=/trunk/; revision=47126
1 parent 4b9b7d5 commit 5678dca

File tree

5 files changed

+261
-69
lines changed

5 files changed

+261
-69
lines changed

reactos/subsystems/win32/win32k/include/msgqueue.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#define MSQ_NORMAL 0
77
#define MSQ_ISHOOK 1
88
#define MSQ_ISEVENT 2
9+
#define MSQ_SENTNOWAIT 0x80000000
910

1011
typedef struct _USER_MESSAGE
1112
{
@@ -28,6 +29,7 @@ typedef struct _USER_SENT_MESSAGE
2829
/* entry in the dispatching list of the sender's message queue */
2930
LIST_ENTRY DispatchingListEntry;
3031
INT HookMessage;
32+
BOOL HasPackedLParam;
3133
} USER_SENT_MESSAGE, *PUSER_SENT_MESSAGE;
3234

3335
typedef struct _USER_SENT_MESSAGE_NOTIFY
@@ -184,6 +186,20 @@ co_IntSendMessageTimeout(HWND hWnd,
184186
UINT uFlags,
185187
UINT uTimeout,
186188
ULONG_PTR *uResult);
189+
190+
LRESULT FASTCALL co_IntSendMessageNoWait(HWND hWnd,
191+
UINT Msg,
192+
WPARAM wParam,
193+
LPARAM lParam);
194+
LRESULT FASTCALL
195+
co_IntSendMessageWithCallBack(HWND hWnd,
196+
UINT Msg,
197+
WPARAM wParam,
198+
LPARAM lParam,
199+
SENDASYNCPROC CompletionCallback,
200+
ULONG_PTR CompletionCallbackContext,
201+
ULONG_PTR *uResult);
202+
187203
LRESULT FASTCALL
188204
IntDispatchMessage(MSG* Msg);
189205
BOOL FASTCALL

reactos/subsystems/win32/win32k/ntuser/focus.c

Lines changed: 13 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ co_IntSendDeactivateMessages(HWND hWndPrev, HWND hWnd)
5353
{
5454
if (hWndPrev)
5555
{
56-
co_IntPostOrSendMessage(hWndPrev, WM_NCACTIVATE, FALSE, 0);
57-
co_IntPostOrSendMessage(hWndPrev, WM_ACTIVATE,
56+
co_IntSendMessageNoWait(hWndPrev, WM_NCACTIVATE, FALSE, 0);
57+
co_IntSendMessageNoWait(hWndPrev, WM_ACTIVATE,
5858
MAKEWPARAM(WA_INACTIVE, UserGetWindowLong(hWndPrev, GWL_STYLE, FALSE) & WS_MINIMIZE),
5959
(LPARAM)hWnd);
6060
}
@@ -105,49 +105,29 @@ co_IntSendActivateMessages(HWND hWndPrev, HWND hWnd, BOOL MouseActivate)
105105

106106
if (Window && WindowPrev)
107107
{
108-
PWINDOW_OBJECT cWindow;
109-
HWND *List, *phWnd;
110108
HANDLE OldTID = IntGetWndThreadId(WindowPrev);
111109
HANDLE NewTID = IntGetWndThreadId(Window);
112110

113-
DPRINT("SendActiveMessage Old -> %x, New -> %x\n", OldTID, NewTID);
111+
DPRINT1("SendActiveMessage Old -> %x, New -> %x\n", OldTID, NewTID);
112+
if (Window->Wnd->style & WS_MINIMIZE)
113+
{
114+
DPRINT1("Widow was nminimized\n");
115+
}
114116

115117
if (OldTID != NewTID)
116118
{
117-
List = IntWinListChildren(UserGetWindowObject(IntGetDesktopWindow()));
118-
if (List)
119-
{
120-
for (phWnd = List; *phWnd; ++phWnd)
121-
{
122-
cWindow = UserGetWindowObject(*phWnd);
123-
if (cWindow && (IntGetWndThreadId(cWindow) == OldTID))
124-
{ // FALSE if the window is being deactivated,
125-
// ThreadId that owns the window being activated.
126-
co_IntPostOrSendMessage(*phWnd, WM_ACTIVATEAPP, FALSE, (LPARAM)NewTID);
127-
}
128-
}
129-
for (phWnd = List; *phWnd; ++phWnd)
130-
{
131-
cWindow = UserGetWindowObject(*phWnd);
132-
if (cWindow && (IntGetWndThreadId(cWindow) == NewTID))
133-
{ // TRUE if the window is being activated,
134-
// ThreadId that owns the window being deactivated.
135-
co_IntPostOrSendMessage(*phWnd, WM_ACTIVATEAPP, TRUE, (LPARAM)OldTID);
136-
}
137-
}
138-
ExFreePool(List);
139-
}
119+
co_IntSendMessageNoWait(hWndPrev, WM_ACTIVATEAPP, FALSE, (LPARAM)NewTID);
120+
co_IntSendMessageNoWait(hWnd, WM_ACTIVATEAPP, TRUE, (LPARAM)OldTID);
140121
}
141122
UserDerefObjectCo(WindowPrev); // Now allow the previous window to die.
142123
}
143124

144125
UserDerefObjectCo(Window);
145126

146127
/* FIXME: IntIsWindow */
147-
148-
co_IntPostOrSendMessage(hWnd, WM_NCACTIVATE, (WPARAM)(hWnd == UserGetForegroundWindow()), 0);
128+
co_IntSendMessageNoWait(hWnd, WM_NCACTIVATE, (WPARAM)(hWnd == UserGetForegroundWindow()), 0);
149129
/* FIXME: WA_CLICKACTIVE */
150-
co_IntPostOrSendMessage(hWnd, WM_ACTIVATE,
130+
co_IntSendMessageNoWait(hWnd, WM_ACTIVATE,
151131
MAKEWPARAM(MouseActivate ? WA_CLICKACTIVE : WA_ACTIVE,
152132
UserGetWindowLong(hWnd, GWL_STYLE, FALSE) & WS_MINIMIZE),
153133
(LPARAM)hWndPrev);
@@ -241,7 +221,9 @@ co_IntSetForegroundAndFocusWindow(PWINDOW_OBJECT Window, PWINDOW_OBJECT FocusWin
241221
co_IntSendDeactivateMessages(hWndPrev, hWnd);
242222
co_IntSendKillFocusMessages(hWndFocusPrev, hWndFocus);
243223

224+
244225
IntSetFocusMessageQueue(Window->pti->MessageQueue);
226+
245227
if (Window->pti->MessageQueue)
246228
{
247229
Window->pti->MessageQueue->ActiveWindow = hWnd;

0 commit comments

Comments
 (0)