PATCH[5/6] server:Declaration handler for SwitchDesktop API

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


  Hi,

       This patch has the declaration handler for SwitchDesktop API.Here we
hide all the windows of the current desktop and show the windows of the
desktop that is being switched to.While showing the windows of a desktop,in
order to avoid showing the default hidden windows, we will maintain array of
windows which we hide manually.

      In order to maintain Active desktop feature, some modifications have
been added in some functions.

     The definition for *int is_active_desktop(struct desktop *)* is in this
patch.

     In order to check whether the window handle is in array or not *int
find_handle_in_array( struct user_handle_array *, user_handle_t )* is
defined.


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

---
 server/window.c |  123 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 122 insertions(+), 1 deletions(-)

diff --git a/server/window.c b/server/window.c
index a0e0788..f577908 100644
--- a/server/window.c
+++ b/server/window.c
@@ -261,6 +261,24 @@ static int add_handle_to_array( struct user_handle_array *array, user_handle_t h
     return 1;
 }
 
+/* Find a window handle in given array */
+/* return 1 if the handle is in the array and 0 if not */
+static int find_handle_in_array( struct user_handle_array *array, user_handle_t handle )
+{
+    int i = 0;
+
+    if (!handle)
+    {
+	set_error( STATUS_INVALID_PARAMETER );
+	return 0;
+    }
+    for(i = 0; i < array->count; i++ )
+    {
+	if (array->handles[i] == handle) return 1;
+    }
+    return 0;
+}
+
 /* set a window property */
 static void set_property( struct window *win, atom_t atom, lparam_t data, enum property_type type )
 {
@@ -697,6 +715,8 @@ static int all_windows_from_point( struct window *top, int x, int y, struct user
 {
     struct window *ptr;
 
+    if(!( top->desktop == top->desktop->winstation->active_desktop )) return 1;
+
     /* make point relative to top window */
     for (ptr = top->parent; ptr && !is_desktop_window(ptr); ptr = ptr->parent)
     {
@@ -736,10 +756,15 @@ struct thread *get_window_thread( user_handle_t handle )
 /* check if any area of a window needs repainting */
 static inline int win_needs_repaint( struct window *win )
 {
-    return win->update_region || (win->paint_flags & PAINT_INTERNAL);
+    return (is_active_desktop( win->desktop )) && (win->update_region || (win->paint_flags & PAINT_INTERNAL));
 }
 
 
+int is_active_desktop( struct desktop *desktop )
+{
+    return (desktop->winstation->active_desktop == desktop);
+}
+
 /* find a child of the specified window that needs repainting */
 static struct window *find_child_to_repaint( struct window *parent, struct thread *thread )
 {
@@ -1241,6 +1266,8 @@ static void redraw_window( struct window *win, struct region *region, int frame,
     struct region *tmp;
     struct window *child;
 
+    if(!(win->desktop == win->desktop->winstation->active_desktop)) return;
+
     if (flags & RDW_INVALIDATE)
     {
         if (!(tmp = crop_region_to_win_rect( win, region, frame ))) return;
@@ -2526,3 +2553,97 @@ DECL_HANDLER(set_window_layered_info)
     }
     else set_win32_error( ERROR_INVALID_WINDOW_HANDLE );
 }
+
+
+/* Switch to another Desktop */
+DECL_HANDLER(switch_desktop)
+{
+    struct winstation *winstation;
+    struct thread *thread;
+    struct desktop *old_desktop, *new_desktop;
+    struct window *top_win = NULL, *next_win = NULL;
+    user_handle_t *handles_windows = NULL, *handles = NULL;
+    static struct user_handle_array array;
+    int i=0, j=0;
+    unsigned int total = 0;
+    data_size_t len;
+
+    if (!(winstation = get_process_winstation( current->process, 0  /*FIXME: access rights? */ ))) return;
+
+    if (!(new_desktop = get_desktop_obj( current->process, req->handle, 0 )))
+    {
+	release_object( winstation );
+	return;
+    }
+    handles = (user_handle_t *)get_req_data();
+
+    /* Getting handle for current desktop */
+    if (!(thread = get_thread_from_id( req->tid ))) return;
+
+    if (!(old_desktop = get_desktop_obj(current->process, thread->desktop, 0 ))) return;
+    release_object( thread );
+
+    /* If SetThreadDesktop is called before SwitchDesktop */
+    if (old_desktop == new_desktop)
+	old_desktop = winstation->active_desktop;
+
+    /* Set Active Desktop */
+    winstation->active_desktop = new_desktop;
+
+    /* Hiding current desktop windows */
+    top_win = old_desktop->top_window;
+    if (!top_win)
+    {
+	set_error( STATUS_INVALID_HANDLE );
+	return;
+    }
+
+    total = get_children_windows( top_win, 0, 0, NULL, 0 );
+    get_children_windows( top_win, 0, 0, handles, total );
+    len = min( get_reply_max_size(), total * sizeof(user_handle_t) );
+
+    if (len && ((handles_windows = set_reply_data_size( len ))))
+    {
+	for(i = 0;i < total; i++)
+	{
+	    next_win = get_window( handles[i] );
+	    if (next_win->style & WS_VISIBLE)
+	    {
+		handles_windows[j] = next_win->handle;
+		if (!(find_handle_in_array( &array, next_win->handle )))
+		    add_handle_to_array( &array, next_win->handle );
+		j++;
+	    }
+	}
+    }
+    reply->old_desktop_count = j;
+
+    /* Showing another  desktop windows */
+    top_win = new_desktop->top_window;
+
+    if (!top_win)
+    {
+	set_error( STATUS_INVALID_HANDLE );
+	return;
+    }
+
+    total = get_children_windows( top_win, 0, 0, NULL, 0 );
+    get_children_windows( top_win, 0, 0, handles, total );
+
+    /* Finding windows to be shown */
+    for(i = 0; i <= total-1; i++)
+    {
+	next_win = get_window( handles[i] );
+	if (next_win->style & ~WS_VISIBLE)
+	{
+	    if (find_handle_in_array( &array, next_win->handle ))
+	    {
+		handles_windows[j] = next_win->handle;
+		j++;
+	    }
+	}
+    }
+    reply->new_desktop_count = j - reply->old_desktop_count;
+
+    return;
+}
-- 
1.6.0.4


More information about the wine-patches mailing list