00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef QT_X11_P_H
00025 #define QT_X11_P_H
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #include "QtGui/qwindowdefs.h"
00039 #include "QtCore/qlist.h"
00040
00041
00042
00043
00044 #if defined(_XLIB_H_) // crude hack, but...
00045 #error "cannot include <X11/Xlib.h> before this file"
00046 #endif
00047 #define XRegisterIMInstantiateCallback qt_XRegisterIMInstantiateCallback
00048 #define XUnregisterIMInstantiateCallback qt_XUnregisterIMInstantiateCallback
00049 #define XSetIMValues qt_XSetIMValues
00050 #include <X11/Xlib.h>
00051 #undef XRegisterIMInstantiateCallback
00052 #undef XUnregisterIMInstantiateCallback
00053 #undef XSetIMValues
00054
00055 #include <X11/Xutil.h>
00056 #include <X11/Xos.h>
00057 #ifdef index
00058 # undef index
00059 #endif
00060 #ifdef rindex
00061 # undef rindex
00062 #endif
00063 #include <X11/Xatom.h>
00064
00065
00066 #ifdef QT_NO_SHAPE
00067 # define XShapeCombineRegion(a,b,c,d,e,f,g)
00068 # define XShapeCombineMask(a,b,c,d,e,f,g)
00069 #else
00070 # include <X11/extensions/shape.h>
00071 #endif // QT_NO_SHAPE
00072
00073
00074 #if !defined (QT_NO_TABLET)
00075 # include <X11/extensions/XInput.h>
00076 #if defined (Q_OS_IRIX)
00077 # include <X11/extensions/SGIMisc.h>
00078 # include <wacom.h>
00079 #endif
00080 #endif // QT_NO_TABLET
00081
00082
00083
00084 #ifndef QT_NO_XINERAMA
00085 # if 0 // ### Xsun, but how to detect it?
00086
00087
00088
00089
00090
00091
00092
00093
00094 extern "C" Bool XPanoramiXQueryExtension(
00095 Display*,
00096 int*,
00097 int*
00098 );
00099 extern "C" Status XPanoramiXQueryVersion(
00100 Display*,
00101 int*,
00102 int*
00103 );
00104 extern "C" Status XPanoramiXGetState(
00105 Display*,
00106 Drawable,
00107 XPanoramiXInfo*
00108 );
00109 extern "C" Status XPanoramiXGetScreenCount(
00110 Display *,
00111 Drawable,
00112 XPanoramiXInfo*
00113 );
00114 extern "C" Status XPanoramiXGetScreenSize(
00115 Display*,
00116 Drawable,
00117 int,
00118 XPanoramiXInfo*
00119 );
00120 # else // XFree86
00121
00122 extern "C" {
00123 # include <X11/extensions/Xinerama.h>
00124 }
00125 # endif
00126 #endif // QT_NO_XINERAMA
00127
00128
00129 #ifndef QT_NO_XRANDR
00130 # include <X11/extensions/Xrandr.h>
00131 #endif // QT_NO_XRANDR
00132
00133
00134 #ifndef QT_NO_XRENDER
00135 # include <X11/extensions/Xrender.h>
00136 #endif // QT_NO_XRENDER
00137
00138
00139 #ifndef QT_NO_XKB
00140 # include <X11/XKBlib.h>
00141 #endif // QT_NO_XKB
00142
00143
00144 #if !defined(XlibSpecificationRelease)
00145 # define X11R4
00146 typedef char *XPointer;
00147 #else
00148 # undef X11R4
00149 #endif
00150
00151
00152 #if defined(X11R4)
00153
00154 #define QT_NO_XIM
00155 #elif defined(Q_OS_OSF) && (XlibSpecificationRelease < 6)
00156
00157 #define QT_NO_XIM
00158 #elif defined(Q_OS_AIX)
00159
00160 #define QT_NO_XIM
00161 #elif defined(QT_NO_DEBUG) && defined(Q_OS_IRIX)
00162
00163
00164 #define QT_NO_XIM
00165 #elif defined(Q_OS_HPUX) && defined(__LP64__)
00166
00167 #define QT_NO_XIM
00168 #elif defined(Q_OS_SCO)
00169
00170
00171 #endif // QT_NO_XIM
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182 #if !defined(QT_NO_XIM) && (XlibSpecificationRelease >= 6) && \
00183 !defined(Q_OS_SOLARIS)
00184 #define USE_X11R6_XIM
00185
00186
00187
00188
00189
00190
00191 extern "C" Bool XRegisterIMInstantiateCallback(
00192 Display*,
00193 struct _XrmHashBucketRec*,
00194 char*,
00195 char*,
00196 XIMProc,
00197 XPointer
00198 );
00199
00200 extern "C" Bool XUnregisterIMInstantiateCallback(
00201 Display*,
00202 struct _XrmHashBucketRec*,
00203 char*,
00204 char*,
00205 XIMProc,
00206 XPointer
00207 );
00208
00209 extern "C" char *XSetIMValues(XIM , ...);
00210
00211 #endif
00212
00213 #ifndef QT_NO_FONTCONFIG
00214 #include <fontconfig/fontconfig.h>
00215 #endif
00216
00217 #ifndef QT_NO_XIM
00218
00219 #ifndef XNResetState
00220 #define XNResetState "resetState"
00221 #endif
00222 #ifndef XIMPreserveState
00223 #define XIMPreserveState (1L<<1)
00224 #endif
00225 #endif
00226
00227
00228 #ifndef X11R4
00229 # include <X11/Xlocale.h>
00230 #endif // X11R4
00231
00232
00233 #ifdef QT_MITSHM
00234
00235 # include <X11/extensions/XShm.h>
00236 #endif // QT_MITSHM
00237
00238 class QWidget;
00239
00240
00241 struct QX11InfoData {
00242 uint ref;
00243 int screen;
00244 int dpiX;
00245 int dpiY;
00246 int depth;
00247 int cells;
00248 Colormap colormap;
00249 Visual *visual;
00250 bool defaultColormap;
00251 bool defaultVisual;
00252 int subpixel;
00253 };
00254
00255 class QDrag;
00256 struct QXdndDropTransaction
00257 {
00258 Time timestamp;
00259 Window target;
00260 Window proxy_target;
00261 QWidget *targetWidget;
00262 QWidget *embedding_widget;
00263 QDrag *object;
00264 };
00265
00266 class QMimeData;
00267
00268 struct QX11Data;
00269 extern QX11Data *qt_x11Data;
00270
00271 enum DesktopEnvironment {
00272 DE_UNKNOWN,
00273 DE_KDE,
00274 DE_GNOME,
00275 DE_CDE
00276 };
00277
00278 struct QX11Data
00279 {
00280 static Qt::KeyboardModifiers translateModifiers(int s);
00281
00282 Window findClientWindow(Window, Atom, bool);
00283
00284
00285 bool clipboardWaitForEvent(Window win, int type, XEvent *event, int timeout);
00286 bool clipboardReadProperty(Window win, Atom property, bool deleteProperty,
00287 QByteArray *buffer, int *size, Atom *type, int *format, bool nullterm);
00288 QByteArray clipboardReadIncrementalProperty(Window win, Atom property, int nbytes, bool nullterm);
00289
00290
00291 bool dndEnable(QWidget* w, bool on);
00292 static void xdndSetup();
00293 void xdndHandleEnter(QWidget *, const XEvent *, bool);
00294 void xdndHandlePosition(QWidget *, const XEvent *, bool);
00295 void xdndHandleStatus(QWidget *, const XEvent *, bool);
00296 void xdndHandleLeave(QWidget *, const XEvent *, bool);
00297 void xdndHandleDrop(QWidget *, const XEvent *, bool);
00298 void xdndHandleFinished(QWidget *, const XEvent *, bool);
00299 void xdndHandleSelectionRequest(const XSelectionRequestEvent *);
00300 static bool xdndHandleBadwindow();
00301 QByteArray xdndAtomToString(Atom a);
00302 Atom xdndStringToAtom(const char *);
00303
00304 QString xdndMimeAtomToString(Atom a);
00305 Atom xdndMimeStringToAtom(const QString &mimeType);
00306 QStringList xdndMimeFormatsForAtom(Atom a);
00307 bool xdndMimeDataForAtom(Atom a, QMimeData *mimeData, QByteArray *data, Atom *atomFormat, int *dataFormat);
00308 QList<Atom> xdndMimeAtomsForFormat(const QString &format);
00309 QByteArray xdndMimeConvertToFormat(Atom a, const QByteArray &data, const QString &format);
00310 Atom xdndMimeAtomForFormat(const QString &format, const QList<Atom> &atoms);
00311
00312 QList<QXdndDropTransaction> dndDropTransactions;
00313
00314
00315 void motifdndHandle(QWidget *, const XEvent *, bool);
00316 void motifdndEnable(QWidget *, bool);
00317 QByteArray motifdndObtainData(const char *format);
00318 QByteArray motifdndFormat(int n);
00319 bool motifdnd_active;
00320
00321 Display *display;
00322 char *displayName;
00323 bool foreignDisplay;
00324
00325 enum {
00326 FM_Unknown = -1,
00327 FM_Other = 0,
00328 FM_PointerRoot = 1
00329 };
00330 int focus_model;
00331
00332
00333 bool use_xrandr;
00334 int xrandr_major;
00335 int xrandr_eventbase;
00336 int xrandr_errorbase;
00337
00338
00339 bool use_xrender;
00340 int xrender_major;
00341 int xrender_version;
00342
00343
00344 bool use_xfixes;
00345 int xfixes_major;
00346 int xfixes_eventbase;
00347 int xfixes_errorbase;
00348
00349
00350 bool use_xinput;
00351 int xinput_major;
00352 int xinput_eventbase;
00353 int xinput_errorbase;
00354
00355 QList<QWidget *> deferred_map;
00356 struct ScrollInProgress {
00357 long id;
00358 QWidget* scrolled_widget;
00359 int dx, dy;
00360 };
00361 long sip_serial;
00362 QList<ScrollInProgress> sip_list;
00363
00364
00365 Atom *net_supported_list;
00366
00367 Window *net_virtual_root_list;
00368
00369 Window wm_client_leader;
00370
00371 QX11InfoData *screens;
00372 int screenCount;
00373 int defaultScreen;
00374
00375 Time time;
00376 Time userTime;
00377
00378 QString default_im;
00379
00380
00381 static inline void ignoreBadwindow() {
00382 qt_x11Data->ignore_badwindow = true;
00383 qt_x11Data->seen_badwindow = false;
00384 }
00385
00386
00387 static inline bool badwindow() {
00388 qt_x11Data->ignore_badwindow = false;
00389 return qt_x11Data->seen_badwindow;
00390 }
00391
00392 bool ignore_badwindow;
00393 bool seen_badwindow;
00394
00395
00396 int visual_class;
00397 int visual_id;
00398 int color_count;
00399 bool custom_cmap;
00400
00401
00402 Visual *visual;
00403 Colormap colormap;
00404
00405 #ifndef QT_NO_XRENDER
00406 enum { solid_fill_count = 16 };
00407 struct SolidFills {
00408 XRenderColor color;
00409 int screen;
00410 Picture picture;
00411 } solid_fills[solid_fill_count];
00412 enum { pattern_fill_count = 16 };
00413 struct PatternFills {
00414 XRenderColor color;
00415 XRenderColor bg_color;
00416 int screen;
00417 int style;
00418 bool opaque;
00419 Picture picture;
00420 } pattern_fills[pattern_fill_count];
00421 Picture getSolidFill(int screen, const QColor &c);
00422 XRenderColor preMultiply(const QColor &c);
00423 #endif
00424
00425 bool has_fontconfig;
00426 qreal fc_scale;
00427 bool fc_antialias;
00428 int fc_hint_style;
00429
00430 char *startupId;
00431
00432 DesktopEnvironment desktopEnvironment;
00433
00434
00435 enum X11Atom {
00436
00437 WM_PROTOCOLS,
00438 WM_DELETE_WINDOW,
00439 WM_TAKE_FOCUS,
00440 _NET_WM_PING,
00441 _NET_WM_CONTEXT_HELP,
00442
00443
00444 WM_STATE,
00445 WM_CHANGE_STATE,
00446
00447
00448 WM_CLIENT_LEADER,
00449 WM_WINDOW_ROLE,
00450 SM_CLIENT_ID,
00451
00452
00453 CLIPBOARD,
00454 INCR,
00455 TARGETS,
00456 MULTIPLE,
00457 TIMESTAMP,
00458 CLIP_TEMPORARY,
00459 _QT_SELECTION,
00460 _QT_CLIPBOARD_SENTINEL,
00461 _QT_SELECTION_SENTINEL,
00462
00463 RESOURCE_MANAGER,
00464
00465 _XSETROOT_ID,
00466
00467 _QT_SCROLL_DONE,
00468 _QT_INPUT_ENCODING,
00469
00470 _MOTIF_WM_HINTS,
00471
00472 DTWM_IS_RUNNING,
00473 KDE_FULL_SESSION,
00474 KWIN_RUNNING,
00475 KWM_RUNNING,
00476 GNOME_BACKGROUND_PROPERTIES,
00477 ENLIGHTENMENT_DESKTOP,
00478 _SGI_DESKS_MANAGER,
00479
00480
00481 _NET_SUPPORTED,
00482 _NET_VIRTUAL_ROOTS,
00483 _NET_WORKAREA,
00484
00485 _NET_WM_NAME,
00486 _NET_WM_ICON_NAME,
00487 _NET_WM_ICON,
00488
00489 _NET_WM_PID,
00490
00491 _NET_WM_WINDOW_OPACITY,
00492
00493 _NET_WM_STATE,
00494 _NET_WM_STATE_ABOVE,
00495 _NET_WM_STATE_FULLSCREEN,
00496 _NET_WM_STATE_MAXIMIZED_HORZ,
00497 _NET_WM_STATE_MAXIMIZED_VERT,
00498 _NET_WM_STATE_MODAL,
00499 _NET_WM_STATE_STAYS_ON_TOP,
00500
00501 _NET_WM_USER_TIME,
00502 _NET_WM_FULL_PLACEMENT,
00503
00504 _NET_WM_WINDOW_TYPE,
00505 _NET_WM_WINDOW_TYPE_DIALOG,
00506 _NET_WM_WINDOW_TYPE_MENU,
00507 _NET_WM_WINDOW_TYPE_NORMAL,
00508 _KDE_NET_WM_WINDOW_TYPE_OVERRIDE,
00509 _NET_WM_WINDOW_TYPE_SPLASH,
00510 _NET_WM_WINDOW_TYPE_TOOLBAR,
00511 _NET_WM_WINDOW_TYPE_UTILITY,
00512
00513 _KDE_NET_WM_FRAME_STRUT,
00514
00515 _NET_STARTUP_INFO,
00516 _NET_STARTUP_INFO_BEGIN,
00517
00518 _NET_SUPPORTING_WM_CHECK,
00519
00520
00521 COMPOUND_TEXT,
00522 TEXT,
00523 UTF8_STRING,
00524
00525
00526 XdndEnter,
00527 XdndPosition,
00528 XdndStatus,
00529 XdndLeave,
00530 XdndDrop,
00531 XdndFinished,
00532 XdndTypelist,
00533 XdndActionList,
00534
00535 XdndSelection,
00536
00537 XdndAware,
00538 XdndProxy,
00539
00540 XdndActionCopy,
00541 XdndActionLink,
00542 XdndActionMove,
00543 XdndActionPrivate,
00544
00545
00546 _MOTIF_DRAG_AND_DROP_MESSAGE,
00547 _MOTIF_DRAG_INITIATOR_INFO,
00548 _MOTIF_DRAG_RECEIVER_INFO,
00549 _MOTIF_DRAG_WINDOW,
00550 _MOTIF_DRAG_TARGETS,
00551
00552 XmTRANSFER_SUCCESS,
00553 XmTRANSFER_FAILURE,
00554
00555
00556 _XKB_RULES_NAMES,
00557
00558 NPredefinedAtoms,
00559
00560 _QT_SETTINGS_TIMESTAMP = NPredefinedAtoms,
00561 NAtoms
00562 };
00563 Atom atoms[NAtoms];
00564 };
00565
00566 extern QX11Data *qt_x11Data;
00567 #define ATOM(x) qt_x11Data->atoms[QX11Data::x]
00568 #define X11 qt_x11Data
00569
00570
00571
00572 enum {
00573 XFocusOut = FocusOut,
00574 XFocusIn = FocusIn,
00575 XKeyPress = KeyPress,
00576 XKeyRelease = KeyRelease,
00577 XNone = None,
00578 XRevertToParent = RevertToParent,
00579 XGrayScale = GrayScale,
00580 XCursorShape = CursorShape
00581 };
00582 #undef FocusOut
00583 #undef FocusIn
00584 #undef KeyPress
00585 #undef KeyRelease
00586 #undef None
00587 #undef RevertToParent
00588 #undef GrayScale
00589 #undef CursorShape
00590
00591 #ifdef FontChange
00592 #undef FontChange
00593 #endif
00594
00595 Q_DECLARE_TYPEINFO(XPoint, Q_PRIMITIVE_TYPE);
00596 Q_DECLARE_TYPEINFO(XRectangle, Q_PRIMITIVE_TYPE);
00597 Q_DECLARE_TYPEINFO(XChar2b, Q_PRIMITIVE_TYPE);
00598 #ifndef QT_NO_XRENDER
00599 Q_DECLARE_TYPEINFO(XGlyphElt32, Q_PRIMITIVE_TYPE);
00600 #endif
00601
00602 #endif // QT_X11_P_H