ucrtbase: Store exception record in ExceptionInformation[6] during unwinding.
[wine.git] / dlls / winex11.drv / x11drv.h
blob49e4f039b181cd7f3c44dd7560b5e662c3c66890
1 /*
2 * X11 driver definitions
4 * Copyright 1996 Alexandre Julliard
5 * Copyright 1999 Patrik Stridvall
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #ifndef __WINE_X11DRV_H
23 #define __WINE_X11DRV_H
25 #ifndef __WINE_CONFIG_H
26 # error You must include config.h to use this header
27 #endif
29 #include <limits.h>
30 #include <stdarg.h>
31 #include <stdlib.h>
32 #include <pthread.h>
33 #include <X11/Xlib.h>
34 #include <X11/Xresource.h>
35 #include <X11/Xutil.h>
36 #include <X11/Xatom.h>
37 #ifdef HAVE_X11_EXTENSIONS_XINPUT2_H
38 #include <X11/extensions/XInput2.h>
39 #endif
41 #define BOOL X_BOOL
42 #define BYTE X_BYTE
43 #define INT8 X_INT8
44 #define INT16 X_INT16
45 #define INT32 X_INT32
46 #define INT64 X_INT64
47 #include <X11/Xmd.h>
48 #include <X11/Xproto.h>
49 #undef BOOL
50 #undef BYTE
51 #undef INT8
52 #undef INT16
53 #undef INT32
54 #undef INT64
55 #undef LONG64
57 #undef Status /* avoid conflict with wintrnl.h */
58 typedef int Status;
60 /* avoid conflict with processthreadsapi.h */
61 #undef ControlMask
63 #include "windef.h"
64 #include "winbase.h"
65 #include "ntgdi.h"
66 #include "wine/gdi_driver.h"
67 #include "unixlib.h"
68 #include "wine/list.h"
69 #include "wine/debug.h"
71 #define MAX_DASHLEN 16
73 #define WINE_XDND_VERSION 5
75 /* X physical pen */
76 typedef struct
78 int style;
79 int endcap;
80 int linejoin;
81 int pixel;
82 int width;
83 char dashes[MAX_DASHLEN];
84 int dash_len;
85 int type; /* GEOMETRIC || COSMETIC */
86 int ext; /* extended pen - 1, otherwise - 0 */
87 } X_PHYSPEN;
89 /* X physical brush */
90 typedef struct
92 int style;
93 int fillStyle;
94 int pixel;
95 Pixmap pixmap;
96 } X_PHYSBRUSH;
98 typedef struct {
99 int shift;
100 int scale;
101 int max;
102 } ChannelShift;
104 typedef struct
106 ChannelShift physicalRed, physicalGreen, physicalBlue;
107 ChannelShift logicalRed, logicalGreen, logicalBlue;
108 } ColorShifts;
110 /* X physical device */
111 typedef struct
113 struct gdi_physdev dev;
114 GC gc; /* X Window GC */
115 Drawable drawable;
116 RECT dc_rect; /* DC rectangle relative to drawable */
117 RECT *bounds; /* Graphics bounds */
118 HRGN region; /* Device region (visible region & clip region) */
119 X_PHYSPEN pen;
120 X_PHYSBRUSH brush;
121 int depth; /* bit depth of the DC */
122 ColorShifts *color_shifts; /* color shifts of the DC */
123 int exposures; /* count of graphics exposures operations */
124 } X11DRV_PDEVICE;
126 #define GAMMA_RAMP_SIZE 256
128 struct x11drv_gamma_ramp
130 WORD red[GAMMA_RAMP_SIZE];
131 WORD green[GAMMA_RAMP_SIZE];
132 WORD blue[GAMMA_RAMP_SIZE];
135 static inline X11DRV_PDEVICE *get_x11drv_dev( PHYSDEV dev )
137 return (X11DRV_PDEVICE *)dev;
140 static inline void reset_bounds( RECT *bounds )
142 bounds->left = bounds->top = INT_MAX;
143 bounds->right = bounds->bottom = INT_MIN;
146 static inline void add_bounds_rect( RECT *bounds, const RECT *rect )
148 if (rect->left >= rect->right || rect->top >= rect->bottom) return;
149 bounds->left = min( bounds->left, rect->left );
150 bounds->top = min( bounds->top, rect->top );
151 bounds->right = max( bounds->right, rect->right );
152 bounds->bottom = max( bounds->bottom, rect->bottom );
155 /* Wine driver X11 functions */
157 extern BOOL X11DRV_Arc( PHYSDEV dev, INT left, INT top, INT right,
158 INT bottom, INT xstart, INT ystart, INT xend, INT yend );
159 extern BOOL X11DRV_Chord( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
160 INT xstart, INT ystart, INT xend, INT yend );
161 extern BOOL X11DRV_Ellipse( PHYSDEV dev, INT left, INT top, INT right, INT bottom );
162 extern BOOL X11DRV_ExtFloodFill( PHYSDEV dev, INT x, INT y, COLORREF color, UINT fillType );
163 extern BOOL X11DRV_FillPath( PHYSDEV dev );
164 extern BOOL X11DRV_GetDeviceGammaRamp( PHYSDEV dev, LPVOID ramp );
165 extern BOOL X11DRV_GetICMProfile( PHYSDEV dev, BOOL allow_default, LPDWORD size, LPWSTR filename );
166 extern DWORD X11DRV_GetImage( PHYSDEV dev, BITMAPINFO *info,
167 struct gdi_image_bits *bits, struct bitblt_coords *src );
168 extern COLORREF X11DRV_GetNearestColor( PHYSDEV dev, COLORREF color );
169 extern UINT X11DRV_GetSystemPaletteEntries( PHYSDEV dev, UINT start, UINT count, LPPALETTEENTRY entries );
170 extern BOOL X11DRV_GradientFill( PHYSDEV dev, TRIVERTEX *vert_array, ULONG nvert,
171 void *grad_array, ULONG ngrad, ULONG mode );
172 extern BOOL X11DRV_LineTo( PHYSDEV dev, INT x, INT y);
173 extern BOOL X11DRV_PaintRgn( PHYSDEV dev, HRGN hrgn );
174 extern BOOL X11DRV_PatBlt( PHYSDEV dev, struct bitblt_coords *dst, DWORD rop );
175 extern BOOL X11DRV_Pie( PHYSDEV dev, INT left, INT top, INT right,
176 INT bottom, INT xstart, INT ystart, INT xend, INT yend );
177 extern BOOL X11DRV_PolyPolygon( PHYSDEV dev, const POINT* pt, const INT* counts, UINT polygons);
178 extern BOOL X11DRV_PolyPolyline( PHYSDEV dev, const POINT* pt, const DWORD* counts, DWORD polylines);
179 extern DWORD X11DRV_PutImage( PHYSDEV dev, HRGN clip, BITMAPINFO *info,
180 const struct gdi_image_bits *bits, struct bitblt_coords *src,
181 struct bitblt_coords *dst, DWORD rop );
182 extern UINT X11DRV_RealizeDefaultPalette( PHYSDEV dev );
183 extern UINT X11DRV_RealizePalette( PHYSDEV dev, HPALETTE hpal, BOOL primary );
184 extern BOOL X11DRV_Rectangle(PHYSDEV dev, INT left, INT top, INT right, INT bottom);
185 extern BOOL X11DRV_RoundRect( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
186 INT ell_width, INT ell_height );
187 extern HBRUSH X11DRV_SelectBrush( PHYSDEV dev, HBRUSH hbrush, const struct brush_pattern *pattern );
188 extern HPEN X11DRV_SelectPen( PHYSDEV dev, HPEN hpen, const struct brush_pattern *pattern );
189 extern COLORREF X11DRV_SetDCBrushColor( PHYSDEV dev, COLORREF crColor );
190 extern COLORREF X11DRV_SetDCPenColor( PHYSDEV dev, COLORREF crColor );
191 extern void X11DRV_SetDeviceClipping( PHYSDEV dev, HRGN rgn );
192 extern BOOL X11DRV_SetDeviceGammaRamp( PHYSDEV dev, LPVOID ramp );
193 extern COLORREF X11DRV_SetPixel( PHYSDEV dev, INT x, INT y, COLORREF color );
194 extern BOOL X11DRV_StretchBlt( PHYSDEV dst_dev, struct bitblt_coords *dst,
195 PHYSDEV src_dev, struct bitblt_coords *src, DWORD rop );
196 extern BOOL X11DRV_StrokeAndFillPath( PHYSDEV dev );
197 extern BOOL X11DRV_StrokePath( PHYSDEV dev );
198 extern BOOL X11DRV_UnrealizePalette( HPALETTE hpal );
200 extern BOOL X11DRV_ActivateKeyboardLayout( HKL hkl, UINT flags );
201 extern void X11DRV_Beep(void);
202 extern INT X11DRV_GetKeyNameText( LONG lparam, LPWSTR buffer, INT size );
203 extern UINT X11DRV_MapVirtualKeyEx( UINT code, UINT map_type, HKL hkl );
204 extern INT X11DRV_ToUnicodeEx( UINT virtKey, UINT scanCode, const BYTE *lpKeyState,
205 LPWSTR bufW, int bufW_size, UINT flags, HKL hkl );
206 extern SHORT X11DRV_VkKeyScanEx( WCHAR wChar, HKL hkl );
207 extern void X11DRV_NotifyIMEStatus( HWND hwnd, UINT status );
208 extern void X11DRV_DestroyCursorIcon( HCURSOR handle );
209 extern void X11DRV_SetCursor( HWND hwnd, HCURSOR handle );
210 extern BOOL X11DRV_SetCursorPos( INT x, INT y );
211 extern BOOL X11DRV_GetCursorPos( LPPOINT pos );
212 extern BOOL X11DRV_ClipCursor( const RECT *clip, BOOL reset );
213 extern void X11DRV_SystrayDockInit( HWND systray );
214 extern BOOL X11DRV_SystrayDockInsert( HWND owner, UINT cx, UINT cy, void *icon );
215 extern void X11DRV_SystrayDockClear( HWND hwnd );
216 extern BOOL X11DRV_SystrayDockRemove( HWND hwnd );
217 extern LONG X11DRV_ChangeDisplaySettings( LPDEVMODEW displays, LPCWSTR primary_name, HWND hwnd, DWORD flags, LPVOID lpvoid );
218 extern BOOL X11DRV_GetCurrentDisplaySettings( LPCWSTR name, BOOL is_primary, LPDEVMODEW devmode );
219 extern INT X11DRV_GetDisplayDepth( LPCWSTR name, BOOL is_primary );
220 extern UINT X11DRV_UpdateDisplayDevices( const struct gdi_device_manager *device_manager, void *param );
221 extern BOOL X11DRV_CreateDesktop( const WCHAR *name, UINT width, UINT height );
222 extern BOOL X11DRV_CreateWindow( HWND hwnd );
223 extern LRESULT X11DRV_DesktopWindowProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp );
224 extern void X11DRV_DestroyWindow( HWND hwnd );
225 extern void X11DRV_FlashWindowEx( PFLASHWINFO pfinfo );
226 extern void X11DRV_GetDC( HDC hdc, HWND hwnd, HWND top, const RECT *win_rect,
227 const RECT *top_rect, DWORD flags );
228 extern void X11DRV_ReleaseDC( HWND hwnd, HDC hdc );
229 extern BOOL X11DRV_ScrollDC( HDC hdc, INT dx, INT dy, HRGN update );
230 extern void X11DRV_SetCapture( HWND hwnd, UINT flags );
231 extern void X11DRV_SetDesktopWindow( HWND hwnd );
232 extern void X11DRV_SetLayeredWindowAttributes( HWND hwnd, COLORREF key, BYTE alpha,
233 DWORD flags );
234 extern void X11DRV_SetParent( HWND hwnd, HWND parent, HWND old_parent );
235 extern void X11DRV_SetWindowIcon( HWND hwnd, UINT type, HICON icon );
236 extern void X11DRV_SetWindowRgn( HWND hwnd, HRGN hrgn, BOOL redraw );
237 extern void X11DRV_SetWindowStyle( HWND hwnd, INT offset, STYLESTRUCT *style );
238 extern void X11DRV_SetWindowText( HWND hwnd, LPCWSTR text );
239 extern UINT X11DRV_ShowWindow( HWND hwnd, INT cmd, RECT *rect, UINT swp );
240 extern LRESULT X11DRV_SysCommand( HWND hwnd, WPARAM wparam, LPARAM lparam );
241 extern LRESULT X11DRV_ClipboardWindowProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp );
242 extern void X11DRV_UpdateClipboard(void);
243 extern BOOL X11DRV_CreateLayeredWindow( HWND hwnd, const RECT *window_rect, COLORREF color_key,
244 struct window_surface **surface );
245 extern void X11DRV_UpdateLayeredWindow( HWND hwnd, const RECT *window_rect, COLORREF color_key,
246 BYTE alpha, UINT flags );
247 extern LRESULT X11DRV_WindowMessage( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp );
248 extern BOOL X11DRV_WindowPosChanging( HWND hwnd, UINT swp_flags, const RECT *window_rect, const RECT *client_rect, RECT *visible_rect );
249 extern BOOL X11DRV_CreateWindowSurface( HWND hwnd, const RECT *surface_rect, struct window_surface **surface );
250 extern void X11DRV_WindowPosChanged( HWND hwnd, HWND insert_after, UINT swp_flags,
251 const RECT *rectWindow, const RECT *rectClient,
252 const RECT *visible_rect, const RECT *valid_rects,
253 struct window_surface *surface );
254 extern BOOL X11DRV_SystemParametersInfo( UINT action, UINT int_param, void *ptr_param,
255 UINT flags );
256 extern void X11DRV_ThreadDetach(void);
258 /* X11 driver internal functions */
260 extern void X11DRV_Xcursor_Init(void);
262 extern DWORD copy_image_bits( BITMAPINFO *info, BOOL is_r8g8b8, XImage *image,
263 const struct gdi_image_bits *src_bits, struct gdi_image_bits *dst_bits,
264 struct bitblt_coords *coords, const int *mapping, unsigned int zeropad_mask );
265 extern Pixmap create_pixmap_from_image( HDC hdc, const XVisualInfo *vis, const BITMAPINFO *info,
266 const struct gdi_image_bits *bits, UINT coloruse );
267 extern DWORD get_pixmap_image( Pixmap pixmap, int width, int height, const XVisualInfo *vis,
268 BITMAPINFO *info, struct gdi_image_bits *bits );
269 extern HRGN expose_surface( struct window_surface *window_surface, const RECT *rect );
271 extern RGNDATA *X11DRV_GetRegionData( HRGN hrgn, HDC hdc_lptodp );
272 extern BOOL add_extra_clipping_region( X11DRV_PDEVICE *dev, HRGN rgn );
273 extern void restore_clipping_region( X11DRV_PDEVICE *dev );
274 extern void add_device_bounds( X11DRV_PDEVICE *dev, const RECT *rect );
276 extern void execute_rop( X11DRV_PDEVICE *physdev, Pixmap src_pixmap, GC gc, const RECT *visrect, DWORD rop );
278 extern BOOL X11DRV_SetupGCForPatBlt( X11DRV_PDEVICE *physDev, GC gc, BOOL fMapColors );
279 extern BOOL X11DRV_SetupGCForBrush( X11DRV_PDEVICE *physDev );
280 extern INT X11DRV_XWStoDS( HDC hdc, INT width );
281 extern INT X11DRV_YWStoDS( HDC hdc, INT height );
283 extern BOOL client_side_graphics;
284 extern BOOL client_side_with_render;
285 extern BOOL shape_layered_windows;
286 extern const struct gdi_dc_funcs *X11DRV_XRender_Init(void);
288 extern struct opengl_funcs *get_glx_driver(UINT);
289 extern UINT X11DRV_VulkanInit( UINT, void *, const struct vulkan_driver_funcs ** );
291 extern struct format_entry *import_xdnd_selection( Display *display, Window win, Atom selection,
292 Atom *targets, UINT count,
293 size_t *size );
295 /**************************************************************************
296 * X11 GDI driver
299 extern Display *gdi_display; /* display to use for all GDI functions */
301 /* X11 GDI palette driver */
303 #define X11DRV_PALETTE_FIXED 0x0001 /* read-only colormap - have to use XAllocColor (if not virtual) */
304 #define X11DRV_PALETTE_VIRTUAL 0x0002 /* no mapping needed - pixel == pixel color */
306 #define X11DRV_PALETTE_PRIVATE 0x1000 /* private colormap, identity mapping */
308 extern UINT16 X11DRV_PALETTE_PaletteFlags;
310 extern int *X11DRV_PALETTE_PaletteToXPixel;
311 extern int *X11DRV_PALETTE_XPixelToPalette;
312 extern ColorShifts X11DRV_PALETTE_default_shifts;
314 extern int X11DRV_PALETTE_mapEGAPixel[16];
316 extern int X11DRV_PALETTE_Init(void);
317 extern BOOL X11DRV_IsSolidColor(COLORREF color);
319 extern COLORREF X11DRV_PALETTE_ToLogical(X11DRV_PDEVICE *physDev, int pixel);
320 extern int X11DRV_PALETTE_ToPhysical(X11DRV_PDEVICE *physDev, COLORREF color);
321 extern COLORREF X11DRV_PALETTE_GetColor( X11DRV_PDEVICE *physDev, COLORREF color );
322 extern int *get_window_surface_mapping( int bpp, int *mapping );
324 static inline const char *debugstr_color( COLORREF color )
326 if (color & (1 << 24)) /* PALETTEINDEX */
327 return wine_dbg_sprintf( "PALETTEINDEX(%u)", LOWORD(color) );
328 if (color >> 16 == 0x10ff) /* DIBINDEX */
329 return wine_dbg_sprintf( "DIBINDEX(%u)", LOWORD(color) );
330 return wine_dbg_sprintf( "RGB(%02x,%02x,%02x)", GetRValue(color), GetGValue(color), GetBValue(color) );
333 /* GDI escapes */
335 #define X11DRV_ESCAPE 6789
336 enum x11drv_escape_codes
338 X11DRV_SET_DRAWABLE, /* set current drawable for a DC */
339 X11DRV_GET_DRAWABLE, /* get current drawable for a DC */
340 X11DRV_START_EXPOSURES, /* start graphics exposures */
341 X11DRV_END_EXPOSURES, /* end graphics exposures */
342 X11DRV_FLUSH_GL_DRAWABLE /* flush changes made to the gl drawable */
345 struct x11drv_escape_set_drawable
347 enum x11drv_escape_codes code; /* escape code (X11DRV_SET_DRAWABLE) */
348 Drawable drawable; /* X drawable */
349 int mode; /* ClipByChildren or IncludeInferiors */
350 RECT dc_rect; /* DC rectangle relative to drawable */
353 struct x11drv_escape_get_drawable
355 enum x11drv_escape_codes code; /* escape code (X11DRV_GET_DRAWABLE) */
356 Drawable drawable; /* X drawable */
357 Drawable gl_drawable; /* GL drawable */
358 int pixel_format; /* internal GL pixel format */
361 struct x11drv_escape_flush_gl_drawable
363 enum x11drv_escape_codes code; /* escape code (X11DRV_FLUSH_GL_DRAWABLE) */
364 Drawable gl_drawable; /* GL drawable */
365 BOOL flush; /* flush X11 before copying */
368 /**************************************************************************
369 * X11 USER driver
372 struct x11drv_thread_data
374 Display *display;
375 XEvent *current_event; /* event currently being processed */
376 HWND grab_hwnd; /* window that currently grabs the mouse */
377 HWND last_focus; /* last window that had focus */
378 HWND keymapnotify_hwnd; /* window that should receive modifier release events */
379 XIM xim; /* input method */
380 HWND last_xic_hwnd; /* last xic window */
381 XFontSet font_set; /* international text drawing font set */
382 Window selection_wnd; /* window used for selection interactions */
383 unsigned long warp_serial; /* serial number of last pointer warp request */
384 Window clip_window; /* window used for cursor clipping */
385 BOOL clipping_cursor; /* whether thread is currently clipping the cursor */
386 #ifdef HAVE_X11_EXTENSIONS_XINPUT2_H
387 XIValuatorClassInfo x_valuator;
388 XIValuatorClassInfo y_valuator;
389 int xinput2_pointer; /* XInput2 master pointer device id */
390 #endif /* HAVE_X11_EXTENSIONS_XINPUT2_H */
393 extern struct x11drv_thread_data *x11drv_init_thread_data(void);
395 static inline struct x11drv_thread_data *x11drv_thread_data(void)
397 return (struct x11drv_thread_data *)(UINT_PTR)NtUserGetThreadInfo()->driver_data;
400 /* retrieve the thread display, or NULL if not created yet */
401 static inline Display *thread_display(void)
403 struct x11drv_thread_data *data = x11drv_thread_data();
404 if (!data) return NULL;
405 return data->display;
408 /* retrieve the thread display, creating it if needed */
409 static inline Display *thread_init_display(void)
411 return x11drv_init_thread_data()->display;
414 static inline size_t get_property_size( int format, unsigned long count )
416 /* format==32 means long, which can be 64 bits... */
417 if (format == 32) return count * sizeof(long);
418 return count * (format / 8);
421 extern XVisualInfo default_visual;
422 extern XVisualInfo argb_visual;
423 extern Colormap default_colormap;
424 extern XPixmapFormatValues **pixmap_formats;
425 extern Window root_window;
426 extern BOOL clipping_cursor;
427 extern BOOL keyboard_grabbed;
428 extern unsigned int screen_bpp;
429 extern BOOL usexrandr;
430 extern BOOL usexvidmode;
431 extern BOOL use_take_focus;
432 extern BOOL use_primary_selection;
433 extern BOOL use_system_cursors;
434 extern BOOL grab_fullscreen;
435 extern BOOL usexcomposite;
436 extern BOOL managed_mode;
437 extern BOOL decorated_mode;
438 extern BOOL private_color_map;
439 extern int primary_monitor;
440 extern int copy_default_colors;
441 extern int alloc_system_colors;
442 extern int xrender_error_base;
443 extern char *process_name;
444 extern Display *clipboard_display;
445 extern WNDPROC client_foreign_window_proc;
447 /* atoms */
449 enum x11drv_atoms
451 FIRST_XATOM = XA_LAST_PREDEFINED + 1,
452 XATOM_CLIPBOARD = FIRST_XATOM,
453 XATOM_COMPOUND_TEXT,
454 XATOM_EDID,
455 XATOM_INCR,
456 XATOM_MANAGER,
457 XATOM_MULTIPLE,
458 XATOM_SELECTION_DATA,
459 XATOM_TARGETS,
460 XATOM_TEXT,
461 XATOM_TIMESTAMP,
462 XATOM_UTF8_STRING,
463 XATOM_RAW_ASCENT,
464 XATOM_RAW_DESCENT,
465 XATOM_RAW_CAP_HEIGHT,
466 XATOM_WM_PROTOCOLS,
467 XATOM_WM_DELETE_WINDOW,
468 XATOM_WM_STATE,
469 XATOM_WM_TAKE_FOCUS,
470 XATOM_DndProtocol,
471 XATOM_DndSelection,
472 XATOM__ICC_PROFILE,
473 XATOM__KDE_NET_WM_STATE_SKIP_SWITCHER,
474 XATOM__MOTIF_WM_HINTS,
475 XATOM__NET_STARTUP_INFO_BEGIN,
476 XATOM__NET_STARTUP_INFO,
477 XATOM__NET_SUPPORTED,
478 XATOM__NET_SYSTEM_TRAY_OPCODE,
479 XATOM__NET_SYSTEM_TRAY_S0,
480 XATOM__NET_SYSTEM_TRAY_VISUAL,
481 XATOM__NET_WM_FULLSCREEN_MONITORS,
482 XATOM__NET_WM_ICON,
483 XATOM__NET_WM_MOVERESIZE,
484 XATOM__NET_WM_NAME,
485 XATOM__NET_WM_PID,
486 XATOM__NET_WM_PING,
487 XATOM__NET_WM_STATE,
488 XATOM__NET_WM_STATE_ABOVE,
489 XATOM__NET_WM_STATE_DEMANDS_ATTENTION,
490 XATOM__NET_WM_STATE_FULLSCREEN,
491 XATOM__NET_WM_STATE_MAXIMIZED_HORZ,
492 XATOM__NET_WM_STATE_MAXIMIZED_VERT,
493 XATOM__NET_WM_STATE_SKIP_PAGER,
494 XATOM__NET_WM_STATE_SKIP_TASKBAR,
495 XATOM__NET_WM_USER_TIME,
496 XATOM__NET_WM_USER_TIME_WINDOW,
497 XATOM__NET_WM_WINDOW_OPACITY,
498 XATOM__NET_WM_WINDOW_TYPE,
499 XATOM__NET_WM_WINDOW_TYPE_DIALOG,
500 XATOM__NET_WM_WINDOW_TYPE_NORMAL,
501 XATOM__NET_WM_WINDOW_TYPE_UTILITY,
502 XATOM__NET_WORKAREA,
503 XATOM__GTK_WORKAREAS_D0,
504 XATOM__XEMBED,
505 XATOM__XEMBED_INFO,
506 XATOM_XdndAware,
507 XATOM_XdndEnter,
508 XATOM_XdndPosition,
509 XATOM_XdndStatus,
510 XATOM_XdndLeave,
511 XATOM_XdndFinished,
512 XATOM_XdndDrop,
513 XATOM_XdndActionCopy,
514 XATOM_XdndActionMove,
515 XATOM_XdndActionLink,
516 XATOM_XdndActionAsk,
517 XATOM_XdndActionPrivate,
518 XATOM_XdndSelection,
519 XATOM_XdndTypeList,
520 XATOM_HTML_Format,
521 XATOM_WCF_DIF,
522 XATOM_WCF_ENHMETAFILE,
523 XATOM_WCF_HDROP,
524 XATOM_WCF_PENDATA,
525 XATOM_WCF_RIFF,
526 XATOM_WCF_SYLK,
527 XATOM_WCF_TIFF,
528 XATOM_WCF_WAVE,
529 XATOM_image_bmp,
530 XATOM_image_gif,
531 XATOM_image_jpeg,
532 XATOM_image_png,
533 XATOM_text_html,
534 XATOM_text_plain,
535 XATOM_text_rtf,
536 XATOM_text_richtext,
537 XATOM_text_uri_list,
538 NB_XATOMS
541 extern Atom X11DRV_Atoms[NB_XATOMS - FIRST_XATOM];
542 extern Atom systray_atom;
543 extern HWND systray_hwnd;
545 #define x11drv_atom(name) (X11DRV_Atoms[XATOM_##name - FIRST_XATOM])
547 /* X11 event driver */
549 typedef BOOL (*x11drv_event_handler)( HWND hwnd, XEvent *event );
551 extern void X11DRV_register_event_handler( int type, x11drv_event_handler handler, const char *name );
553 extern BOOL X11DRV_ButtonPress( HWND hwnd, XEvent *event );
554 extern BOOL X11DRV_ButtonRelease( HWND hwnd, XEvent *event );
555 extern BOOL X11DRV_MotionNotify( HWND hwnd, XEvent *event );
556 extern BOOL X11DRV_EnterNotify( HWND hwnd, XEvent *event );
557 extern BOOL X11DRV_KeyEvent( HWND hwnd, XEvent *event );
558 extern BOOL X11DRV_KeymapNotify( HWND hwnd, XEvent *event );
559 extern BOOL X11DRV_DestroyNotify( HWND hwnd, XEvent *event );
560 extern BOOL X11DRV_SelectionRequest( HWND hWnd, XEvent *event );
561 extern BOOL X11DRV_SelectionClear( HWND hWnd, XEvent *event );
562 extern BOOL X11DRV_MappingNotify( HWND hWnd, XEvent *event );
563 extern BOOL X11DRV_GenericEvent( HWND hwnd, XEvent *event );
565 extern int xinput2_opcode;
566 extern void x11drv_xinput2_load(void);
567 extern void x11drv_xinput2_init( struct x11drv_thread_data *data );
568 extern void x11drv_xinput2_enable( Display *display, Window window );
569 extern void x11drv_xinput2_disable( Display *display, Window window );
571 extern Bool (*pXGetEventData)( Display *display, XEvent /*XGenericEventCookie*/ *event );
572 extern void (*pXFreeEventData)( Display *display, XEvent /*XGenericEventCookie*/ *event );
574 extern DWORD EVENT_x11_time_to_win32_time(Time time);
576 /* X11 driver private messages */
577 enum x11drv_window_messages
579 WM_X11DRV_UPDATE_CLIPBOARD = WM_WINE_FIRST_DRIVER_MSG,
580 WM_X11DRV_SET_WIN_REGION,
581 WM_X11DRV_DELETE_TAB,
582 WM_X11DRV_ADD_TAB
585 /* _NET_WM_STATE properties that we keep track of */
586 enum x11drv_net_wm_state
588 KDE_NET_WM_STATE_SKIP_SWITCHER,
589 NET_WM_STATE_FULLSCREEN,
590 NET_WM_STATE_ABOVE,
591 NET_WM_STATE_MAXIMIZED,
592 NET_WM_STATE_SKIP_PAGER,
593 NET_WM_STATE_SKIP_TASKBAR,
594 NB_NET_WM_STATES
597 /* x11drv private window data */
598 struct x11drv_win_data
600 Display *display; /* display connection for the thread owning the window */
601 XVisualInfo vis; /* X visual used by this window */
602 Colormap whole_colormap; /* colormap if non-default visual */
603 HWND hwnd; /* hwnd that this private data belongs to */
604 Window whole_window; /* X window for the complete window */
605 Window client_window; /* X window for the client area */
606 RECT window_rect; /* USER window rectangle relative to win32 parent window client area */
607 RECT whole_rect; /* X window rectangle for the whole window relative to win32 parent window client area */
608 RECT client_rect; /* client area relative to win32 parent window client area */
609 XIC xic; /* X input context */
610 UINT managed : 1; /* is window managed? */
611 UINT mapped : 1; /* is window mapped? (in either normal or iconic state) */
612 UINT iconic : 1; /* is window in iconic state? */
613 UINT embedded : 1; /* is window an XEMBED client? */
614 UINT shaped : 1; /* is window using a custom region shape? */
615 UINT layered : 1; /* is window layered and with valid attributes? */
616 UINT use_alpha : 1; /* does window use an alpha channel? */
617 UINT skip_taskbar : 1; /* does window should be deleted from taskbar */
618 UINT add_taskbar : 1; /* does window should be added to taskbar regardless of style */
619 UINT net_wm_fullscreen_monitors_set : 1; /* is _NET_WM_FULLSCREEN_MONITORS set */
620 int wm_state; /* current value of the WM_STATE property */
621 DWORD net_wm_state; /* bit mask of active x11drv_net_wm_state values */
622 Window embedder; /* window id of embedder */
623 unsigned long configure_serial; /* serial number of last configure request */
624 struct window_surface *surface;
625 Pixmap icon_pixmap;
626 Pixmap icon_mask;
627 unsigned long *icon_bits;
628 unsigned int icon_size;
631 extern struct x11drv_win_data *get_win_data( HWND hwnd );
632 extern void release_win_data( struct x11drv_win_data *data );
633 extern Window X11DRV_get_whole_window( HWND hwnd );
634 extern Window get_dummy_parent(void);
636 extern void sync_gl_drawable( HWND hwnd, BOOL known_child );
637 extern void set_gl_drawable_parent( HWND hwnd, HWND parent );
638 extern void destroy_gl_drawable( HWND hwnd );
639 extern void destroy_vk_surface( HWND hwnd );
641 extern void wait_for_withdrawn_state( HWND hwnd, BOOL set );
642 extern Window init_clip_window(void);
643 extern void update_user_time( Time time );
644 extern void read_net_wm_states( Display *display, struct x11drv_win_data *data );
645 extern void update_net_wm_states( struct x11drv_win_data *data );
646 extern void make_window_embedded( struct x11drv_win_data *data );
647 extern Window create_client_window( HWND hwnd, const XVisualInfo *visual, Colormap colormap );
648 extern void detach_client_window( struct x11drv_win_data *data, Window client_window );
649 extern void destroy_client_window( HWND hwnd, Window client_window );
650 extern void set_window_visual( struct x11drv_win_data *data, const XVisualInfo *vis, BOOL use_alpha );
651 extern void change_systray_owner( Display *display, Window systray_window );
652 extern HWND create_foreign_window( Display *display, Window window );
653 extern BOOL update_clipboard( HWND hwnd );
654 extern void init_win_context(void);
655 extern void *file_list_to_drop_files( const void *data, size_t size, size_t *ret_size );
656 extern void *uri_list_to_drop_files( const void *data, size_t size, size_t *ret_size );
658 static inline void mirror_rect( const RECT *window_rect, RECT *rect )
660 int width = window_rect->right - window_rect->left;
661 int tmp = rect->left;
662 rect->left = width - rect->right;
663 rect->right = width - tmp;
666 /* X context to associate a hwnd to an X window */
667 extern XContext winContext;
668 /* X context to associate an X cursor to a Win32 cursor handle */
669 extern XContext cursor_context;
671 extern UINT get_win_monitor_dpi( HWND hwnd );
672 extern BOOL is_current_process_focused(void);
673 extern void X11DRV_SetFocus( HWND hwnd );
674 extern void set_window_cursor( Window window, HCURSOR handle );
675 extern void reapply_cursor_clipping(void);
676 extern void ungrab_clipping_window(void);
677 extern void move_resize_window( HWND hwnd, int dir );
678 extern void X11DRV_InitKeyboard( Display *display );
679 extern BOOL process_events( Display *display, Bool (*filter)(Display*, XEvent*, XPointer), ULONG_PTR arg );
680 extern BOOL X11DRV_ProcessEvents( DWORD mask );
681 extern HWND *build_hwnd_list(void);
683 typedef int (*x11drv_error_callback)( Display *display, XErrorEvent *event, void *arg );
685 extern void X11DRV_expect_error( Display *display, x11drv_error_callback callback, void *arg );
686 extern int X11DRV_check_error(void);
687 extern void X11DRV_X_to_window_rect( struct x11drv_win_data *data, RECT *rect, int x, int y, int cx, int cy );
688 extern POINT virtual_screen_to_root( INT x, INT y );
689 extern POINT root_to_virtual_screen( INT x, INT y );
690 extern RECT get_host_primary_monitor_rect(void);
691 extern RECT get_work_area( const RECT *monitor_rect );
692 extern BOOL xinerama_get_fullscreen_monitors( const RECT *rect, long *indices );
693 extern void xinerama_init( unsigned int width, unsigned int height );
694 extern void init_recursive_mutex( pthread_mutex_t *mutex );
696 #define DEPTH_COUNT 3
697 extern const unsigned int *depths;
699 /* Use a distinct type for the settings id, to avoid mixups other types of ids */
700 typedef struct { ULONG_PTR id; } x11drv_settings_id;
702 /* Required functions for changing and enumerating display settings */
703 struct x11drv_settings_handler
705 /* A name to tell what host driver is used */
706 const char *name;
708 /* Higher priority can override handlers with a lower priority */
709 UINT priority;
711 /* get_id() will be called to map a device name, e.g., \\.\DISPLAY1 to a driver specific id.
712 * Following functions use this id to identify the device.
714 * Return FALSE if the device cannot be found and TRUE on success */
715 BOOL (*get_id)(const WCHAR *device_name, BOOL is_primary, x11drv_settings_id *id);
717 /* get_modes() will be called to get a list of supported modes of the device of id in modes
718 * with respect to flags, which could be 0, EDS_RAWMODE or EDS_ROTATEDMODE. If the implementation
719 * uses dmDriverExtra then every DEVMODEW in the list must have the same dmDriverExtra value
721 * Following fields in DEVMODE must be valid:
722 * dmSize, dmDriverExtra, dmFields, dmDisplayOrientation, dmBitsPerPel, dmPelsWidth, dmPelsHeight,
723 * dmDisplayFlags and dmDisplayFrequency
725 * Return FALSE on failure with parameters unchanged and error code set. Return TRUE on success */
726 BOOL (*get_modes)(x11drv_settings_id id, DWORD flags, DEVMODEW **modes, UINT *mode_count, BOOL full);
728 /* free_modes() will be called to free the mode list returned from get_modes() */
729 void (*free_modes)(DEVMODEW *modes);
731 /* get_current_mode() will be called to get the current display mode of the device of id
733 * Following fields in DEVMODE must be valid:
734 * dmFields, dmDisplayOrientation, dmBitsPerPel, dmPelsWidth, dmPelsHeight, dmDisplayFlags,
735 * dmDisplayFrequency and dmPosition
737 * Return FALSE on failure with parameters unchanged and error code set. Return TRUE on success */
738 BOOL (*get_current_mode)(x11drv_settings_id id, DEVMODEW *mode);
740 /* set_current_mode() will be called to change the display mode of the display device of id.
741 * mode must be a valid mode from get_modes() with optional fields, such as dmPosition set.
743 * Return DISP_CHANGE_*, same as ChangeDisplaySettingsExW() return values */
744 LONG (*set_current_mode)(x11drv_settings_id id, const DEVMODEW *mode);
747 #define NEXT_DEVMODEW(mode) ((DEVMODEW *)((char *)((mode) + 1) + (mode)->dmDriverExtra))
749 extern void X11DRV_Settings_SetHandler(const struct x11drv_settings_handler *handler);
751 extern void X11DRV_init_desktop( Window win, unsigned int width, unsigned int height );
752 extern BOOL is_virtual_desktop(void);
753 extern BOOL is_desktop_fullscreen(void);
754 extern BOOL is_detached_mode(const DEVMODEW *);
755 void X11DRV_Settings_Init(void);
757 void X11DRV_XF86VM_Init(void);
758 void X11DRV_XRandR_Init(void);
759 void init_user_driver(void);
761 /* X11 display device handler. Used to initialize display device registry data */
763 struct x11drv_gpu
765 ULONG_PTR id;
766 char *name;
767 struct pci_id pci_id;
768 GUID vulkan_uuid;
771 struct x11drv_adapter
773 ULONG_PTR id;
774 DWORD state_flags;
777 /* Required functions for display device registry initialization */
778 struct x11drv_display_device_handler
780 /* A name to tell what host driver is used */
781 const char *name;
783 /* Higher priority can override handlers with lower priority */
784 INT priority;
786 /* get_gpus will be called to get a list of GPUs. First GPU has to be where the primary adapter is.
788 * Return FALSE on failure with parameters unchanged */
789 BOOL (*get_gpus)(struct x11drv_gpu **gpus, int *count, BOOL get_properties);
791 /* get_adapters will be called to get a list of adapters in EnumDisplayDevices context under a GPU.
792 * The first adapter has to be primary if GPU is primary.
794 * Return FALSE on failure with parameters unchanged */
795 BOOL (*get_adapters)(ULONG_PTR gpu_id, struct x11drv_adapter **adapters, int *count);
797 /* get_monitors will be called to get a list of monitors in EnumDisplayDevices context under an adapter.
798 * The first monitor has to be primary if adapter is primary.
800 * Return FALSE on failure with parameters unchanged */
801 BOOL (*get_monitors)(ULONG_PTR adapter_id, struct gdi_monitor **monitors, int *count);
803 /* free_gpus will be called to free a GPU list from get_gpus */
804 void (*free_gpus)(struct x11drv_gpu *gpus, int count);
806 /* free_adapters will be called to free an adapter list from get_adapters */
807 void (*free_adapters)(struct x11drv_adapter *adapters);
809 /* free_monitors will be called to free a monitor list from get_monitors */
810 void (*free_monitors)(struct gdi_monitor *monitors, int count);
812 /* register_event_handlers will be called to register event handlers.
813 * This function pointer is optional and can be NULL when driver doesn't support it */
814 void (*register_event_handlers)(void);
817 extern void X11DRV_DisplayDevices_SetHandler(const struct x11drv_display_device_handler *handler);
818 extern void X11DRV_DisplayDevices_RegisterEventHandlers(void);
819 extern BOOL X11DRV_DisplayDevices_SupportEventHandlers(void);
820 /* Display device handler used in virtual desktop mode */
821 extern struct x11drv_display_device_handler desktop_handler;
823 /* XIM support */
824 extern BOOL xim_init( const WCHAR *input_style );
825 extern void xim_thread_attach( struct x11drv_thread_data *data );
826 extern BOOL xim_in_compose_mode(void);
827 extern void xim_set_result_string( HWND hwnd, const char *str, UINT count );
828 extern XIC X11DRV_get_ic( HWND hwnd );
829 extern void xim_set_focus( HWND hwnd, BOOL focus );
831 #define XEMBED_MAPPED (1 << 0)
833 static inline BOOL is_window_rect_mapped( const RECT *rect )
835 RECT virtual_rect = NtUserGetVirtualScreenRect();
836 return (rect->left < virtual_rect.right &&
837 rect->top < virtual_rect.bottom &&
838 max( rect->right, rect->left + 1 ) > virtual_rect.left &&
839 max( rect->bottom, rect->top + 1 ) > virtual_rect.top);
842 /* unixlib interface */
844 extern NTSTATUS x11drv_tablet_attach_queue( void *arg );
845 extern NTSTATUS x11drv_tablet_get_packet( void *arg );
846 extern NTSTATUS x11drv_tablet_load_info( void *arg );
847 extern NTSTATUS x11drv_tablet_info( void *arg );
849 extern NTSTATUS x11drv_client_func( enum x11drv_client_funcs func, const void *params,
850 ULONG size );
852 /* GDI helpers */
854 static inline BOOL lp_to_dp( HDC hdc, POINT *points, INT count )
856 return NtGdiTransformPoints( hdc, points, points, count, NtGdiLPtoDP );
859 static inline UINT get_palette_entries( HPALETTE palette, UINT start, UINT count, PALETTEENTRY *entries )
861 return NtGdiDoPalette( palette, start, count, entries, NtGdiGetPaletteEntries, TRUE );
864 /* user helpers */
866 static inline LRESULT send_message( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam )
868 return NtUserMessageCall( hwnd, msg, wparam, lparam, NULL, NtUserSendMessage, FALSE );
871 static inline LRESULT send_message_timeout( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam,
872 UINT flags, UINT timeout, PDWORD_PTR res_ptr )
874 struct send_message_timeout_params params = { .flags = flags, .timeout = timeout };
875 LRESULT res = NtUserMessageCall( hwnd, msg, wparam, lparam, &params,
876 NtUserSendMessageTimeout, FALSE );
877 if (res_ptr) *res_ptr = params.result;
878 return res;
881 static inline BOOL send_notify_message( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam )
883 return NtUserMessageCall( hwnd, msg, wparam, lparam, 0, NtUserSendNotifyMessage, FALSE );
886 /* per-monitor DPI aware NtUserSetWindowPos call */
887 static inline BOOL set_window_pos( HWND hwnd, HWND after, INT x, INT y, INT cx, INT cy, UINT flags )
889 UINT context = NtUserSetThreadDpiAwarenessContext( NTUSER_DPI_PER_MONITOR_AWARE_V2 );
890 BOOL ret = NtUserSetWindowPos( hwnd, after, x, y, cx, cy, flags );
891 NtUserSetThreadDpiAwarenessContext( context );
892 return ret;
895 /* per-monitor DPI aware NtUserRedrawWindow call */
896 static inline BOOL redraw_window( HWND hwnd, const RECT *rect, HRGN hrgn, UINT flags )
898 UINT context = NtUserSetThreadDpiAwarenessContext( NTUSER_DPI_PER_MONITOR_AWARE_V2 );
899 BOOL ret = NtUserRedrawWindow( hwnd, rect, hrgn, flags );
900 NtUserSetThreadDpiAwarenessContext( context );
901 return ret;
904 /* per-monitor DPI aware NtUserChildWindowFromPointEx call */
905 static inline HWND child_window_from_point( HWND parent, LONG x, LONG y, UINT flags )
907 UINT context = NtUserSetThreadDpiAwarenessContext( NTUSER_DPI_PER_MONITOR_AWARE_V2 );
908 HWND ret = NtUserChildWindowFromPointEx( parent, x, y, flags );
909 NtUserSetThreadDpiAwarenessContext( context );
910 return ret;
913 static inline HWND get_focus(void)
915 GUITHREADINFO info;
916 info.cbSize = sizeof(info);
917 return NtUserGetGUIThreadInfo( GetCurrentThreadId(), &info ) ? info.hwndFocus : 0;
920 static inline HWND get_active_window(void)
922 GUITHREADINFO info;
923 info.cbSize = sizeof(info);
924 return NtUserGetGUIThreadInfo( GetCurrentThreadId(), &info ) ? info.hwndActive : 0;
927 static inline BOOL intersect_rect( RECT *dst, const RECT *src1, const RECT *src2 )
929 dst->left = max( src1->left, src2->left );
930 dst->top = max( src1->top, src2->top );
931 dst->right = min( src1->right, src2->right );
932 dst->bottom = min( src1->bottom, src2->bottom );
933 return !IsRectEmpty( dst );
936 /* registry helpers */
938 extern HKEY open_hkcu_key( const char *name );
939 extern ULONG query_reg_value( HKEY hkey, const WCHAR *name,
940 KEY_VALUE_PARTIAL_INFORMATION *info, ULONG size );
941 extern HKEY reg_open_key( HKEY root, const WCHAR *name, ULONG name_len );
943 /* string helpers */
945 static inline void ascii_to_unicode( WCHAR *dst, const char *src, size_t len )
947 while (len--) *dst++ = (unsigned char)*src++;
950 static inline UINT asciiz_to_unicode( WCHAR *dst, const char *src )
952 WCHAR *p = dst;
953 while ((*p++ = *src++));
954 return (p - dst) * sizeof(WCHAR);
957 #endif /* __WINE_X11DRV_H */