From 085ef06bd5b974b7e872c36fe8c0792e4df62018 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Wed, 27 Oct 2004 21:54:41 +0000 Subject: [PATCH] Added is_window_visible function. --- server/user.h | 1 + server/window.c | 25 ++++++++++++++++++++++--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/server/user.h b/server/user.h index 7488c73d637..dfeda2aaa18 100644 --- a/server/user.h +++ b/server/user.h @@ -96,6 +96,7 @@ static inline struct region *create_empty_region(void) { return create_region( N extern void destroy_thread_windows( struct thread *thread ); extern int is_child_window( user_handle_t parent, user_handle_t child ); extern int is_top_level_window( user_handle_t window ); +extern int is_window_visible( user_handle_t window ); extern int make_window_active( user_handle_t window ); extern struct thread *get_window_thread( user_handle_t handle ); extern user_handle_t window_from_point( int x, int y ); diff --git a/server/window.c b/server/window.c index 1b069870b41..9a9229d637c 100644 --- a/server/window.c +++ b/server/window.c @@ -405,6 +405,27 @@ int make_window_active( user_handle_t window ) return 1; } +/* check if window and all its ancestors are visible */ +static int is_visible( const struct window *win ) +{ + while (win && win != top_window) + { + if (!(win->style & WS_VISIBLE)) return 0; + win = win->parent; + /* if parent is minimized children are not visible */ + if (win && (win->style & WS_MINIMIZE)) return 0; + } + return 1; +} + +/* same as is_visible but takes a window handle */ +int is_window_visible( user_handle_t window ) +{ + struct window *win = get_user_object( window, USER_WINDOW ); + if (!win) return 0; + return is_visible( win ); +} + /* check if point is inside the window */ static inline int is_point_in_window( struct window *win, int x, int y ) { @@ -601,15 +622,13 @@ static struct region *get_visible_region( struct window *win, struct window *top unsigned int flags ) { struct region *tmp, *region; - struct window *ptr; int offset_x, offset_y; if (!(region = create_empty_region())) return NULL; /* first check if all ancestors are visible */ - for (ptr = win; ptr != top_window; ptr = ptr->parent) - if (!(ptr->style & WS_VISIBLE)) return region; /* empty region */ + if (!is_visible( win )) return region; /* empty region */ /* create a region relative to the window itself */