PATCH[6/6] server: Declaration handler for OpenInputDesktop

shanmukha sainath addepalli sainath.addepalli at gmail.com
Sat Aug 29 00:52:54 CDT 2009


  Hi,

         This patch contains the Declaration Handler for OpenInputDesktop
API.We will allocate a handle with the given access rights for the active
desktop and return the handle.

         Some functions and Declaration Handlers have been modified to
support Active Desktop concept.

-- 
Regards
Sainath A
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.winehq.org/pipermail/wine-patches/attachments/20090829/5cc617cc/attachment.htm>
-------------- next part --------------
From 45c9cb67a1b6db5c86fdc3e5279f4511ecacadaa Mon Sep 17 00:00:00 2001
From: Sainath Addepalli <sainath.addepalli at gmail.com>
Date: Fri, 28 Aug 2009 18:25:24 +0530
Subject: OpenInputDesktop Declaration Handler

---
 server/winstation.c |   74 +++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 72 insertions(+), 2 deletions(-)

diff --git a/server/winstation.c b/server/winstation.c
index cfff0a4..a9974cc 100644
--- a/server/winstation.c
+++ b/server/winstation.c
@@ -121,6 +121,7 @@ static struct winstation *create_winstation( const struct unicode_str *name, uns
             winstation->flags = flags;
             winstation->clipboard = NULL;
             winstation->atom_table = NULL;
+	    winstation->active_desktop = NULL;
             list_add_tail( &winstation_list, &winstation->entry );
             list_init( &winstation->desktops );
         }
@@ -499,6 +500,8 @@ DECL_HANDLER(create_desktop)
         if ((desktop = create_desktop( &name, req->attributes, req->flags, winstation )))
         {
             reply->handle = alloc_handle( current->process, desktop, req->access, req->attributes );
+	    if (!(winstation->active_desktop))
+		winstation->active_desktop = desktop;   /* This is the first desktop of the winstation */
             release_object( desktop );
         }
         release_object( winstation );
@@ -535,16 +538,83 @@ DECL_HANDLER(open_desktop)
 }
 
 
+/* open a handle to input desktop */
+DECL_HANDLER(open_input_desktop)
+{
+    struct winstation *winstation = NULL;
+    struct desktop *desktop;
+    struct object *obj;
+
+    winstation = get_process_winstation( current->process, 0 );
+    if (winstation)
+    {
+	desktop = winstation->active_desktop;
+	if (!desktop) return;
+	obj = &(desktop->obj);
+	if (&desktop_ops && obj->ops != &desktop_ops)
+	    set_error( STATUS_OBJECT_TYPE_MISMATCH );
+	else
+	    reply->handle = alloc_handle( current->process, obj, req->access, req->attributes );
+	release_object( obj );
+	release_object( winstation );
+    }
+}
+
+
 /* close a desktop */
 DECL_HANDLER(close_desktop)
 {
-    struct desktop *desktop;
+    struct desktop *desktop, *prev_desktop = NULL, *next_desktop = NULL, *current_desktop = NULL;
+    struct winstation *winstation = NULL;
+    int j = 0;
+
+    if (!(winstation = get_process_winstation( current->process, 0 ))) return;
 
     /* make sure it is a desktop handle */
     if ((desktop = (struct desktop *)get_handle_obj( current->process, req->handle,
                                                      0, &desktop_ops )))
     {
-        if (!close_handle( current->process, req->handle )) set_error( STATUS_DEVICE_BUSY );
+	if (desktop == winstation->active_desktop)
+	{
+	    LIST_FOR_EACH_ENTRY( next_desktop, &winstation->desktops, struct desktop, entry )
+	    {
+		if (!current_desktop) current_desktop = next_desktop;
+	        if (current_desktop == desktop)
+		{
+		    if (prev_desktop)
+		    {
+			winstation->active_desktop = prev_desktop;
+			break;
+		    }
+		    /* If we are closing first desktop then we need to assign next desktop as active if it exists */
+		    else
+		    {
+			if (j)
+			{
+			    if (next_desktop)
+			    {
+				winstation->active_desktop = next_desktop;
+				break;
+			    }
+			    else break;
+			}
+			else
+			{
+			    j++;
+			    continue;
+			}
+		    }
+		}
+		current_desktop = next_desktop;
+		prev_desktop = next_desktop;
+	    }
+	}
+
+	if (!close_handle( current->process, req->handle ))
+	{
+	    set_error( STATUS_DEVICE_BUSY );
+	    winstation->active_desktop = desktop;
+	}
         release_object( desktop );
     }
 }
-- 
1.6.0.4


More information about the wine-patches mailing list