src/gui/kernel/qt_x11_p.h

Go to the documentation of this file.
00001 /****************************************************************************
00002 **
00003 ** Copyright (C) 1992-2006 Trolltech ASA. All rights reserved.
00004 **
00005 ** This file is part of the QtGui module of the Qt Toolkit.
00006 **
00007 ** This file may be used under the terms of the GNU General Public
00008 ** License version 2.0 as published by the Free Software Foundation
00009 ** and appearing in the file LICENSE.GPL included in the packaging of
00010 ** this file.  Please review the following information to ensure GNU
00011 ** General Public Licensing requirements will be met:
00012 ** http://www.trolltech.com/products/qt/opensource.html
00013 **
00014 ** If you are unsure which license is appropriate for your use, please
00015 ** review the following information:
00016 ** http://www.trolltech.com/products/qt/licensing.html or contact the
00017 ** sales department at sales@trolltech.com.
00018 **
00019 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00020 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00021 **
00022 ****************************************************************************/
00023 
00024 #ifndef QT_X11_P_H
00025 #define QT_X11_P_H
00026 
00027 //
00028 //  W A R N I N G
00029 //  -------------
00030 //
00031 // This file is not part of the Qt API.  It exists purely as an
00032 // implementation detail.  This header file may change from version to
00033 // version without notice, or even be removed.
00034 //
00035 // We mean it.
00036 //
00037 
00038 #include "QtGui/qwindowdefs.h"
00039 #include "QtCore/qlist.h"
00040 
00041 // the following is necessary to work around breakage in many versions
00042 // of XFree86's Xlib.h still in use
00043 // ### which versions?
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 //#define QT_NO_SHAPE
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 // #define QT_NO_XINERAMA
00084 #ifndef QT_NO_XINERAMA
00085 #  if 0 // ### Xsun, but how to detect it?
00086 // Xinerama is only supported in Solaris 7 with patches 107648/108376 and
00087 // Solaris 8 or above which introduce the X11R6.4 Xserver.
00088 // To switch the Xinerama functionality on, you need to add the "+xinerama"
00089 // argument to the Xsun start line.
00090 // At least Solaris 7 and 8 are missing Xinerama system headers and function
00091 // declarations (bug 4284701).
00092 // The Xinerama API is not documented. In theory it could change but it
00093 // probably won't because Sun are using it in at least dtlogin (bug 4221829).
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 // XFree86 does not C++ify Xinerama (at least up to XFree86 4.0.3).
00122 extern "C" {
00123 #    include <X11/extensions/Xinerama.h>
00124 }
00125 #  endif
00126 #endif // QT_NO_XINERAMA
00127 
00128 // #define QT_NO_XRANDR
00129 #ifndef QT_NO_XRANDR
00130 #  include <X11/extensions/Xrandr.h>
00131 #endif // QT_NO_XRANDR
00132 
00133 // #define QT_NO_XRENDER
00134 #ifndef QT_NO_XRENDER
00135 #  include <X11/extensions/Xrender.h>
00136 #endif // QT_NO_XRENDER
00137 
00138 // #define QT_NO_XKB
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 // #define QT_NO_XIM
00152 #if defined(X11R4)
00153 // X11R4 does not have XIM
00154 #define QT_NO_XIM
00155 #elif defined(Q_OS_OSF) && (XlibSpecificationRelease < 6)
00156 // broken in Xlib up to OSF/1 3.2
00157 #define QT_NO_XIM
00158 #elif defined(Q_OS_AIX)
00159 // broken in Xlib up to what version of AIX?
00160 #define QT_NO_XIM
00161 #elif defined(QT_NO_DEBUG) && defined(Q_OS_IRIX)
00162 // XmbLookupString broken on IRIX
00163 // XCreateIC broken when compiling -64 on IRIX 6.5.2
00164 #define QT_NO_XIM
00165 #elif defined(Q_OS_HPUX) && defined(__LP64__)
00166 // XCreateIC broken when compiling 64-bit ELF on HP-UX 11.0
00167 #define QT_NO_XIM
00168 #elif defined(Q_OS_SCO)
00169 // ### suggested by user...
00170 // ### #define QT_NO_XIM
00171 #endif // QT_NO_XIM
00172 
00173 
00174 /*
00175  * Solaris patch 108652-47 and higher fixes crases in
00176  * XRegisterIMInstantiateCallback, but the function doesn't seem to
00177  * work.
00178  *
00179  * Instead, we disabled R6 input, and open the input method
00180  * immediately at application start.
00181  */
00182 #if !defined(QT_NO_XIM) && (XlibSpecificationRelease >= 6) && \
00183     !defined(Q_OS_SOLARIS)
00184 #define USE_X11R6_XIM
00185 
00186 //######### XFree86 has wrong declarations for XRegisterIMInstantiateCallback
00187 //######### and XUnregisterIMInstantiateCallback in at least version 3.3.2.
00188 //######### Many old X11R6 header files lack XSetIMValues.
00189 //######### Therefore, we have to declare these functions ourselves.
00190 
00191 extern "C" Bool XRegisterIMInstantiateCallback(
00192     Display*,
00193     struct _XrmHashBucketRec*,
00194     char*,
00195     char*,
00196     XIMProc, //XFree86 has XIDProc, which has to be wrong
00197     XPointer
00198 );
00199 
00200 extern "C" Bool XUnregisterIMInstantiateCallback(
00201     Display*,
00202     struct _XrmHashBucketRec*,
00203     char*,
00204     char*,
00205     XIMProc, //XFree86 has XIDProc, which has to be wrong
00206     XPointer
00207 );
00208 
00209 extern "C" char *XSetIMValues(XIM /* im */, ...);
00210 
00211 #endif
00212 
00213 #ifndef QT_NO_FONTCONFIG
00214 #include <fontconfig/fontconfig.h>
00215 #endif
00216 
00217 #ifndef QT_NO_XIM
00218 // some platforms (eg. Solaris 2.51) don't have these defines in Xlib.h
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     // from qclipboard_x11.cpp
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     // from qdnd_x11.cpp
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     // from qmotifdnd_x11.cpp
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     // current focus model
00325     enum {
00326         FM_Unknown = -1,
00327         FM_Other = 0,
00328         FM_PointerRoot = 1
00329     };
00330     int focus_model;
00331 
00332     // true if Qt is compiled w/ RANDR support and RANDR is supported on the connected Display
00333     bool use_xrandr;
00334     int xrandr_major;
00335     int xrandr_eventbase;
00336     int xrandr_errorbase;
00337 
00338     // true if Qt is compiled w/ RENDER support and RENDER is supported on the connected Display
00339     bool use_xrender;
00340     int xrender_major;
00341     int xrender_version;
00342 
00343     // true if Qt is compiled w/ XFIXES support and XFIXES is supported on the connected Display
00344     bool use_xfixes;
00345     int xfixes_major;
00346     int xfixes_eventbase;
00347     int xfixes_errorbase;
00348 
00349     // true if Qt is compiled w/ Tablet support and we have a tablet.
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     // window managers list of supported "stuff"
00365     Atom *net_supported_list;
00366     // list of virtual root windows
00367     Window *net_virtual_root_list;
00368     // client leader window
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     // starts to ignore bad window errors from X
00381     static inline void ignoreBadwindow() {
00382         qt_x11Data->ignore_badwindow = true;
00383         qt_x11Data->seen_badwindow = false;
00384     }
00385 
00386     // ends ignoring bad window errors and returns whether an error had happened.
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     // options
00396     int visual_class;
00397     int visual_id;
00398     int color_count;
00399     bool custom_cmap;
00400 
00401     // outside visual/colormap
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     /* Warning: if you modify this list, modify the names of atoms in qapplication_x11.cpp as well! */
00435     enum X11Atom {
00436         // window-manager <-> client protocols
00437         WM_PROTOCOLS,
00438         WM_DELETE_WINDOW,
00439         WM_TAKE_FOCUS,
00440         _NET_WM_PING,
00441         _NET_WM_CONTEXT_HELP,
00442 
00443         // ICCCM window state
00444         WM_STATE,
00445         WM_CHANGE_STATE,
00446 
00447         // Session management
00448         WM_CLIENT_LEADER,
00449         WM_WINDOW_ROLE,
00450         SM_CLIENT_ID,
00451 
00452         // Clipboard
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         // EWMH (aka NETWM)
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         // Property formats
00521         COMPOUND_TEXT,
00522         TEXT,
00523         UTF8_STRING,
00524 
00525         // Xdnd
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         // Motif DND
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         // Xkb
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 // rename a couple of X defines to get rid of name clashes
00571 // resolve the conflict between X11's FocusIn and QEvent::FocusIn
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

Generated on Thu Mar 15 11:55:15 2007 for Qt 4.2 User's Guide by  doxygen 1.5.1