Dmitry Timoshkov : user32: Reimplement IsHungAppWindow.

Alexandre Julliard julliard at winehq.org
Fri Dec 28 07:38:44 CST 2007


Module: wine
Branch: master
Commit: e735e199ad52314cf6fd9094cbc626dfb8782ded
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=e735e199ad52314cf6fd9094cbc626dfb8782ded

Author: Dmitry Timoshkov <dmitry at codeweavers.com>
Date:   Fri Dec 28 10:59:13 2007 +0800

user32: Reimplement IsHungAppWindow.

---

 dlls/user32/message.c          |   11 +++++++++--
 include/wine/server_protocol.h |   18 +++++++++++++++++-
 server/protocol.def            |    8 ++++++++
 server/queue.c                 |   16 ++++++++++++++++
 server/request.h               |    2 ++
 server/trace.c                 |   13 +++++++++++++
 6 files changed, 65 insertions(+), 3 deletions(-)

diff --git a/dlls/user32/message.c b/dlls/user32/message.c
index d3f4a3a..67bf10e 100644
--- a/dlls/user32/message.c
+++ b/dlls/user32/message.c
@@ -3556,6 +3556,13 @@ BOOL WINAPI GetGUIThreadInfo( DWORD id, GUITHREADINFO *info )
  */
 BOOL WINAPI IsHungAppWindow( HWND hWnd )
 {
-    DWORD_PTR dwResult;
-    return !SendMessageTimeoutA(hWnd, WM_NULL, 0, 0, SMTO_ABORTIFHUNG, 5000, &dwResult);
+    BOOL ret;
+
+    SERVER_START_REQ( is_window_hung )
+    {
+        req->win = hWnd;
+        ret = !wine_server_call_err( req ) && reply->is_hung;
+    }
+    SERVER_END_REQ;
+    return ret;
 }
diff --git a/include/wine/server_protocol.h b/include/wine/server_protocol.h
index fea45f8..798fda5 100644
--- a/include/wine/server_protocol.h
+++ b/include/wine/server_protocol.h
@@ -2597,6 +2597,19 @@ struct kill_win_timer_reply
 
 
 
+struct is_window_hung_request
+{
+    struct request_header __header;
+    user_handle_t   win;
+};
+struct is_window_hung_reply
+{
+    struct reply_header __header;
+    int is_hung;
+};
+
+
+
 struct get_serial_info_request
 {
     struct request_header __header;
@@ -4382,6 +4395,7 @@ enum request
     REQ_get_message_reply,
     REQ_set_win_timer,
     REQ_kill_win_timer,
+    REQ_is_window_hung,
     REQ_get_serial_info,
     REQ_set_serial_info,
     REQ_register_async,
@@ -4620,6 +4634,7 @@ union generic_request
     struct get_message_reply_request get_message_reply_request;
     struct set_win_timer_request set_win_timer_request;
     struct kill_win_timer_request kill_win_timer_request;
+    struct is_window_hung_request is_window_hung_request;
     struct get_serial_info_request get_serial_info_request;
     struct set_serial_info_request set_serial_info_request;
     struct register_async_request register_async_request;
@@ -4856,6 +4871,7 @@ union generic_reply
     struct get_message_reply_reply get_message_reply_reply;
     struct set_win_timer_reply set_win_timer_reply;
     struct kill_win_timer_reply kill_win_timer_reply;
+    struct is_window_hung_reply is_window_hung_reply;
     struct get_serial_info_reply get_serial_info_reply;
     struct set_serial_info_reply set_serial_info_reply;
     struct register_async_reply register_async_reply;
@@ -4960,6 +4976,6 @@ union generic_reply
     struct add_fd_completion_reply add_fd_completion_reply;
 };
 
-#define SERVER_PROTOCOL_VERSION 334
+#define SERVER_PROTOCOL_VERSION 335
 
 #endif /* __WINE_WINE_SERVER_PROTOCOL_H */
diff --git a/server/protocol.def b/server/protocol.def
index aa10f89..bfd7242 100644
--- a/server/protocol.def
+++ b/server/protocol.def
@@ -1925,6 +1925,14 @@ enum message_type
 @END
 
 
