2 * Wine server USER definitions
4 * Copyright (C) 2001 Alexandre Julliard
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #ifndef __WINE_SERVER_USER_H
22 #define __WINE_SERVER_USER_H
24 #include "wine/server_protocol.h"
39 USER_CLIENT
/* arbitrary client handle */
42 #define DESKTOP_ATOM ((atom_t)32769)
46 struct object obj
; /* object header */
47 unsigned int flags
; /* winstation flags */
48 struct list entry
; /* entry in global winstation list */
49 struct list desktops
; /* list of desktops of this winstation */
50 struct clipboard
*clipboard
; /* clipboard information */
51 struct atom_table
*atom_table
; /* global atom table */
56 struct object obj
; /* object header */
57 unsigned int flags
; /* desktop flags */
58 struct winstation
*winstation
; /* winstation this desktop belongs to */
59 struct list entry
; /* entry in winstation list of desktops */
60 struct window
*top_window
; /* desktop window for this desktop */
61 struct window
*msg_window
; /* HWND_MESSAGE top window */
62 struct hook_table
*global_hooks
; /* table of global hooks on this desktop */
63 struct timeout_user
*close_timeout
; /* timeout before closing the desktop */
64 struct thread_input
*foreground_input
; /* thread input of foreground thread */
65 unsigned int users
; /* processes and threads using this desktop */
66 int cursor_x
; /* cursor position */
68 rectangle_t cursor_clip
; /* cursor clip rectangle */
69 unsigned char keystate
[256]; /* asynchronous key state */
72 /* user handles functions */
74 extern user_handle_t
alloc_user_handle( void *ptr
, enum user_object type
);
75 extern void *get_user_object( user_handle_t handle
, enum user_object type
);
76 extern void *get_user_object_handle( user_handle_t
*handle
, enum user_object type
);
77 extern user_handle_t
get_user_full_handle( user_handle_t handle
);
78 extern void *free_user_handle( user_handle_t handle
);
79 extern void *next_user_handle( user_handle_t
*handle
, enum user_object type
);
80 extern void free_process_user_handles( struct process
*process
);
82 /* clipboard functions */
84 extern void cleanup_clipboard_thread( struct thread
*thread
);
88 extern void remove_thread_hooks( struct thread
*thread
);
89 extern unsigned int get_active_hooks(void);
90 extern struct thread
*get_first_global_hook( int id
);
94 extern void free_msg_queue( struct thread
*thread
);
95 extern struct hook_table
*get_queue_hooks( struct thread
*thread
);
96 extern void set_queue_hooks( struct thread
*thread
, struct hook_table
*hooks
);
97 extern void inc_queue_paint_count( struct thread
*thread
, int incr
);
98 extern void queue_cleanup_window( struct thread
*thread
, user_handle_t win
);
99 extern int init_thread_queue( struct thread
*thread
);
100 extern int attach_thread_input( struct thread
*thread_from
, struct thread
*thread_to
);
101 extern void detach_thread_input( struct thread
*thread_from
);
102 extern void post_message( user_handle_t win
, unsigned int message
,
103 lparam_t wparam
, lparam_t lparam
);
104 extern void post_win_event( struct thread
*thread
, unsigned int event
,
105 user_handle_t win
, unsigned int object_id
,
106 unsigned int child_id
, client_ptr_t proc
,
107 const WCHAR
*module
, data_size_t module_size
,
108 user_handle_t handle
);
110 /* region functions */
112 extern struct region
*create_empty_region(void);
113 extern struct region
*create_region_from_req_data( const void *data
, data_size_t size
);
114 extern void free_region( struct region
*region
);
115 extern void set_region_rect( struct region
*region
, const rectangle_t
*rect
);
116 extern rectangle_t
*get_region_data( const struct region
*region
, data_size_t max_size
,
117 data_size_t
*total_size
);
118 extern rectangle_t
*get_region_data_and_free( struct region
*region
, data_size_t max_size
,
119 data_size_t
*total_size
);
120 extern int is_region_empty( const struct region
*region
);
121 extern void get_region_extents( const struct region
*region
, rectangle_t
*rect
);
122 extern void offset_region( struct region
*region
, int x
, int y
);
123 extern void mirror_region( const rectangle_t
*client_rect
, struct region
*region
);
124 extern struct region
*copy_region( struct region
*dst
, const struct region
*src
);
125 extern struct region
*intersect_region( struct region
*dst
, const struct region
*src1
,
126 const struct region
*src2
);
127 extern struct region
*subtract_region( struct region
*dst
, const struct region
*src1
,
128 const struct region
*src2
);
129 extern struct region
*union_region( struct region
*dst
, const struct region
*src1
,
130 const struct region
*src2
);
131 extern struct region
*xor_region( struct region
*dst
, const struct region
*src1
,
132 const struct region
*src2
);
133 extern int point_in_region( struct region
*region
, int x
, int y
);
134 extern int rect_in_region( struct region
*region
, const rectangle_t
*rect
);
136 /* window functions */
138 extern struct process
*get_top_window_owner( struct desktop
*desktop
);
139 extern void get_top_window_rectangle( struct desktop
*desktop
, rectangle_t
*rect
);
140 extern void close_desktop_window( struct desktop
*desktop
);
141 extern void destroy_window( struct window
*win
);
142 extern void destroy_thread_windows( struct thread
*thread
);
143 extern int is_child_window( user_handle_t parent
, user_handle_t child
);
144 extern int is_top_level_window( user_handle_t window
);
145 extern int is_window_visible( user_handle_t window
);
146 extern int is_window_transparent( user_handle_t window
);
147 extern int make_window_active( user_handle_t window
);
148 extern struct thread
*get_window_thread( user_handle_t handle
);
149 extern user_handle_t
window_from_point( struct desktop
*desktop
, int x
, int y
);
150 extern user_handle_t
find_window_to_repaint( user_handle_t parent
, struct thread
*thread
);
151 extern struct window_class
*get_window_class( user_handle_t window
);
153 /* window class functions */
155 extern void destroy_process_classes( struct process
*process
);
156 extern struct window_class
*grab_class( struct process
*process
, atom_t atom
,
157 mod_handle_t instance
, int *extra_bytes
);
158 extern void release_class( struct window_class
*class );
159 extern int is_desktop_class( struct window_class
*class );
160 extern int is_hwnd_message_class( struct window_class
*class );
161 extern atom_t
get_class_atom( struct window_class
*class );
162 extern client_ptr_t
get_class_client_ptr( struct window_class
*class );
164 /* windows station functions */
166 extern struct desktop
*get_desktop_obj( struct process
*process
, obj_handle_t handle
, unsigned int access
);
167 extern struct winstation
*get_process_winstation( struct process
*process
, unsigned int access
);
168 extern struct desktop
*get_thread_desktop( struct thread
*thread
, unsigned int access
);
169 extern void connect_process_winstation( struct process
*process
, struct thread
*parent
);
170 extern void set_process_default_desktop( struct process
*process
, struct desktop
*desktop
,
171 obj_handle_t handle
);
172 extern void close_process_desktop( struct process
*process
);
173 extern void close_thread_desktop( struct thread
*thread
);
175 /* mirror a rectangle respective to the window client area */
176 static inline void mirror_rect( const rectangle_t
*client_rect
, rectangle_t
*rect
)
178 int width
= client_rect
->right
- client_rect
->left
;
179 int tmp
= rect
->left
;
180 rect
->left
= width
- rect
->right
;
181 rect
->right
= width
- tmp
;
184 /* compute the intersection of two rectangles; return 0 if the result is empty */
185 static inline int intersect_rect( rectangle_t
*dst
, const rectangle_t
*src1
, const rectangle_t
*src2
)
187 dst
->left
= max( src1
->left
, src2
->left
);
188 dst
->top
= max( src1
->top
, src2
->top
);
189 dst
->right
= min( src1
->right
, src2
->right
);
190 dst
->bottom
= min( src1
->bottom
, src2
->bottom
);
191 return (dst
->left
< dst
->right
&& dst
->top
< dst
->bottom
);
194 #endif /* __WINE_SERVER_USER_H */