server: Use BOOL type where appropriate
Frédéric Delanoy
frederic.delanoy at gmail.com
Fri Oct 18 04:25:01 CDT 2013
---
server/user.h | 10 +++---
server/window.c | 99 +++++++++++++++++++++++++++++----------------------------
2 files changed, 55 insertions(+), 54 deletions(-)
diff --git a/server/user.h b/server/user.h
index 2947de7..3f7a807 100644
--- a/server/user.h
+++ b/server/user.h
@@ -151,11 +151,11 @@ extern void post_desktop_message( struct desktop *desktop, unsigned int message,
lparam_t wparam, lparam_t lparam );
extern void destroy_window( struct window *win );
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 is_window_transparent( user_handle_t window );
-extern int make_window_active( user_handle_t window );
+extern BOOL is_child_window( user_handle_t parent, user_handle_t child );
+extern BOOL is_top_level_window( user_handle_t window );
+extern BOOL is_window_visible( user_handle_t window );
+extern BOOL is_window_transparent( user_handle_t window );
+extern BOOL make_window_active( user_handle_t window );
extern struct thread *get_window_thread( user_handle_t handle );
extern user_handle_t window_from_point( struct desktop *desktop, int x, int y );
extern user_handle_t find_window_to_repaint( user_handle_t parent, struct thread *thread );
diff --git a/server/window.c b/server/window.c
index 1696fce..9a8b21e 100644
--- a/server/window.c
+++ b/server/window.c
@@ -133,7 +133,7 @@ static inline struct window *get_window( user_handle_t handle )
}
/* check if window is the desktop */
-static inline int is_desktop_window( const struct window *win )
+static inline BOOL is_desktop_window( const struct window *win )
{
return !win->parent; /* only desktop windows have no parent */
}
@@ -230,7 +230,7 @@ static void link_window( struct window *win, struct window *previous )
}
/* change the parent of a window (or unlink the window if the new parent is NULL) */
-static int set_parent_window( struct window *win, struct window *parent )
+static BOOL set_parent_window( struct window *win, struct window *parent )
{
struct window *ptr;
@@ -240,7 +240,7 @@ static int set_parent_window( struct window *win, struct window *parent )
if (ptr == win)
{
set_error( STATUS_INVALID_PARAMETER );
- return 0;
+ return FALSE;
}
}
@@ -263,11 +263,11 @@ static int set_parent_window( struct window *win, struct window *parent )
list_add_head( &win->parent->unlinked, &win->entry );
win->is_linked = 0;
}
- return 1;
+ return TRUE;
}
/* append a user handle to a handle array */
-static int add_handle_to_array( struct user_handle_array *array, user_handle_t handle )
+static BOOL add_handle_to_array( struct user_handle_array *array, user_handle_t handle )
{
if (array->count >= array->total)
{
@@ -277,13 +277,13 @@ static int add_handle_to_array( struct user_handle_array *array, user_handle_t h
{
free( array->handles );
set_error( STATUS_NO_MEMORY );
- return 0;
+ return FALSE;
}
array->handles = new_array;
array->total = new_total;
}
array->handles[array->count++] = handle;
- return 1;
+ return TRUE;
}
/* set a window property */
@@ -567,33 +567,33 @@ static struct window *get_desktop_window( struct thread *thread )
}
/* check whether child is a descendant of parent */
-int is_child_window( user_handle_t parent, user_handle_t child )
+BOOL is_child_window( user_handle_t parent, user_handle_t child )
{
struct window *child_ptr = get_user_object( child, USER_WINDOW );
struct window *parent_ptr = get_user_object( parent, USER_WINDOW );
- if (!child_ptr || !parent_ptr) return 0;
+ if (!child_ptr || !parent_ptr) return FALSE;
while (child_ptr->parent)
{
- if (child_ptr->parent == parent_ptr) return 1;
+ if (child_ptr->parent == parent_ptr) return TRUE;
child_ptr = child_ptr->parent;
}
- return 0;
+ return FALSE;
}
/* check whether window is a top-level window */
-int is_top_level_window( user_handle_t window )
+BOOL is_top_level_window( user_handle_t window )
{
struct window *win = get_user_object( window, USER_WINDOW );
return (win && (is_desktop_window(win) || is_desktop_window(win->parent)));
}
/* make a window active if possible */
-int make_window_active( user_handle_t window )
+BOOL make_window_active( user_handle_t window )
{
struct window *owner, *win = get_window( window );
- if (!win) return 0;
+ if (!win) return FALSE;
/* set last active for window and its owners */
owner = win;
@@ -602,7 +602,7 @@ int make_window_active( user_handle_t window )
owner->last_active = win->handle;
owner = get_user_object( owner->owner, USER_WINDOW );
}
- return 1;
+ return TRUE;
}
/* increment (or decrement) the window paint count */
@@ -612,48 +612,49 @@ static inline void inc_window_paint_count( struct window *win, int incr )
}
/* check if window and all its ancestors are visible */
-static int is_visible( const struct window *win )
+static BOOL is_visible( const struct window *win )
{
while (win)
{
- if (!(win->style & WS_VISIBLE)) return 0;
+ if (!(win->style & WS_VISIBLE)) return FALSE;
win = win->parent;
/* if parent is minimized children are not visible */
- if (win && (win->style & WS_MINIMIZE)) return 0;
+ if (win && (win->style & WS_MINIMIZE)) return FALSE;
}
- return 1;
+ return TRUE;
}
/* same as is_visible but takes a window handle */
-int is_window_visible( user_handle_t window )
+BOOL is_window_visible( user_handle_t window )
{
struct window *win = get_user_object( window, USER_WINDOW );
- if (!win) return 0;
+ if (!win) return FALSE;
return is_visible( win );
}
-int is_window_transparent( user_handle_t window )
+BOOL is_window_transparent( user_handle_t window )
{
struct window *win = get_user_object( window, USER_WINDOW );
- if (!win) return 0;
+ if (!win) return FALSE;
return (win->ex_style & (WS_EX_LAYERED|WS_EX_TRANSPARENT)) == (WS_EX_LAYERED|WS_EX_TRANSPARENT);
}
/* check if point is inside the window */
-static inline int is_point_in_window( struct window *win, int x, int y )
+static inline BOOL is_point_in_window( struct window *win, int x, int y )
{
- if (!(win->style & WS_VISIBLE)) return 0; /* not visible */
+ if (!(win->style & WS_VISIBLE))
+ return FALSE; /* not visible */
if ((win->style & (WS_POPUP|WS_CHILD|WS_DISABLED)) == (WS_CHILD|WS_DISABLED))
- return 0; /* disabled child */
+ return FALSE; /* disabled child */
if ((win->ex_style & (WS_EX_LAYERED|WS_EX_TRANSPARENT)) == (WS_EX_LAYERED|WS_EX_TRANSPARENT))
- return 0; /* transparent */
+ return FALSE; /* transparent */
if (x < win->visible_rect.left || x >= win->visible_rect.right ||
y < win->visible_rect.top || y >= win->visible_rect.bottom)
- return 0; /* not in window */
+ return FALSE; /* not in window */
if (win->win_region &&
!point_in_region( win->win_region, x - win->window_rect.left, y - win->window_rect.top ))
- return 0; /* not in window region */
- return 1;
+ return FALSE; /* not in window region */
+ return TRUE;
}
/* fill an array with the handles of the children of a specified window */
@@ -702,7 +703,7 @@ static struct window *child_window_from_point( struct window *parent, int x, int
}
/* find all children of 'parent' that contain the given point */
-static int get_window_children_from_point( struct window *parent, int x, int y,
+static BOOL get_window_children_from_point( struct window *parent, int x, int y,
struct user_handle_array *array )
{
struct window *ptr;
@@ -718,13 +719,13 @@ static int get_window_children_from_point( struct window *parent, int x, int y,
{
if (!get_window_children_from_point( ptr, x - ptr->client_rect.left,
y - ptr->client_rect.top, array ))
- return 0;
+ return FALSE;
}
/* now add window to the array */
- if (!add_handle_to_array( array, ptr->handle )) return 0;
+ if (!add_handle_to_array( array, ptr->handle )) return FALSE;
}
- return 1;
+ return TRUE;
}
/* find window containing point (in absolute coords) */
@@ -738,7 +739,7 @@ user_handle_t window_from_point( struct desktop *desktop, int x, int y )
}
/* return list of all windows containing point (in absolute coords) */
-static int all_windows_from_point( struct window *top, int x, int y, struct user_handle_array *array )
+static BOOL all_windows_from_point( struct window *top, int x, int y, struct user_handle_array *array )
{
struct window *ptr;
@@ -749,7 +750,7 @@ static int all_windows_from_point( struct window *top, int x, int y, struct user
y -= ptr->client_rect.top;
}
- if (!is_point_in_window( top, x, y )) return 1;
+ if (!is_point_in_window( top, x, y )) return TRUE;
/* if point is in client area, and window is not minimized or disabled, check children */
if (!(top->style & (WS_MINIMIZE|WS_DISABLED)) &&
@@ -761,11 +762,11 @@ static int all_windows_from_point( struct window *top, int x, int y, struct user
x -= top->client_rect.left;
y -= top->client_rect.top;
}
- if (!get_window_children_from_point( top, x, y, array )) return 0;
+ if (!get_window_children_from_point( top, x, y, array )) return FALSE;
}
/* now add window to the array */
- if (!add_handle_to_array( array, top->handle )) return 0;
- return 1;
+ if (!add_handle_to_array( array, top->handle )) return FALSE;
+ return TRUE;
}
@@ -779,7 +780,7 @@ 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 )
+static inline BOOL win_needs_repaint( struct window *win )
{
return win->update_region || (win->paint_flags & PAINT_INTERNAL);
}
@@ -1119,11 +1120,11 @@ struct window_class* get_window_class( user_handle_t window )
/* determine the window visible rectangle, i.e. window or client rect cropped by parent rects */
/* the returned rectangle is in window coordinates; return 0 if rectangle is empty */
-static int get_window_visible_rect( struct window *win, rectangle_t *rect, int frame )
+static BOOL get_window_visible_rect( struct window *win, rectangle_t *rect, int frame )
{
int offset_x = 0, offset_y = 0;
- if (!(win->style & WS_VISIBLE)) return 0;
+ if (!(win->style & WS_VISIBLE)) return FALSE;
*rect = frame ? win->window_rect : win->client_rect;
if (!is_desktop_window(win))
@@ -1135,18 +1136,18 @@ static int get_window_visible_rect( struct window *win, rectangle_t *rect, int f
while (win->parent)
{
win = win->parent;
- if (!(win->style & WS_VISIBLE) || win->style & WS_MINIMIZE) return 0;
+ if (!(win->style & WS_VISIBLE) || win->style & WS_MINIMIZE) return FALSE;
if (!is_desktop_window(win))
{
offset_x += win->client_rect.left;
offset_y += win->client_rect.top;
offset_rect( rect, win->client_rect.left, win->client_rect.top );
}
- if (!intersect_rect( rect, rect, &win->client_rect )) return 0;
- if (!intersect_rect( rect, rect, &win->window_rect )) return 0;
+ if (!intersect_rect( rect, rect, &win->client_rect )) return FALSE;
+ if (!intersect_rect( rect, rect, &win->window_rect )) return FALSE;
}
offset_rect( rect, -offset_x, -offset_y );
- return 1;
+ return TRUE;
}
/* return a copy of the specified region cropped to the window client or frame rectangle, */
@@ -1206,15 +1207,15 @@ static void set_update_region( struct window *win, struct region *region )
/* add a region to the update region; the passed region is freed or reused */
-static int add_update_region( struct window *win, struct region *region )
+static BOOL add_update_region( struct window *win, struct region *region )
{
if (win->update_region && !union_region( region, win->update_region, region ))
{
free_region( region );
- return 0;
+ return FALSE;
}
set_update_region( win, region );
- return 1;
+ return TRUE;
}
--
1.8.4
More information about the wine-patches
mailing list