+/* check if the thread owning the window is hung */
+ at REQ(is_window_hung)
+    user_handle_t   win;       /* window handle */
+ at REPLY
+    int is_hung;
+ at END
+
+
 /* Retrieve info about a serial port */
 @REQ(get_serial_info)
     obj_handle_t handle;       /* handle to comm port */
diff --git a/server/queue.c b/server/queue.c
index d837e84..a32bd7e 100644
--- a/server/queue.c
+++ b/server/queue.c
@@ -1562,6 +1562,22 @@ void post_win_event( struct thread *thread, unsigned int event,
     }
 }
 
+
+/* check if the thread owning the window is hung */
+DECL_HANDLER(is_window_hung)
+{
+    struct thread *thread;
+
+    thread = get_window_thread( req->win );
+    if (thread)
+    {
+        reply->is_hung = is_queue_hung( thread->queue );
+        release_object( thread );
+    }
+    else reply->is_hung = 0;
+}
+
+
 /* get the message queue of the current thread */
 DECL_HANDLER(get_msg_queue)
 {
diff --git a/server/request.h b/server/request.h
index cc1d3d1..6c5f146 100644
--- a/server/request.h
+++ b/server/request.h
@@ -239,6 +239,7 @@ DECL_HANDLER(accept_hardware_message);
 DECL_HANDLER(get_message_reply);
 DECL_HANDLER(set_win_timer);
 DECL_HANDLER(kill_win_timer);
+DECL_HANDLER(is_window_hung);
 DECL_HANDLER(get_serial_info);
 DECL_HANDLER(set_serial_info);
 DECL_HANDLER(register_async);
@@ -476,6 +477,7 @@ static const req_handler req_handlers[REQ_NB_REQUESTS] =
     (req_handler)req_get_message_reply,
     (req_handler)req_set_win_timer,
     (req_handler)req_kill_win_timer,
+    (req_handler)req_is_window_hung,
     (req_handler)req_get_serial_info,
     (req_handler)req_set_serial_info,
     (req_handler)req_register_async,
diff --git a/server/trace.c b/server/trace.c
index 4bcd545..47e059e 100644
--- a/server/trace.c
+++ b/server/trace.c
@@ -2412,6 +2412,16 @@ static void dump_kill_win_timer_request( const struct kill_win_timer_request *re
     fprintf( stderr, " id=%lx", req->id );
 }
 
+static void dump_is_window_hung_request( const struct is_window_hung_request *req )
+{
+    fprintf( stderr, " win=%p", req->win );
+}
+
+static void dump_is_window_hung_reply( const struct is_window_hung_reply *req )
+{
+    fprintf( stderr, " is_hung=%d", req->is_hung );
+}
+
 static void dump_get_serial_info_request( const struct get_serial_info_request *req )
 {
     fprintf( stderr, " handle=%p", req->handle );
@@ -3878,6 +3888,7 @@ static const dump_func req_dumpers[REQ_NB_REQUESTS] = {
     (dump_func)dump_get_message_reply_request,
     (dump_func)dump_set_win_timer_request,
     (dump_func)dump_kill_win_timer_request,
+    (dump_func)dump_is_window_hung_request,
     (dump_func)dump_get_serial_info_request,
     (dump_func)dump_set_serial_info_request,
     (dump_func)dump_register_async_request,
@@ -4112,6 +4123,7 @@ static const dump_func reply_dumpers[REQ_NB_REQUESTS] = {
     (dump_func)dump_get_message_reply_reply,
     (dump_func)dump_set_win_timer_reply,
     (dump_func)0,
+    (dump_func)dump_is_window_hung_reply,
     (dump_func)dump_get_serial_info_reply,
     (dump_func)0,
     (dump_func)0,
@@ -4346,6 +4358,7 @@ static const char * const req_names[REQ_NB_REQUESTS] = {
     "get_message_reply",
     "set_win_timer",
     "kill_win_timer",
+    "is_window_hung",
     "get_serial_info",
     "set_serial_info",
     "register_async",




More information about the wine-cvs mailing list