[1/6]user32:SwitchDesktop API Implementation (try 2)

shanmukha sainath addepalli sainath.addepalli at gmail.com
Sat Dec 12 05:05:42 CST 2009


Hi,

      These are the series of patches for the Implementation of
SwitchDesktop and OpenInputDesktop API in user32.dll. SwitchDesktop
API is useful for switching between two desktops. Multi desktop
applications use this API functionality to switch between desktops.

     It calls server request handler of SwitchDesktop. When this API
called, it hides all the windows of the current desktop and shows the
windows of the desktop that is being switched.

   Differences from previous patch:
           1. Corrections in formatting.


     Change Log: Implemented SwitchDesktop API.

-- 
Regards
Sainath A
-------------- next part --------------
From d1490db638780698dfa5a1a74c278e4a40fd364d Mon Sep 17 00:00:00 2001
From: Sainath Addepalli <sainath.addepalli at gmail.com>
Date: Fri, 11 Dec 2009 19:18:41 +0530
Subject: SwitchDesktop API Declaration

---
 dlls/user32/win.c |   46 ++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 44 insertions(+), 2 deletions(-)

diff --git a/dlls/user32/win.c b/dlls/user32/win.c
index 46c2388..c9b006f 100644
--- a/dlls/user32/win.c
+++ b/dlls/user32/win.c
@@ -3479,8 +3479,50 @@ BOOL WINAPI GetWindowInfo( HWND hwnd, PWINDOWINFO pwi)
  */
 BOOL WINAPI SwitchDesktop( HDESK hDesktop)
 {
-    FIXME("SwitchDesktop(hwnd %p) stub!\n", hDesktop);
-    return TRUE;
+    BOOL ret = 0;
+    HWND *list_old = NULL, *list_new = NULL, *list = NULL;
+    int size = 128, count_old = 0, count_new = 0, i = 0, j = 0;
+    TRACE( "Switching to Desktop %p\n", hDesktop );
+
+    if (!(list = HeapAlloc( GetProcessHeap(), 0, size * sizeof(HWND) ))) return ret;
+    if (!(list_old = HeapAlloc( GetProcessHeap(), 0, size * sizeof(HWND) ))) goto end1;
+    if (!(list_new = HeapAlloc( GetProcessHeap(), 0, size * sizeof(HWND) ))) goto end2;
+
+    SERVER_START_REQ( switch_desktop )
+    {
+        req->handle = wine_server_obj_handle( hDesktop );
+        wine_server_add_data( req, list, (size-1) * sizeof(user_handle_t) );
+        wine_server_set_reply( req, list_old, (size-1) * sizeof(user_handle_t) );
+        ret = !wine_server_call( req );
+
+        count_old = reply->old_desktop_count;
+        count_new = reply->new_desktop_count;
+    }
+    SERVER_END_REQ;
+
+    if (count_old)
+    {
+        for (i = count_old-1; i>=0; i--)
+            list_old[i] = wine_server_ptr_handle( ((user_handle_t *)list_old) [i] );
+
+        for (i = 0; i < count_old; i++)
+            ret = ShowWindowAsync( list_old[i], SW_HIDE );
+    }
+
+    if (count_new)
+    {
+        for (i = count_old,j = 0; i < count_old+count_new; i++, j++)
+            list_new[j] = wine_server_ptr_handle( ((user_handle_t *)list_old) [i] );
+
+        for (i = 0; i < count_new; i++)
+            ret = ShowWindowAsync( list_new[i], SW_SHOW );
+    }
+
+    HeapFree( GetProcessHeap(), 0, list_new );
+    end2:HeapFree( GetProcessHeap(), 0, list_old );
+    end1:HeapFree( GetProcessHeap(), 0, list );
+
+    return ret;
 }
 
 /*****************************************************************************
-- 
1.6.0.4


More information about the wine-patches mailing list