VirtualBox

source: vbox/trunk/src/VBox/Additions/x11/x11include/xorg-server-1.3.0.0/Xplugin.h@ 61386

最後變更 在這個檔案從61386是 25078,由 vboxsync 提交於 15 年 前

Additions/x11/x11include: exported and set eol-style on new headers

  • 屬性 svn:eol-style 設為 native
檔案大小: 19.2 KB
 
1/* Xplugin.h -- windowing API for rootless X11 server
2 $Id$
3
4 Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
5
6 Permission is hereby granted, free of charge, to any person
7 obtaining a copy of this software and associated documentation files
8 (the "Software"), to deal in the Software without restriction,
9 including without limitation the rights to use, copy, modify, merge,
10 publish, distribute, sublicense, and/or sell copies of the Software,
11 and to permit persons to whom the Software is furnished to do so,
12 subject to the following conditions:
13
14 The above copyright notice and this permission notice shall be
15 included in all copies or substantial portions of the Software.
16
17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
21 HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24 DEALINGS IN THE SOFTWARE.
25
26 Except as contained in this notice, the name(s) of the above
27 copyright holders shall not be used in advertising or otherwise to
28 promote the sale, use or other dealings in this Software without
29 prior written authorization.
30
31 Note that these interfaces are provided solely for the use of the
32 X11 server. Any other uses are unsupported and strongly discouraged. */
33
34#ifndef XPLUGIN_H
35#define XPLUGIN_H 1
36
37#include <stdint.h>
38
39/* By default we use the X server definition of BoxRec to define xp_box,
40 so that the compiler can silently convert between the two. But if
41 XP_NO_X_HEADERS is defined, we'll define it ourselves. */
42
43#ifndef XP_NO_X_HEADERS
44# include "miscstruct.h"
45 typedef BoxRec xp_box;
46#else
47 struct xp_box_struct {
48 short x1, y1, x2, y2;
49 };
50 typedef struct xp_box_struct xp_box;
51#endif
52
53typedef unsigned int xp_resource_id;
54typedef xp_resource_id xp_window_id;
55typedef xp_resource_id xp_surface_id;
56typedef unsigned int xp_client_id;
57typedef unsigned int xp_request_type;
58typedef int xp_error;
59typedef int xp_bool;
60
61
62/* Error codes that the functions declared here may return. They all
63 numerically match their X equivalents, i.e. the XP_ can be dropped
64 if <X11/X.h> has been included. */
65
66enum xp_error_enum {
67 XP_Success = 0,
68 XP_BadRequest = 1,
69 XP_BadValue = 2,
70 XP_BadWindow = 3,
71 XP_BadMatch = 8,
72 XP_BadAccess = 10,
73 XP_BadImplementation = 17,
74};
75
76
77/* Event types generated by the plugin. */
78
79enum xp_event_type_enum {
80 /* The global display configuration changed somehow. */
81 XP_EVENT_DISPLAY_CHANGED = 1 << 0,
82
83 /* A window changed state. Argument is xp_window_state_event */
84 XP_EVENT_WINDOW_STATE_CHANGED = 1 << 1,
85
86 /* An async request encountered an error. Argument is of type
87 xp_async_error_event */
88 XP_EVENT_ASYNC_ERROR = 1 << 2,
89
90 /* Sent when a surface is destroyed as a side effect of destroying
91 a window. Arg is of type xp_surface_id. */
92 XP_EVENT_SURFACE_DESTROYED = 1 << 3,
93
94 /* Sent when any GL contexts pointing at the given surface need to
95 call xp_update_gl_context () to refresh their state (because the
96 window moved or was resized. Arg is of type xp_surface_id. */
97 XP_EVENT_SURFACE_CHANGED = 1 << 4,
98
99 /* Sent when a window has been moved. Arg is of type xp_window_id. */
100 XP_EVENT_WINDOW_MOVED = 1 << 5,
101};
102
103/* Function type used to receive events. */
104
105typedef void (xp_event_fun) (unsigned int type, const void *arg,
106 unsigned int arg_size, void *user_data);
107
108
109/* Operation types. Used when reporting errors asynchronously. */
110
111enum xp_request_type_enum {
112 XP_REQUEST_NIL = 0,
113 XP_REQUEST_DESTROY_WINDOW = 1,
114 XP_REQUEST_CONFIGURE_WINDOW = 2,
115 XP_REQUEST_FLUSH_WINDOW = 3,
116 XP_REQUEST_COPY_WINDOW = 4,
117 XP_REQUEST_UNLOCK_WINDOW = 5,
118 XP_REQUEST_DISABLE_UPDATE = 6,
119 XP_REQUEST_REENABLE_UPDATE = 7,
120 XP_REQUEST_HIDE_CURSOR = 8,
121 XP_REQUEST_SHOW_CURSOR = 9,
122 XP_REQUEST_FRAME_DRAW = 10,
123};
124
125/* Structure used to report an error asynchronously. Passed as the "arg"
126 of an XP_EVENT_ASYNC_ERROR event. */
127
128struct xp_async_error_event_struct {
129 xp_request_type request_type;
130 xp_resource_id id;
131 xp_error error;
132};
133
134typedef struct xp_async_error_event_struct xp_async_error_event;
135
136
137/* Possible window states. */
138
139enum xp_window_state_enum {
140 /* The window is not in the global list of possibly-visible windows. */
141 XP_WINDOW_STATE_OFFSCREEN = 1 << 0,
142
143 /* Parts of the window may be obscured by other windows. */
144 XP_WINDOW_STATE_OBSCURED = 1 << 1,
145};
146
147/* Structure passed as argument of an XP_EVENT_WINDOW_STATE_CHANGED event. */
148
149struct xp_window_state_event_struct {
150 xp_window_id id;
151 unsigned int state;
152};
153
154typedef struct xp_window_state_event_struct xp_window_state_event;
155
156
157/* Function type used to supply a colormap for indexed drawables. */
158
159typedef xp_error (xp_colormap_fun) (void *data, int first_color,
160 int n_colors, uint32_t *colors);
161
162
163/* Window attributes structure. Used when creating and configuring windows.
164 Also used when configuring surfaces attached to windows. Functions that
165 take one of these structures also take a bit mask defining which
166 fields are set to meaningful values. */
167
168enum xp_window_changes_enum {
169 XP_ORIGIN = 1 << 0,
170 XP_SIZE = 1 << 1,
171 XP_BOUNDS = XP_ORIGIN | XP_SIZE,
172 XP_SHAPE = 1 << 2,
173 XP_STACKING = 1 << 3,
174 XP_DEPTH = 1 << 4,
175 XP_COLORMAP = 1 << 5,
176 XP_WINDOW_LEVEL = 1 << 6,
177};
178
179struct xp_window_changes_struct {
180 /* XP_ORIGIN */
181 int x, y;
182
183 /* XP_SIZE */
184 unsigned int width, height;
185 int bit_gravity; /* how to resize the backing store */
186
187 /* XP_SHAPE */
188 int shape_nrects; /* -1 = remove shape */
189 xp_box *shape_rects;
190 int shape_tx, shape_ty; /* translation for shape */
191
192 /* XP_STACKING */
193 int stack_mode;
194 xp_window_id sibling; /* may be zero; in ABOVE/BELOW modes
195 it may specify a relative window */
196 /* XP_DEPTH, window-only */
197 unsigned int depth;
198
199 /* XP_COLORMAP, window-only */
200 xp_colormap_fun *colormap;
201 void *colormap_data;
202
203 /* XP_WINDOW_LEVEL, window-only */
204 int window_level;
205};
206
207typedef struct xp_window_changes_struct xp_window_changes;
208
209/* Values for bit_gravity field */
210
211enum xp_bit_gravity_enum {
212 XP_GRAVITY_NONE = 0, /* no gravity, fill everything */
213 XP_GRAVITY_NORTH_WEST = 1, /* anchor to top-left corner */
214 XP_GRAVITY_NORTH_EAST = 2, /* anchor to top-right corner */
215 XP_GRAVITY_SOUTH_EAST = 3, /* anchor to bottom-right corner */
216 XP_GRAVITY_SOUTH_WEST = 4, /* anchor to bottom-left corner */
217};
218
219/* Values for stack_mode field */
220
221enum xp_window_stack_mode_enum {
222 XP_UNMAPPED = 0, /* remove the window */
223 XP_MAPPED_ABOVE = 1, /* display the window on top */
224 XP_MAPPED_BELOW = 2, /* display the window at bottom */
225};
226
227/* Data formats for depth field and composite functions */
228
229enum xp_depth_enum {
230 XP_DEPTH_NIL = 0, /* null source when compositing */
231 XP_DEPTH_ARGB8888,
232 XP_DEPTH_RGB555,
233 XP_DEPTH_A8, /* for masks when compositing */
234 XP_DEPTH_INDEX8,
235};
236
237/* Options that may be passed to the xp_init () function. */
238
239enum xp_init_options_enum {
240 /* Don't mark that this process can be in the foreground. */
241 XP_IN_BACKGROUND = 1 << 0,
242
243 /* Deliver background pointer events to this process. */
244 XP_BACKGROUND_EVENTS = 1 << 1,
245};
246
247
248
249/* Miscellaneous functions */
250
251/* Initialize the plugin library. Only the copy/fill/composite functions
252 may be called without having previously called xp_init () */
253
254extern xp_error xp_init (unsigned int options);
255
256/* Sets the current set of requested notifications to MASK. When any of
257 these arrive, CALLBACK will be invoked with CALLBACK-DATA. Note that
258 calling this function cancels any previously requested notifications
259 that aren't set in MASK. */
260
261extern xp_error xp_select_events (unsigned int mask,
262 xp_event_fun *callback,
263 void *callback_data);
264
265/* Waits for all initiated operations to complete. */
266
267extern xp_error xp_synchronize (void);
268
269/* Causes any display update initiated through the plugin libary to be
270 queued until update is reenabled. Note that calls to these functions
271 nest. */
272
273extern xp_error xp_disable_update (void);
274extern xp_error xp_reenable_update (void);
275
276
277
278/* Cursor functions. */
279
280/* Installs the specified cursor. ARGB-DATA should point to 32-bit
281 premultiplied big-endian ARGB data. The HOT-X,HOT-Y parameters
282 specify the offset to the cursor's hot spot from its top-left
283 corner. */
284
285extern xp_error xp_set_cursor (unsigned int width, unsigned int height,
286 unsigned int hot_x, unsigned int hot_y,
287 const uint32_t *argb_data,
288 unsigned int rowbytes);
289
290/* Hide and show the cursor if it's owned by the current process. Calls
291 to these functions nest. */
292
293extern xp_error xp_hide_cursor (void);
294extern xp_error xp_show_cursor (void);
295
296
297
298/* Window functions. */
299
300/* Create a new window as defined by MASK and VALUES. MASK must contain
301 XP_BOUNDS or an error is raised. The id of the newly created window
302 is stored in *RET-ID if this function returns XP_Success. */
303
304extern xp_error xp_create_window (unsigned int mask,
305 const xp_window_changes *values,
306 xp_window_id *ret_id);
307
308/* Destroys the window identified by ID. */
309
310extern xp_error xp_destroy_window (xp_window_id id);
311
312/* Reconfigures the given window according to MASK and VALUES. */
313
314extern xp_error xp_configure_window (xp_window_id id, unsigned int mask,
315 const xp_window_changes *values);
316
317
318/* Returns true if NATIVE-ID is a window created by the plugin library.
319 If so and RET-ID is non-null, stores the id of the window in *RET-ID. */
320
321extern xp_bool xp_lookup_native_window (unsigned int native_id,
322 xp_window_id *ret_id);
323
324/* If ID names a window created by the plugin library, stores it's native
325 window id in *RET-NATIVE-ID. */
326
327extern xp_error xp_get_native_window (xp_window_id id,
328 unsigned int *ret_native_id);
329
330
331/* Locks the rectangle IN-RECT (or, if null, the entire window) of the
332 given window's backing store. Any other non-null parameters are filled
333 in as follows:
334
335 DEPTH = format of returned data. Currently either XP_DEPTH_ARGB8888
336 or XP_DEPTH_RGB565 (possibly with 8 bit planar alpha). Data is
337 always stored in native byte order.
338
339 BITS[0] = pointer to top-left pixel of locked color data
340 BITS[1] = pointer to top-left of locked alpha data, or null if window
341 has no alpha. If the alpha data is meshed, then BITS[1] = BITS[0].
342
343 ROWBYTES[0,1] = size in bytes of each row of color,alpha data
344
345 OUT-RECT = rectangle specifying the current position and size of the
346 locked region relative to the window origin.
347
348 Note that an error is raised when trying to lock an already locked
349 window. While the window is locked, the only operations that may
350 be performed on it are to modify, access or flush its marked region. */
351
352extern xp_error xp_lock_window (xp_window_id id,
353 const xp_box *in_rect,
354 unsigned int *depth,
355 void *bits[2],
356 unsigned int rowbytes[2],
357 xp_box *out_rect);
358
359/* Mark that the region specified by SHAPE-NRECTS, SHAPE-RECTS,
360 SHAPE-TX, and SHAPE-TY in the specified window has been updated, and
361 will need to subsequently be redisplayed. */
362
363extern xp_error xp_mark_window (xp_window_id id, int shape_nrects,
364 const xp_box *shape_rects,
365 int shape_tx, int shape_ty);
366
367/* Unlocks the specified window. If FLUSH is true, then any marked
368 regions are immediately redisplayed. Note that it's an error to
369 unlock an already unlocked window. */
370
371extern xp_error xp_unlock_window (xp_window_id id, xp_bool flush);
372
373/* If anything is marked in the given window for redisplay, do it now. */
374
375extern xp_error xp_flush_window (xp_window_id id);
376
377/* Moves the contents of the region DX,DY pixels away from that specified
378 by DST_RECTS and DST_NRECTS in the window with SRC-ID to the
379 destination region in the window DST-ID. Note that currently source
380 and destination windows must be the same. */
381
382extern xp_error xp_copy_window (xp_window_id src_id, xp_window_id dst_id,
383 int dst_nrects, const xp_box *dst_rects,
384 int dx, int dy);
385
386/* Returns true if the given window has any regions marked for
387 redisplay. */
388
389extern xp_bool xp_is_window_marked (xp_window_id id);
390
391/* If successful returns a superset of the region marked for update in
392 the given window. Use xp_free_region () to release the returned data. */
393
394extern xp_error xp_get_marked_shape (xp_window_id id,
395 int *ret_nrects, xp_box **ret_rects);
396
397extern void xp_free_shape (int nrects, xp_box *rects);
398
399/* Searches for the first window below ABOVE-ID containing the point X,Y,
400 and returns it's window id in *RET-ID. If no window is found, *RET-ID
401 is set to zero. If ABOVE-ID is zero, finds the topmost window
402 containing the given point. */
403
404extern xp_error xp_find_window (int x, int y, xp_window_id above_id,
405 xp_window_id *ret_id);
406
407/* Returns the current origin and size of the window ID in *BOUNDS-RET if
408 successful. */
409extern xp_error xp_get_window_bounds (xp_window_id id, xp_box *bounds_ret);
410
411
412
413/* Window surface functions. */
414
415/* Create a new VRAM surface on the specified window. If successful,
416 returns the identifier of the new surface in *RET-SID. */
417
418extern xp_error xp_create_surface (xp_window_id id, xp_surface_id *ret_sid);
419
420/* Destroys the specified surface. */
421
422extern xp_error xp_destroy_surface (xp_surface_id sid);
423
424/* Reconfigures the specified surface as defined by MASK and VALUES.
425 Note that specifying XP_DEPTH is an error. */
426
427extern xp_error xp_configure_surface (xp_surface_id sid, unsigned int mask,
428 const xp_window_changes *values);
429
430/* If successful, places the client identifier of the current process
431 in *RET-CLIENT. */
432
433extern xp_error xp_get_client_id (xp_client_id *ret_client);
434
435/* Given a valid window,surface combination created by the current
436 process, attempts to allow the specified external client access
437 to that surface. If successful, returns two integers in RET-KEY
438 which the client can use to import the surface into their process. */
439
440extern xp_error xp_export_surface (xp_window_id wid, xp_surface_id sid,
441 xp_client_id client,
442 unsigned int ret_key[2]);
443
444/* Given a two integer key returned from xp_export_surface (), tries
445 to import the surface into the current process. If successful the
446 local surface identifier is stored in *SID-RET. */
447
448extern xp_error xp_import_surface (const unsigned int key[2],
449 xp_surface_id *sid_ret);
450
451/* If successful, stores the number of surfaces attached to the
452 specified window in *RET. */
453
454extern xp_error xp_get_window_surface_count (xp_window_id id,
455 unsigned int *ret);
456
457/* Attaches the CGLContextObj CGL-CTX to the specified surface. */
458
459extern xp_error xp_attach_gl_context (void *cgl_ctx, xp_surface_id sid);
460
461/* Updates the CGLContextObj CGL-CTX to reflect any recent changes to
462 the surface it's attached to. */
463
464extern xp_error xp_update_gl_context (void *cgl_ctx);
465
466
467
468/* Window frame functions. */
469
470/* Possible arguments to xp_frame_get_rect (). */
471
472enum xp_frame_rect_enum {
473 XP_FRAME_RECT_TITLEBAR = 1,
474 XP_FRAME_RECT_TRACKING = 2,
475 XP_FRAME_RECT_GROWBOX = 3,
476};
477
478/* Classes of window frame. */
479
480enum xp_frame_class_enum {
481 XP_FRAME_CLASS_DOCUMENT = 1 << 0,
482 XP_FRAME_CLASS_DIALOG = 1 << 1,
483 XP_FRAME_CLASS_MODAL_DIALOG = 1 << 2,
484 XP_FRAME_CLASS_SYSTEM_MODAL_DIALOG = 1 << 3,
485 XP_FRAME_CLASS_UTILITY = 1 << 4,
486 XP_FRAME_CLASS_TOOLBAR = 1 << 5,
487 XP_FRAME_CLASS_MENU = 1 << 6,
488 XP_FRAME_CLASS_SPLASH = 1 << 7,
489 XP_FRAME_CLASS_BORDERLESS = 1 << 8,
490};
491
492/* Attributes of window frames. */
493
494enum xp_frame_attr_enum {
495 XP_FRAME_ACTIVE = 0x0001,
496 XP_FRAME_URGENT = 0x0002,
497 XP_FRAME_TITLE = 0x0004,
498 XP_FRAME_PRELIGHT = 0x0008,
499 XP_FRAME_SHADED = 0x0010,
500 XP_FRAME_CLOSE_BOX = 0x0100,
501 XP_FRAME_COLLAPSE = 0x0200,
502 XP_FRAME_ZOOM = 0x0400,
503 XP_FRAME_ANY_BUTTON = 0x0700,
504 XP_FRAME_CLOSE_BOX_CLICKED = 0x0800,
505 XP_FRAME_COLLAPSE_BOX_CLICKED = 0x1000,
506 XP_FRAME_ZOOM_BOX_CLICKED = 0x2000,
507 XP_FRAME_ANY_CLICKED = 0x3800,
508 XP_FRAME_GROW_BOX = 0x4000,
509};
510
511#define XP_FRAME_ATTR_IS_SET(a,b) (((a) & (b)) == (b))
512#define XP_FRAME_ATTR_IS_CLICKED(a,m) ((a) & ((m) << 3))
513#define XP_FRAME_ATTR_SET_CLICKED(a,m) ((a) |= ((m) << 3))
514#define XP_FRAME_ATTR_UNSET_CLICKED(a,m) ((a) &= ~((m) << 3))
515
516#define XP_FRAME_POINTER_ATTRS (XP_FRAME_PRELIGHT \
517 | XP_FRAME_ANY_BUTTON \
518 | XP_FRAME_ANY_CLICKED)
519
520extern xp_error xp_frame_get_rect (int type, int class, const xp_box *outer,
521 const xp_box *inner, xp_box *ret);
522extern xp_error xp_frame_hit_test (int class, int x, int y,
523 const xp_box *outer,
524 const xp_box *inner, int *ret);
525extern xp_error xp_frame_draw (xp_window_id wid, int class, unsigned int attr,
526 const xp_box *outer, const xp_box *inner,
527 unsigned int title_len,
528 const unsigned char *title_bytes);
529
530
531
532/* Memory manipulation functions. */
533
534enum xp_composite_op_enum {
535 XP_COMPOSITE_SRC = 0,
536 XP_COMPOSITE_OVER,
537};
538
539#define XP_COMPOSITE_FUNCTION(op, src_depth, mask_depth, dest_depth) \
540 (((op) << 24) | ((src_depth) << 16) \
541 | ((mask_depth) << 8) | ((dest_depth) << 0))
542
543#define XP_COMPOSITE_FUNCTION_OP(f) (((f) >> 24) & 255)
544#define XP_COMPOSITE_FUNCTION_SRC_DEPTH(f) (((f) >> 16) & 255)
545#define XP_COMPOSITE_FUNCTION_MASK_DEPTH(f) (((f) >> 8) & 255)
546#define XP_COMPOSITE_FUNCTION_DEST_DEPTH(f) (((f) >> 0) & 255)
547
548/* Composite WIDTH by HEIGHT pixels from source and mask to destination
549 using a specified function (if source and destination overlap,
550 undefined behavior results).
551
552 For SRC and DEST, the first element of the array is the color data. If
553 the second element is non-null it implies that there is alpha data
554 (which may be meshed or planar). Data without alpha is assumed to be
555 opaque.
556
557 Passing a null SRC-ROWBYTES pointer implies that the data SRC points
558 to is a single element.
559
560 Operations that are not supported will return XP_BadImplementation. */
561
562extern xp_error xp_composite_pixels (unsigned int width, unsigned int height,
563 unsigned int function,
564 void *src[2], unsigned int src_rowbytes[2],
565 void *mask, unsigned int mask_rowbytes,
566 void *dest[2], unsigned int dest_rowbytes[2]);
567
568/* Fill HEIGHT rows of data starting at DST. Each row will have WIDTH
569 bytes filled with the 32-bit pattern VALUE. Each row is DST-ROWBYTES
570 wide in total. */
571
572extern void xp_fill_bytes (unsigned int width,
573 unsigned int height, uint32_t value,
574 void *dst, unsigned int dst_rowbytes);
575
576/* Copy HEIGHT rows of bytes from SRC to DST. Each row will have WIDTH
577 bytes copied. SRC and DST may overlap, and the right thing will happen. */
578
579extern void xp_copy_bytes (unsigned int width, unsigned int height,
580 const void *src, unsigned int src_rowbytes,
581 void *dst, unsigned int dst_rowbytes);
582
583/* Suggestions for the minimum number of bytes or pixels for which it
584 makes sense to use some of the xp_ functions */
585
586extern unsigned int xp_fill_bytes_threshold, xp_copy_bytes_threshold,
587 xp_composite_area_threshold, xp_scroll_area_threshold;
588
589
590#endif /* XPLUGIN_H */
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette