Qt 4.8
Classes | Macros | Typedefs | Functions | Variables
qapplication_x11.cpp File Reference
#include "qplatformdefs.h"
#include "qcolormap.h"
#include "qdesktopwidget.h"
#include "qapplication.h"
#include "qapplication_p.h"
#include "qcursor.h"
#include "qwidget.h"
#include "qbitarray.h"
#include "qpainter.h"
#include "qfile.h"
#include "qpixmapcache.h"
#include "qdatetime.h"
#include "qtextcodec.h"
#include "qdatastream.h"
#include "qbuffer.h"
#include "qsocketnotifier.h"
#include "qsessionmanager.h"
#include "qclipboard.h"
#include "qwhatsthis.h"
#include "qsettings.h"
#include "qstylefactory.h"
#include "qfileinfo.h"
#include "qdir.h"
#include "qhash.h"
#include "qevent.h"
#include "qevent_p.h"
#include "qvarlengtharray.h"
#include "qdebug.h"
#include <private/qcrashhandler_p.h>
#include <private/qcolor_p.h>
#include <private/qcursor_p.h>
#include <private/qiconloader_p.h>
#include <qgtkstyle.h>
#include "qstyle.h"
#include "qmetaobject.h"
#include "qtimer.h"
#include "qlibrary.h"
#include <private/qgraphicssystemfactory_p.h>
#include "qguiplatformplugin_p.h"
#include "qkde_p.h"
#include <wacomcfg.h>
#include "qguieventdispatcher_glib_p.h"
#include "qeventdispatcher_x11_p.h"
#include <private/qpaintengine_x11_p.h>
#include <private/qkeymapper_p.h>
#include "qinputcontext.h"
#include "qinputcontextfactory.h"
#include <X11/extensions/Xfixes.h>
#include "qt_x11_p.h"
#include "qx11info_x11.h"
#include <X11/keysymdef.h>
#include <X11/extensions/XI.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <locale.h>
#include "qwidget_p.h"
#include <private/qbackingstore_p.h>
#include <X11/SM/SMlib.h>
#include "qapplication_x11.moc"

Go to the source code of this file.

Classes

struct  PaintEventInfo
 
class  QETWidget
 
class  QSessionManagerPrivate
 
class  QSmSocketReceiver
 
struct  QT_smcConn
 
struct  qt_sync_request_event_data
 
struct  qt_tablet_motion_data
 
struct  qt_xfixes_selection_event_data
 

Macros

#define class   c_class
 
#define QT_GUI_DOUBLE_CLICK_RADIUS   5
 
#define QT_NO_UNSETENV
 
#define XINPUT_LOAD(symbol)   symbol
 
#define XK_MISCELLANY
 
#define XWACOM_PARAM_TOOLID   322
 
#define XWACOM_PARAM_TOOLSERIAL   323
 

Typedefs

typedef int(* PtrWacomConfigCloseDevice) (WACOMDEVICE *)
 
typedef int *(* PtrWacomConfigGetRawParam) (WACOMDEVICE *, int, int *, int, unsigned *)
 
typedef WACOMCONFIG *(* PtrWacomConfigInit) (Display *, WACOMERRORFUNC)
 
typedef WACOMDEVICE *(* PtrWacomConfigOpenDevice) (WACOMCONFIG *, const char *)
 
typedef void(* PtrWacomConfigTerm) (WACOMCONFIG *)
 
typedef bool(* QX11FilterFunction) (XEvent *event)
 

Functions

void fetchWacomToolId (int &deviceType, qint64 &serialId)
 
static void getXDefault (const char *group, const char *key, int *val)
 
static void getXDefault (const char *group, const char *key, double *val)
 
static void getXDefault (const char *group, const char *key, bool *val)
 
static Bool isPaintOrScrollDoneEvent (Display *, XEvent *ev, XPointer a)
 
void qPRCleanup (QWidget *widget)
 
void qPRCreate (const QWidget *widget, Window oldwin)
 
static QETWidgetqPRFindWidget (Window oldwin)
 
void qt_change_net_wm_state (const QWidget *w, bool set, Atom one, Atom two=0)
 
bool qt_check_clipboard_sentinel ()
 
static void qt_check_focus_model ()
 
bool qt_check_selection_sentinel ()
 
void qt_cleanup ()
 
void qt_desktopwidget_update_workarea ()
 
static void qt_get_net_supported ()
 
static void qt_get_net_virtual_roots ()
 
void qt_init (QApplicationPrivate *priv, int, Display *display, Qt::HANDLE visual, Qt::HANDLE colormap)
 
Q_GUI_EXPORT void qt_installX11EventFilter (QX11FilterFunction func)
 
static void * qt_load_library_runtime (const char *library, int vernum, int highestVernum, const char *symbol)
 Try to resolve a symbol from library with the version specified by vernum. More...
 
static Bool qt_mouseMotion_scanner (Display *, XEvent *event, XPointer arg)
 
void qt_net_remove_user_time (QWidget *tlw)
 
void qt_net_update_user_time (QWidget *tlw, unsigned long timestamp)
 
bool qt_nograb ()
 
Q_GUI_EXPORT void qt_removeX11EventFilter (QX11FilterFunction func)
 
static void qt_save_rootinfo ()
 
static void qt_set_input_encoding ()
 
static void qt_set_x11_resources (const char *font=0, const char *fg=0, const char *bg=0, const char *button=0)
 
static Bool qt_sync_request_scanner (Display *, XEvent *event, XPointer arg)
 
QTabletDeviceDataListqt_tablet_devices ()
 
static Bool qt_tabletMotion_scanner (Display *, XEvent *event, XPointer arg)
 
Q_GUI_EXPORT bool qt_try_modal (QWidget *, XEvent *)
 
void qt_updated_rootinfo ()
 
bool qt_wstate_iconified (WId winid)
 
Q_GUI_EXPORT void qt_x11_apply_settings_in_all_apps ()
 
static void qt_x11_create_intern_atoms ()
 
static bool qt_x11EventFilter (XEvent *ev)
 
static int qt_x_errhandler (Display *dpy, XErrorEvent *err)
 
bool qt_xfixes_clipboard_changed (Window clipboardOwner, Time timestamp)
 
static Bool qt_xfixes_scanner (Display *, XEvent *event, XPointer arg)
 
bool qt_xfixes_selection_changed (Window selectionOwner, Time timestamp)
 
static int qt_xio_errhandler (Display *)
 
static void resetSmState ()
 
bool runningUnderDebugger ()
 
static void sm_dieCallback (SmcConn smcConn, SmPointer clientData)
 
static void sm_interactCallback (SmcConn smcConn, SmPointer clientData)
 
static void sm_performSaveYourself (QSessionManagerPrivate *)
 
static void sm_saveCompleteCallback (SmcConn smcConn, SmPointer clientData)
 
static void sm_saveYourselfCallback (SmcConn smcConn, SmPointer clientData, int saveType, Bool shutdown, int interactStyle, Bool fast)
 
static void sm_saveYourselfPhase2Callback (SmcConn smcConn, SmPointer clientData)
 
static void sm_setProperty (const char *name, const char *type, int num_vals, SmPropValue *vals)
 
static void sm_setProperty (const QString &name, const QString &value)
 
static void sm_setProperty (const QString &name, const QStringList &value)
 
static void sm_shutdownCancelledCallback (SmcConn smcConn, SmPointer clientData)
 
static bool translateBySips (QWidget *that, QRect &paintRect)
 
static Qt::MouseButtons translateMouseButtons (int s)
 

Variables

static bool app_do_modal = false
 
static bool app_save_rootinfo = false
 
static const char * appBGCol = 0
 
static const char * appBTNCol = 0
 
static const char * appClass = 0
 
static bool appDoGrab = false
 
static const char * appFGCol = 0
 
static const char * appFont = 0
 
static const char * appName = 0
 
static bool appNoGrab = false
 
static bool appSync = false
 
static Window curWin = 0
 
static Window mouseActWindow = 0
 
static Qt::MouseButton mouseButtonPressed = Qt::NoButton
 
static Time mouseButtonPressTime = 0
 
static Qt::MouseButtons mouseButtonState = Qt::NoButton
 
static short mouseGlobalXPos
 
static short mouseGlobalYPos
 
static short mouseXPos
 
static short mouseYPos
 
static const char * mwGeometry = 0
 
static const char * mwTitle = 0
 
static int openPopupCount = 0
 
static int(* original_x_errhandler )(Display *dpy, XErrorEvent *)
 
static int(* original_xio_errhandler )(Display *dpy)
 
static bool popupGrabOk
 
static Window pressed_window = XNone
 
static PtrWacomConfigCloseDevice ptrWacomConfigCloseDevice = 0
 
static PtrWacomConfigGetRawParam ptrWacomConfigGetRawParam = 0
 
static PtrWacomConfigInit ptrWacomConfigInit = 0
 
static PtrWacomConfigOpenDevice ptrWacomConfigOpenDevice = 0
 
static PtrWacomConfigTerm ptrWacomConfigTerm = 0
 
uchar qt_alt_mask = 0
 
QWidgetqt_button_down = 0
 
uchar qt_hyper_mask = 0
 
QTextCodecqt_input_mapper = 0
 
bool qt_is_gui_used
 
QPointer< QWidgetqt_last_mouse_receiver = 0
 
uchar qt_meta_mask = 0
 
QWidgetListqt_modal_stack
 
uchar qt_mode_switch_mask = 0
 
static QWidgetqt_popup_down = 0
 
bool qt_sm_blockUserInput = false
 
uchar qt_super_mask = 0
 
bool qt_tabletChokeMouse
 
bool qt_use_rtl_extensions = false
 
Q_GUI_EXPORT QX11Dataqt_x11Data = 0
 
bool qt_xdnd_dragging
 
Q_GUI_EXPORT int qt_xfocusout_grab_counter = 0
 
int qt_ximComposingKeycode =0
 
char * qt_ximServer = 0
 
static bool replayPopupMouseEvent = false
 
static bool sm_cancel
 
static bool sm_in_phase2
 
static bool sm_interactionActive
 
static int sm_interactStyle
 
static bool sm_isshutdown
 
static bool sm_phase2
 
static QSmSocketReceiversm_receiver = 0
 
static int sm_saveType
 
static bool sm_smActive
 
static bool sm_waitingForInteraction
 
static SmcConn smcConnection = 0
 
static QWidgetMapperwPRmapper = 0
 
static const char * x11_atomnames
 

Macro Definition Documentation

◆ class

#define class   c_class

Definition at line 92 of file qapplication_x11.cpp.

◆ QT_GUI_DOUBLE_CLICK_RADIUS

#define QT_GUI_DOUBLE_CLICK_RADIUS   5

Definition at line 99 of file qapplication_x11.cpp.

Referenced by QETWidget::translateMouseEvent().

◆ QT_NO_UNSETENV

#define QT_NO_UNSETENV

Definition at line 148 of file qapplication_x11.cpp.

◆ XINPUT_LOAD

#define XINPUT_LOAD (   symbol)    symbol

Definition at line 505 of file qapplication_x11.cpp.

Referenced by qt_init().

◆ XK_MISCELLANY

#define XK_MISCELLANY

Definition at line 126 of file qapplication_x11.cpp.

◆ XWACOM_PARAM_TOOLID

#define XWACOM_PARAM_TOOLID   322

Definition at line 1565 of file qapplication_x11.cpp.

Referenced by fetchWacomToolId().

◆ XWACOM_PARAM_TOOLSERIAL

#define XWACOM_PARAM_TOOLSERIAL   323

Definition at line 1566 of file qapplication_x11.cpp.

Referenced by fetchWacomToolId().

Typedef Documentation

◆ PtrWacomConfigCloseDevice

typedef int(* PtrWacomConfigCloseDevice) (WACOMDEVICE *)

Definition at line 1571 of file qapplication_x11.cpp.

◆ PtrWacomConfigGetRawParam

typedef int*(* PtrWacomConfigGetRawParam) (WACOMDEVICE *, int, int *, int, unsigned *)

Definition at line 1570 of file qapplication_x11.cpp.

◆ PtrWacomConfigInit

typedef WACOMCONFIG*(* PtrWacomConfigInit) (Display *, WACOMERRORFUNC)

Definition at line 1568 of file qapplication_x11.cpp.

◆ PtrWacomConfigOpenDevice

typedef WACOMDEVICE*(* PtrWacomConfigOpenDevice) (WACOMCONFIG *, const char *)

Definition at line 1569 of file qapplication_x11.cpp.

◆ PtrWacomConfigTerm

typedef void(* PtrWacomConfigTerm) (WACOMCONFIG *)

Definition at line 1572 of file qapplication_x11.cpp.

◆ QX11FilterFunction

typedef bool(* QX11FilterFunction) (XEvent *event)

Definition at line 403 of file qapplication_x11.cpp.

Function Documentation

◆ fetchWacomToolId()

void fetchWacomToolId ( int &  deviceType,
qint64 serialId 
)

Definition at line 4588 of file qapplication_x11.cpp.

Referenced by QETWidget::translateXinputEvent().

4589 {
4590  if (ptrWacomConfigInit == 0) // we actually have the lib
4591  return;
4592  WACOMCONFIG *config = ptrWacomConfigInit(X11->display, 0);
4593  if (config == 0)
4594  return;
4595  WACOMDEVICE *device = ptrWacomConfigOpenDevice (config, wacomDeviceName()->constData());
4596  if (device == 0)
4597  return;
4598  unsigned keys[1];
4599  int serialInt;
4600  ptrWacomConfigGetRawParam (device, XWACOM_PARAM_TOOLSERIAL, &serialInt, 1, keys);
4601  serialId = serialInt;
4602  int toolId;
4603  ptrWacomConfigGetRawParam (device, XWACOM_PARAM_TOOLID, &toolId, 1, keys);
4604  switch(toolId) {
4605  case 0x007: /* Mouse 4D and 2D */
4606  case 0x017: /* Intuos3 2D Mouse */
4607  case 0x094:
4608  case 0x09c:
4609  deviceType = QTabletEvent::FourDMouse;
4610  break;
4611  case 0x096: /* Lens cursor */
4612  case 0x097: /* Intuos3 Lens cursor */
4613  deviceType = QTabletEvent::Puck;
4614  break;
4615  case 0x0fa:
4616  case 0x81b: /* Intuos3 Classic Pen Eraser */
4617  case 0x82a: /* Eraser */
4618  case 0x82b: /* Intuos3 Grip Pen Eraser */
4619  case 0x85a:
4620  case 0x91a:
4621  case 0x91b: /* Intuos3 Airbrush Eraser */
4622  case 0xd1a:
4623  deviceType = QTabletEvent::XFreeEraser;
4624  break;
4625  case 0x112:
4626  case 0x912:
4627  case 0x913: /* Intuos3 Airbrush */
4628  case 0xd12:
4629  deviceType = QTabletEvent::Airbrush;
4630  break;
4631  case 0x012:
4632  case 0x022:
4633  case 0x032:
4634  case 0x801: /* Intuos3 Inking pen */
4635  case 0x812: /* Inking pen */
4636  case 0x813: /* Intuos3 Classic Pen */
4637  case 0x822: /* Pen */
4638  case 0x823: /* Intuos3 Grip Pen */
4639  case 0x832: /* Stroke pen */
4640  case 0x842:
4641  case 0x852:
4642  case 0x885: /* Intuos3 Marker Pen */
4643  default: /* Unknown tool */
4644  deviceType = QTabletEvent::Stylus;
4645  }
4646 
4647  /* Close device and return */
4648  ptrWacomConfigCloseDevice (device);
4649  ptrWacomConfigTerm(config);
4650 }
static PtrWacomConfigInit ptrWacomConfigInit
static PtrWacomConfigTerm ptrWacomConfigTerm
#define X11
Definition: qt_x11_p.h:724
QStringList keys
static PtrWacomConfigCloseDevice ptrWacomConfigCloseDevice
#define XWACOM_PARAM_TOOLSERIAL
static PtrWacomConfigGetRawParam ptrWacomConfigGetRawParam
#define XWACOM_PARAM_TOOLID
static PtrWacomConfigOpenDevice ptrWacomConfigOpenDevice

◆ getXDefault() [1/3]

static void getXDefault ( const char *  group,
const char *  key,
int *  val 
)
static

Definition at line 1589 of file qapplication_x11.cpp.

1590 {
1591  char *str = XGetDefault(X11->display, group, key);
1592  if (str) {
1593  char *end = 0;
1594  int v = strtol(str, &end, 0);
1595  if (str != end)
1596  *val = v;
1597  // otherwise use fontconfig to convert the string to integer
1598  else
1599  FcNameConstant((FcChar8 *) str, val);
1600  }
1601 }
#define X11
Definition: qt_x11_p.h:724
int key
static const KeyPair *const end

◆ getXDefault() [2/3]

static void getXDefault ( const char *  group,
const char *  key,
double *  val 
)
static

Definition at line 1603 of file qapplication_x11.cpp.

1604 {
1605  char *str = XGetDefault(X11->display, group, key);
1606  if (str) {
1607  bool ok;
1608  double v = QByteArray(str).toDouble(&ok);
1609  if (ok)
1610  *val = v;
1611  }
1612 }
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
#define X11
Definition: qt_x11_p.h:724
int key
double toDouble(bool *ok=0) const
Returns the byte array converted to a double value.

◆ getXDefault() [3/3]

static void getXDefault ( const char *  group,
const char *  key,
bool *  val 
)
static

Definition at line 1614 of file qapplication_x11.cpp.

1615 {
1616  char *str = XGetDefault(X11->display, group, key);
1617  if (str) {
1618  char c = str[0];
1619  if (isupper((int)c))
1620  c = tolower(c);
1621  if (c == 't' || c == 'y' || c == '1')
1622  *val = true;
1623  else if (c == 'f' || c == 'n' || c == '0')
1624  *val = false;
1625  if (c == 'o') {
1626  c = str[1];
1627  if (isupper((int)c))
1628  c = tolower(c);
1629  if (c == 'n')
1630  *val = true;
1631  if (c == 'f')
1632  *val = false;
1633  }
1634  }
1635 }
unsigned char c[8]
Definition: qnumeric_p.h:62
#define X11
Definition: qt_x11_p.h:724
int key

◆ isPaintOrScrollDoneEvent()

static Bool isPaintOrScrollDoneEvent ( Display ,
XEvent ev,
XPointer  a 
)
static

Definition at line 5166 of file qapplication_x11.cpp.

Referenced by QETWidget::translatePaintEvent().

5167 {
5169  if (ev->type == Expose || ev->type == GraphicsExpose
5170  || (ev->type == ClientMessage && ev->xclient.message_type == ATOM(_QT_SCROLL_DONE)))
5171  {
5172  if (ev->xexpose.window == info->window)
5173  return True;
5174  }
5175  return False;
5176 }
static mach_timebase_info_data_t info
long ASN1_INTEGER_get ASN1_INTEGER * a
#define ATOM(x)
Definition: qt_x11_p.h:723

◆ qPRCleanup()

void qPRCleanup ( QWidget widget)

Definition at line 3123 of file qapplication_x11.cpp.

Referenced by QWidgetPrivate::isBackgroundInherited(), and QApplication::x11ProcessEvent().

3124 {
3125  QETWidget *etw = static_cast<QETWidget *>(const_cast<QWidget *>(widget));
3127  return; // not a reparented widget
3129  while (it != wPRmapper->constEnd()) {
3130  QWidget *w = *it;
3131  if (w == etw) { // found widget
3132  etw->setAttribute(Qt::WA_WState_Reparented, false); // clear flag
3133  it = wPRmapper->erase(it);// old window no longer needed
3134  } else {
3135  ++it;
3136  }
3137  }
3138  if (wPRmapper->size() == 0) { // became empty
3139  delete wPRmapper; // then reset alt mapper
3140  wPRmapper = 0;
3141  }
3142 }
QPointer< QWidget > widget
#define it(className, varName)
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
static QWidgetMapper * wPRmapper
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the hash...
Definition: qhash.h:469
int size() const
Returns the number of items in the hash.
Definition: qhash.h:295
The QHash::iterator class provides an STL-style non-const iterator for QHash and QMultiHash.
Definition: qhash.h:330
iterator begin()
Returns an STL-style iterator pointing to the first item in the hash.
Definition: qhash.h:464
void setAttribute(Qt::WidgetAttribute, bool on=true)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
Definition: qwidget.cpp:11087
iterator erase(iterator it)
Removes the (key, value) pair associated with the iterator pos from the hash, and returns an iterator...
Definition: qhash.h:827

◆ qPRCreate()

void qPRCreate ( const QWidget widget,
Window  oldwin 
)

Definition at line 3113 of file qapplication_x11.cpp.

Referenced by QWidgetPrivate::isBackgroundInherited().

3114 { // QWidget::reparent mechanism
3115  if (!wPRmapper)
3116  wPRmapper = new QWidgetMapper;
3117 
3118  QETWidget *w = static_cast<QETWidget *>(const_cast<QWidget *>(widget));
3119  wPRmapper->insert((int)oldwin, w); // add old window to mapper
3120  w->setAttribute(Qt::WA_WState_Reparented); // set reparented flag
3121 }
QPointer< QWidget > widget
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition: qhash.h:753
static QWidgetMapper * wPRmapper
QHash< WId, QWidget * > QWidgetMapper
Definition: qwindowdefs.h:148
void setAttribute(Qt::WidgetAttribute, bool on=true)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
Definition: qwidget.cpp:11087

◆ qPRFindWidget()

static QETWidget* qPRFindWidget ( Window  oldwin)
static

Definition at line 3144 of file qapplication_x11.cpp.

Referenced by QApplication::x11ProcessEvent().

3145 {
3146  return wPRmapper ? (QETWidget*)wPRmapper->value((int)oldwin, 0) : 0;
3147 }
const T value(const Key &key) const
Returns the value associated with the key.
Definition: qhash.h:606
static QWidgetMapper * wPRmapper

◆ qt_change_net_wm_state()

void qt_change_net_wm_state ( const QWidget w,
bool  set,
Atom  one,
Atom  two = 0 
)

Definition at line 413 of file qwidget_x11.cpp.

Referenced by qstring_to_xtp(), and QApplication::syncX().

414 {
415  if (!w->isVisible()) // not managed by the window manager
416  return;
417 
418  XEvent e;
419  e.xclient.type = ClientMessage;
420  e.xclient.message_type = ATOM(_NET_WM_STATE);
421  e.xclient.display = X11->display;
422  e.xclient.window = w->internalWinId();
423  e.xclient.format = 32;
424  e.xclient.data.l[0] = set ? 1 : 0;
425  e.xclient.data.l[1] = one;
426  e.xclient.data.l[2] = two;
427  e.xclient.data.l[3] = 0;
428  e.xclient.data.l[4] = 0;
429  XSendEvent(X11->display, RootWindow(X11->display, w->x11Info().screen()),
430  false, (SubstructureNotifyMask | SubstructureRedirectMask), &e);
431 }
bool isVisible() const
Definition: qwidget.h:1005
const QX11Info & x11Info() const
Returns information about the configuration of the X display used to display the widget.
#define X11
Definition: qt_x11_p.h:724
union _XEvent XEvent
Definition: qwindowdefs.h:116
#define ATOM(x)
Definition: qt_x11_p.h:723
WId internalWinId() const
Returns the window system identifier of the widget, or 0 if the widget is not created yet...
Definition: qwidget.h:244
int screen() const
Returns the number of the screen currently in use.

◆ qt_check_clipboard_sentinel()

bool qt_check_clipboard_sentinel ( )

Definition at line 1485 of file qclipboard_x11.cpp.

Referenced by qt_xfixes_clipboard_changed(), and QApplication::x11ProcessEvent().

1486 {
1487  bool doIt = true;
1488  if (owner && !X11->use_xfixes) {
1489  unsigned char *retval;
1490  Atom actualType;
1491  int actualFormat;
1492  unsigned long nitems, bytesLeft;
1493 
1494  if (XGetWindowProperty(X11->display,
1496  ATOM(_QT_CLIPBOARD_SENTINEL), 0, 2, False, XA_WINDOW,
1497  &actualType, &actualFormat, &nitems, &bytesLeft,
1498  &retval) == Success) {
1499  Window *owners = (Window *)retval;
1500  if (actualType == XA_WINDOW && actualFormat == 32 && nitems == 2) {
1501  Window win = owner->internalWinId();
1502  if (owners[0] == win || owners[1] == win)
1503  doIt = false;
1504  }
1505 
1506  XFree(owners);
1507  }
1508  }
1509 
1510  if (doIt) {
1511  if (waiting_for_data) {
1513  if (! pending_timer_id)
1515  doIt = false;
1516  } else {
1517  clipboardData()->clear();
1518  }
1519  }
1520 
1521  return doIt;
1522 }
int startTimer(int interval)
Starts a timer and returns a timer identifier, or returns zero if it could not start a timer...
Definition: qobject.cpp:1623
static bool pending_clipboard_changed
static int pending_timer_id
static QWidget * owner
#define X11
Definition: qt_x11_p.h:724
#define ATOM(x)
Definition: qt_x11_p.h:723
static QClipboardData * clipboardData()
static QClipboard * clipboard()
Returns a pointer to the application global clipboard.
QWidget * screen(int screen=-1)
static QDesktopWidget * desktop()
Returns the desktop widget (also called the root window).
static bool waiting_for_data
WId internalWinId() const
Returns the window system identifier of the widget, or 0 if the widget is not created yet...
Definition: qwidget.h:244

◆ qt_check_focus_model()

static void qt_check_focus_model ( )
static

Definition at line 1550 of file qapplication_x11.cpp.

Referenced by QApplication::x11ProcessEvent().

1551 {
1552  Window fw = XNone;
1553  int unused;
1554  XGetInputFocus(X11->display, &fw, &unused);
1555  if (fw == PointerRoot)
1556  X11->focus_model = QX11Data::FM_PointerRoot;
1557  else
1558  X11->focus_model = QX11Data::FM_Other;
1559 }
#define X11
Definition: qt_x11_p.h:724

◆ qt_check_selection_sentinel()

bool qt_check_selection_sentinel ( )

Definition at line 1433 of file qclipboard_x11.cpp.

Referenced by qt_xfixes_selection_changed(), and QApplication::x11ProcessEvent().

1434 {
1435  bool doIt = true;
1436  if (owner && !X11->use_xfixes) {
1437  /*
1438  Since the X selection mechanism cannot give any signal when
1439  the selection has changed, we emulate it (for Qt processes) here.
1440  The notification should be ignored in case of either
1441  a) This is the process that did setData (because setData()
1442  then has already emitted dataChanged())
1443  b) This is the process that owned the selection when dataChanged()
1444  was called (because we have then received a SelectionClear event,
1445  and have already emitted dataChanged() as a result of that)
1446  */
1447 
1448  unsigned char *retval;
1449  Atom actualType;
1450  int actualFormat;
1451  ulong nitems;
1452  ulong bytesLeft;
1453 
1454  if (XGetWindowProperty(X11->display,
1456  ATOM(_QT_SELECTION_SENTINEL), 0, 2, False, XA_WINDOW,
1457  &actualType, &actualFormat, &nitems,
1458  &bytesLeft, &retval) == Success) {
1459  Window *owners = (Window *)retval;
1460  if (actualType == XA_WINDOW && actualFormat == 32 && nitems == 2) {
1461  Window win = owner->internalWinId();
1462  if (owners[0] == win || owners[1] == win)
1463  doIt = false;
1464  }
1465 
1466  XFree(owners);
1467  }
1468  }
1469 
1470  if (doIt) {
1471  if (waiting_for_data) {
1473  if (! pending_timer_id)
1475  doIt = false;
1476  } else {
1477  selectionData()->clear();
1478  }
1479  }
1480 
1481  return doIt;
1482 }
int startTimer(int interval)
Starts a timer and returns a timer identifier, or returns zero if it could not start a timer...
Definition: qobject.cpp:1623
static int pending_timer_id
static QWidget * owner
#define X11
Definition: qt_x11_p.h:724
#define ATOM(x)
Definition: qt_x11_p.h:723
static QClipboard * clipboard()
Returns a pointer to the application global clipboard.
unsigned long ulong
Definition: qglobal.h:997
static bool pending_selection_changed
QWidget * screen(int screen=-1)
static QDesktopWidget * desktop()
Returns the desktop widget (also called the root window).
static QClipboardData * selectionData()
static bool waiting_for_data
WId internalWinId() const
Returns the window system identifier of the widget, or 0 if the widget is not created yet...
Definition: qwidget.h:244

◆ qt_cleanup()

void qt_cleanup ( )

Definition at line 2680 of file qapplication_x11.cpp.

Referenced by QApplication::~QApplication(), and QApplicationPrivate::~QApplicationPrivate().

2681 {
2682  if (app_save_rootinfo) // root window must keep state
2683  qt_save_rootinfo();
2684 
2685  if (qt_is_gui_used) {
2688  QFont::cleanup();
2690 
2691 #if !defined (QT_NO_TABLET)
2693  if (X11->ptrXCloseDevice)
2694  for (int i = 0; i < devices->size(); ++i)
2695  X11->ptrXCloseDevice(X11->display, (XDevice*)devices->at(i).device);
2696  devices->clear();
2697 #endif
2698  }
2699 
2700 #ifndef QT_NO_XRENDER
2701  for (int i = 0; i < X11->solid_fill_count; ++i) {
2702  if (X11->solid_fills[i].picture)
2703  XRenderFreePicture(X11->display, X11->solid_fills[i].picture);
2704  }
2705  for (int i = 0; i < X11->pattern_fill_count; ++i) {
2706  if (X11->pattern_fills[i].picture)
2707  XRenderFreePicture(X11->display, X11->pattern_fills[i].picture);
2708  }
2709 #endif
2710 
2711 #if !defined(QT_NO_IM)
2714 #endif
2715 
2716  // Reset the error handlers
2717  if (qt_is_gui_used)
2718  XSync(X11->display, False); // sync first to process all possible errors
2719  XSetErrorHandler(original_x_errhandler);
2720  XSetIOErrorHandler(original_xio_errhandler);
2721 
2722  if (X11->argbColormaps) {
2723  for (int s = 0; s < X11->screenCount; s++) {
2724  if (X11->argbColormaps[s])
2725  XFreeColormap(X11->display, X11->argbColormaps[s]);
2726  }
2727  }
2728 
2729  if (qt_is_gui_used && !X11->foreignDisplay)
2730  XCloseDisplay(X11->display); // close X display
2731  X11->display = 0;
2732 
2733  delete [] X11->screens;
2734  delete [] X11->argbVisuals;
2735  delete [] X11->argbColormaps;
2736 
2737  if (X11->foreignDisplay) {
2738  delete [] (char *)appName;
2739  appName = 0;
2740  }
2741 
2742  delete [] (char *)appClass;
2743  appClass = 0;
2744 
2745  if (X11->net_supported_list)
2746  delete [] X11->net_supported_list;
2747  X11->net_supported_list = 0;
2748 
2749  if (X11->net_virtual_root_list)
2750  delete [] X11->net_virtual_root_list;
2751  X11->net_virtual_root_list = 0;
2752 
2753  delete X11;
2754  X11 = 0;
2755 }
static const char * appName
static void cleanup()
Internal function that cleans up the font system.
Definition: qfont_mac.cpp:93
static void qt_save_rootinfo()
#define X11
Definition: qt_x11_p.h:724
static const char * appClass
QTabletDeviceDataList * qt_tablet_devices()
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
static void clear()
Removes all pixmaps from the cache.
void clear()
Removes all items from the list.
Definition: qlist.h:764
static QInputContext * inputContext
static bool app_save_rootinfo
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
bool qt_is_gui_used
static void cleanup()
Definition: qcursor.cpp:402
static int(* original_x_errhandler)(Display *dpy, XErrorEvent *)
static int(* original_xio_errhandler)(Display *dpy)
static void cleanup()
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ qt_desktopwidget_update_workarea()

void qt_desktopwidget_update_workarea ( )

Definition at line 59 of file qdesktopwidget_x11.cpp.

Referenced by QApplication::x11ProcessEvent().

60 {
62 }
static bool qt_desktopwidget_workarea_dirty

◆ qt_get_net_supported()

static void qt_get_net_supported ( )
static

Definition at line 1389 of file qapplication_x11.cpp.

Referenced by qt_init(), and QApplication::x11ProcessEvent().

1390 {
1391  Atom type;
1392  int format;
1393  long offset = 0;
1394  unsigned long nitems, after;
1395  unsigned char *data = 0;
1396 
1397  int e = XGetWindowProperty(X11->display, QX11Info::appRootWindow(),
1398  ATOM(_NET_SUPPORTED), 0, 0,
1399  False, XA_ATOM, &type, &format, &nitems, &after, &data);
1400  if (data)
1401  XFree(data);
1402 
1403  if (X11->net_supported_list)
1404  delete [] X11->net_supported_list;
1405  X11->net_supported_list = 0;
1406 
1407  if (e == Success && type == XA_ATOM && format == 32) {
1408  QBuffer ts;
1410 
1411  while (after > 0) {
1412  XGetWindowProperty(X11->display, QX11Info::appRootWindow(),
1413  ATOM(_NET_SUPPORTED), offset, 1024,
1414  False, XA_ATOM, &type, &format, &nitems, &after, &data);
1415 
1416  if (type == XA_ATOM && format == 32) {
1417  ts.write(reinterpret_cast<char *>(data), nitems * sizeof(long));
1418  offset += nitems;
1419  } else
1420  after = 0;
1421  if (data)
1422  XFree(data);
1423  }
1424 
1425  // compute nitems
1426  QByteArray buffer(ts.buffer());
1427  nitems = buffer.size() / sizeof(Atom);
1428  X11->net_supported_list = new Atom[nitems + 1];
1429  Atom *a = (Atom *) buffer.data();
1430  uint i;
1431  for (i = 0; i < nitems; i++)
1432  X11->net_supported_list[i] = a[i];
1433  X11->net_supported_list[nitems] = 0;
1434  }
1435 }
int type
Definition: qmetatype.cpp:239
bool open(OpenMode openMode)
Reimplemented Function
Definition: qbuffer.cpp:338
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
static Qt::HANDLE appRootWindow(int screen=-1)
Returns a handle for the applications root window on the given screen.
long ASN1_INTEGER_get ASN1_INTEGER * a
The QBuffer class provides a QIODevice interface for a QByteArray.
Definition: qbuffer.h:57
#define X11
Definition: qt_x11_p.h:724
#define ATOM(x)
Definition: qt_x11_p.h:723
QByteArray & buffer()
Returns a reference to the QBuffer&#39;s internal buffer.
Definition: qbuffer.cpp:271
static const char * data(const QByteArray &arr)
unsigned int uint
Definition: qglobal.h:996
int size() const
Returns the number of bytes in this byte array.
Definition: qbytearray.h:402
qint64 write(const char *data, qint64 len)
Writes at most maxSize bytes of data from data to the device.
Definition: qiodevice.cpp:1342

◆ qt_get_net_virtual_roots()

static void qt_get_net_virtual_roots ( )
static

Definition at line 1457 of file qapplication_x11.cpp.

Referenced by qt_init(), and QApplication::x11ProcessEvent().

1458 {
1459  if (X11->net_virtual_root_list)
1460  delete [] X11->net_virtual_root_list;
1461  X11->net_virtual_root_list = 0;
1462 
1463  if (!X11->isSupportedByWM(ATOM(_NET_VIRTUAL_ROOTS)))
1464  return;
1465 
1466  Atom type;
1467  int format;
1468  long offset = 0;
1469  unsigned long nitems, after;
1470  unsigned char *data;
1471 
1472  int e = XGetWindowProperty(X11->display, QX11Info::appRootWindow(),
1473  ATOM(_NET_VIRTUAL_ROOTS), 0, 0,
1474  False, XA_ATOM, &type, &format, &nitems, &after, &data);
1475  if (data)
1476  XFree(data);
1477 
1478  if (e == Success && type == XA_ATOM && format == 32) {
1479  QBuffer ts;
1481 
1482  while (after > 0) {
1483  XGetWindowProperty(X11->display, QX11Info::appRootWindow(),
1484  ATOM(_NET_VIRTUAL_ROOTS), offset, 1024,
1485  False, XA_ATOM, &type, &format, &nitems, &after, &data);
1486 
1487  if (type == XA_ATOM && format == 32) {
1488  ts.write(reinterpret_cast<char *>(data), nitems * 4);
1489  offset += nitems;
1490  } else
1491  after = 0;
1492  if (data)
1493  XFree(data);
1494  }
1495 
1496  // compute nitems
1497  QByteArray buffer(ts.buffer());
1498  nitems = buffer.size() / sizeof(Window);
1499  X11->net_virtual_root_list = new Window[nitems + 1];
1500  Window *a = (Window *) buffer.data();
1501  uint i;
1502  for (i = 0; i < nitems; i++)
1503  X11->net_virtual_root_list[i] = a[i];
1504  X11->net_virtual_root_list[nitems] = 0;
1505  }
1506 }
int type
Definition: qmetatype.cpp:239
bool open(OpenMode openMode)
Reimplemented Function
Definition: qbuffer.cpp:338
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
static Qt::HANDLE appRootWindow(int screen=-1)
Returns a handle for the applications root window on the given screen.
long ASN1_INTEGER_get ASN1_INTEGER * a
The QBuffer class provides a QIODevice interface for a QByteArray.
Definition: qbuffer.h:57
#define X11
Definition: qt_x11_p.h:724
#define ATOM(x)
Definition: qt_x11_p.h:723
QByteArray & buffer()
Returns a reference to the QBuffer&#39;s internal buffer.
Definition: qbuffer.cpp:271
static const char * data(const QByteArray &arr)
unsigned int uint
Definition: qglobal.h:996
int size() const
Returns the number of bytes in this byte array.
Definition: qbytearray.h:402
qint64 write(const char *data, qint64 len)
Writes at most maxSize bytes of data from data to the device.
Definition: qiodevice.cpp:1342

◆ qt_init()

void qt_init ( QApplicationPrivate priv,
int  ,
Display display = 0,
Qt::HANDLE  visual = 0,
Qt::HANDLE  colormap = 0 
)

Definition at line 1666 of file qapplication_x11.cpp.

Referenced by QApplicationPrivate::construct(), and QApplicationPrivate::~QApplicationPrivate().

1668 {
1669  X11 = new QX11Data;
1670  X11->display = display;
1671  X11->displayName = 0;
1672  X11->foreignDisplay = (display != 0);
1673  X11->focus_model = -1;
1674 
1675  // RANDR
1676  X11->use_xrandr = false;
1677  X11->xrandr_major = 0;
1678  X11->xrandr_eventbase = 0;
1679  X11->xrandr_errorbase = 0;
1680 
1681  // RENDER
1682  X11->use_xrender = false;
1683  X11->xrender_major = 0;
1684  X11->xrender_version = 0;
1685 
1686  // XFIXES
1687  X11->use_xfixes = false;
1688  X11->xfixes_major = 0;
1689  X11->xfixes_eventbase = 0;
1690  X11->xfixes_errorbase = 0;
1691 
1692  // XInputExtension
1693  X11->use_xinput = false;
1694  X11->xinput_major = 0;
1695  X11->xinput_eventbase = 0;
1696  X11->xinput_errorbase = 0;
1697 
1698  X11->use_xkb = false;
1699  X11->xkb_major = 0;
1700  X11->xkb_eventbase = 0;
1701  X11->xkb_errorbase = 0;
1702 
1703  // MIT-SHM
1704  X11->use_mitshm = false;
1705  X11->use_mitshm_pixmaps = false;
1706  X11->mitshm_major = 0;
1707 
1708  X11->sip_serial = 0;
1709  X11->net_supported_list = 0;
1710  X11->net_virtual_root_list = 0;
1711  X11->wm_client_leader = 0;
1712  X11->screens = 0;
1713  X11->argbVisuals = 0;
1714  X11->argbColormaps = 0;
1715  X11->screenCount = 0;
1716  X11->time = CurrentTime;
1717  X11->userTime = CurrentTime;
1718  X11->ignore_badwindow = false;
1719  X11->seen_badwindow = false;
1720 
1721  X11->motifdnd_active = false;
1722 
1723  X11->default_im = QLatin1String("imsw-multi");
1724  priv->inputContext = 0;
1725 
1726  // colormap control
1727  X11->visual_class = -1;
1728  X11->visual_id = -1;
1729  X11->color_count = 0;
1730  X11->custom_cmap = false;
1731 
1732  // outside visual/colormap
1733  X11->visual = reinterpret_cast<Visual *>(visual);
1734  X11->colormap = colormap;
1735 
1736  // Fontconfig
1737  X11->has_fontconfig = false;
1738 #if !defined(QT_NO_FONTCONFIG)
1739  if (qgetenv("QT_X11_NO_FONTCONFIG").isNull())
1740  X11->has_fontconfig = FcInit();
1741  X11->fc_antialias = true;
1742 #endif
1743 
1744 #ifndef QT_NO_XRENDER
1745  memset(X11->solid_fills, 0, sizeof(X11->solid_fills));
1746  for (int i = 0; i < X11->solid_fill_count; ++i)
1747  X11->solid_fills[i].screen = -1;
1748  memset(X11->pattern_fills, 0, sizeof(X11->pattern_fills));
1749  for (int i = 0; i < X11->pattern_fill_count; ++i)
1750  X11->pattern_fills[i].screen = -1;
1751 #endif
1752 
1753  X11->startupId = 0;
1754 
1755  int argc = priv->argc;
1756  char **argv = priv->argv;
1757 
1758  if (X11->display) {
1759  // Qt part of other application
1760 
1761  // Set application name and class
1762  appName = qstrdup("Qt-subapplication");
1763  char *app_class = 0;
1764  if (argv) {
1765  const char* p = strrchr(argv[0], '/');
1766  app_class = qstrdup(p ? p + 1 : argv[0]);
1767  if (app_class[0])
1768  app_class[0] = toupper(app_class[0]);
1769  }
1770  appClass = app_class;
1771  } else {
1772  // Qt controls everything (default)
1773 
1775  XInitThreads();
1776 
1777  // Set application name and class
1778  char *app_class = 0;
1779  if (argv && argv[0]) {
1780  const char *p = strrchr(argv[0], '/');
1781  appName = p ? p + 1 : argv[0];
1782  app_class = qstrdup(appName);
1783  if (app_class[0])
1784  app_class[0] = toupper(app_class[0]);
1785  }
1786  appClass = app_class;
1787  }
1788 
1789  // Install default error handlers
1790  original_x_errhandler = XSetErrorHandler(qt_x_errhandler);
1791  original_xio_errhandler = XSetIOErrorHandler(qt_xio_errhandler);
1792 
1793  // Get command line params
1794  int j = argc ? 1 : 0;
1795  for (int i=1; i<argc; i++) {
1796  if (argv[i] && *argv[i] != '-') {
1797  argv[j++] = argv[i];
1798  continue;
1799  }
1800  QByteArray arg(argv[i]);
1801  if (arg == "-display") {
1802  if (++i < argc && !X11->display)
1803  X11->displayName = argv[i];
1804  } else if (arg == "-fn" || arg == "-font") {
1805  if (++i < argc)
1806  appFont = argv[i];
1807  } else if (arg == "-bg" || arg == "-background") {
1808  if (++i < argc)
1809  appBGCol = argv[i];
1810  } else if (arg == "-btn" || arg == "-button") {
1811  if (++i < argc)
1812  appBTNCol = argv[i];
1813  } else if (arg == "-fg" || arg == "-foreground") {
1814  if (++i < argc)
1815  appFGCol = argv[i];
1816  } else if (arg == "-name") {
1817  if (++i < argc)
1818  appName = argv[i];
1819  } else if (arg == "-title") {
1820  if (++i < argc)
1821  mwTitle = argv[i];
1822  } else if (arg == "-geometry") {
1823  if (++i < argc)
1824  mwGeometry = argv[i];
1825  } else if (arg == "-im") {
1826  if (++i < argc)
1827  qt_ximServer = argv[i];
1828  } else if (arg == "-ncols") { // xv and netscape use this name
1829  if (++i < argc)
1830  X11->color_count = qMax(0,atoi(argv[i]));
1831  } else if (arg == "-visual") { // xv and netscape use this name
1832  if (++i < argc && !X11->visual) {
1833  QString s = QString::fromLocal8Bit(argv[i]).toLower();
1834  if (s == QLatin1String("staticgray"))
1835  X11->visual_class = StaticGray;
1836  else if (s == QLatin1String("grayscale"))
1837  X11->visual_class = XGrayScale;
1838  else if (s == QLatin1String("staticcolor"))
1839  X11->visual_class = StaticColor;
1840  else if (s == QLatin1String("pseudocolor"))
1841  X11->visual_class = PseudoColor;
1842  else if (s == QLatin1String("truecolor"))
1843  X11->visual_class = TrueColor;
1844  else if (s == QLatin1String("directcolor"))
1845  X11->visual_class = DirectColor;
1846  else
1847  X11->visual_id = static_cast<int>(strtol(argv[i], 0, 0));
1848  }
1849 #ifndef QT_NO_XIM
1850  } else if (arg == "-inputstyle") {
1851  if (++i < argc) {
1852  QString s = QString::fromLocal8Bit(argv[i]).toLower();
1853  if (s == QLatin1String("onthespot"))
1854  qt_xim_preferred_style = XIMPreeditCallbacks |
1855  XIMStatusNothing;
1856  else if (s == QLatin1String("overthespot"))
1857  qt_xim_preferred_style = XIMPreeditPosition |
1858  XIMStatusNothing;
1859  else if (s == QLatin1String("offthespot"))
1860  qt_xim_preferred_style = XIMPreeditArea |
1861  XIMStatusArea;
1862  else if (s == QLatin1String("root"))
1863  qt_xim_preferred_style = XIMPreeditNothing |
1864  XIMStatusNothing;
1865  }
1866 #endif
1867  } else if (arg == "-cmap") { // xv uses this name
1868  if (!X11->colormap)
1869  X11->custom_cmap = true;
1870  }
1871  else if (arg == "-sync")
1872  appSync = !appSync;
1873 #if defined(QT_DEBUG)
1874  else if (arg == "-nograb")
1875  appNoGrab = !appNoGrab;
1876  else if (arg == "-dograb")
1877  appDoGrab = !appDoGrab;
1878 #endif
1879  else
1880  argv[j++] = argv[i];
1881  }
1882 
1883  priv->argc = j;
1884 
1885 #if defined(QT_DEBUG) && defined(Q_OS_LINUX)
1886  if (!appNoGrab && !appDoGrab && runningUnderDebugger()) {
1887  appNoGrab = true;
1888  qDebug("Qt: gdb: -nograb added to command-line options.\n"
1889  "\t Use the -dograb option to enforce grabbing.");
1890  }
1891 #endif
1892 
1893  // Connect to X server
1894  if (qt_is_gui_used && !X11->display) {
1895  if ((X11->display = XOpenDisplay(X11->displayName)) == 0) {
1896  qWarning("%s: cannot connect to X server %s", appName,
1897  XDisplayName(X11->displayName));
1899  exit(1);
1900  }
1901 
1902  if (appSync) // if "-sync" argument
1903  XSynchronize(X11->display, true);
1904  }
1905 
1906  // Common code, regardless of whether display is foreign.
1907 
1908  // Get X parameters
1909 
1910  if (qt_is_gui_used) {
1911  X11->defaultScreen = DefaultScreen(X11->display);
1912  X11->screenCount = ScreenCount(X11->display);
1913 
1914  int formatCount = 0;
1915  XPixmapFormatValues *values = XListPixmapFormats(X11->display, &formatCount);
1916  for (int i = 0; i < formatCount; ++i)
1917  X11->bppForDepth[values[i].depth] = values[i].bits_per_pixel;
1918  XFree(values);
1919 
1920  X11->screens = new QX11InfoData[X11->screenCount];
1921  X11->argbVisuals = new Visual *[X11->screenCount];
1922  X11->argbColormaps = new Colormap[X11->screenCount];
1923 
1924  for (int s = 0; s < X11->screenCount; s++) {
1925  QX11InfoData *screen = X11->screens + s;
1926  screen->ref = 1; // ensures it doesn't get deleted
1927  screen->screen = s;
1928 
1929  int widthMM = DisplayWidthMM(X11->display, s);
1930  if (widthMM != 0) {
1931  screen->dpiX = (DisplayWidth(X11->display, s) * 254 + widthMM * 5) / (widthMM * 10);
1932  } else {
1933  screen->dpiX = 72;
1934  }
1935 
1936  int heightMM = DisplayHeightMM(X11->display, s);
1937  if (heightMM != 0) {
1938  screen->dpiY = (DisplayHeight(X11->display, s) * 254 + heightMM * 5) / (heightMM * 10);
1939  } else {
1940  screen->dpiY = 72;
1941  }
1942 
1943  X11->argbVisuals[s] = 0;
1944  X11->argbColormaps[s] = 0;
1945  }
1946 
1947 
1948 #ifndef QT_NO_XRENDER
1949  int xrender_eventbase, xrender_errorbase;
1950  // See if XRender is supported on the connected display
1951  if (XQueryExtension(X11->display, "RENDER", &X11->xrender_major,
1952  &xrender_eventbase, &xrender_errorbase)
1953  && XRenderQueryExtension(X11->display, &xrender_eventbase,
1954  &xrender_errorbase)) {
1955  // Check the version as well - we need v0.4 or higher
1956  int major = 0;
1957  int minor = 0;
1958  XRenderQueryVersion(X11->display, &major, &minor);
1959  if (qgetenv("QT_X11_NO_XRENDER").isNull()) {
1960  X11->use_xrender = (major >= 0 && minor >= 5);
1961  X11->xrender_version = major*100+minor;
1962  // workaround for broken XServer on Ubuntu Breezy (6.8 compiled with 7.0
1963  // protocol headers)
1964  if (X11->xrender_version == 10
1965  && VendorRelease(X11->display) < 60900000
1966  && QByteArray(ServerVendor(X11->display)).contains("X.Org"))
1967  X11->xrender_version = 9;
1968  }
1969  }
1970 #endif // QT_NO_XRENDER
1971 
1972 #ifndef QT_NO_MITSHM
1973  int mitshm_minor;
1974  int mitshm_major;
1975  int mitshm_eventbase;
1976  int mitshm_errorbase;
1977  int mitshm_pixmaps;
1978  if (XQueryExtension(X11->display, "MIT-SHM", &X11->mitshm_major,
1979  &mitshm_eventbase, &mitshm_errorbase)
1980  && XShmQueryVersion(X11->display, &mitshm_major, &mitshm_minor,
1981  &mitshm_pixmaps))
1982  {
1983  QString displayName = QLatin1String(XDisplayName(NULL));
1984 
1985  // MITSHM only works for local displays, so do a quick check here
1986  // to determine whether the display is local or not (not 100 % accurate).
1987  // BGR server layouts are not supported either, since it requires the raster
1988  // engine to work on a QImage with BGR layout.
1989  bool local = displayName.isEmpty() || displayName.lastIndexOf(QLatin1Char(':')) == 0;
1990  if (local && (qgetenv("QT_X11_NO_MITSHM").toInt() == 0)) {
1991  Visual *defaultVisual = DefaultVisual(X11->display, DefaultScreen(X11->display));
1992  X11->use_mitshm = ((defaultVisual->red_mask == 0xff0000
1993  || defaultVisual->red_mask == 0xf800)
1994  && (defaultVisual->green_mask == 0xff00
1995  || defaultVisual->green_mask == 0x7e0)
1996  && (defaultVisual->blue_mask == 0xff
1997  || defaultVisual->blue_mask == 0x1f));
1998  X11->use_mitshm_pixmaps = X11->use_mitshm && mitshm_pixmaps;
1999  }
2000  }
2001 #endif // QT_NO_MITSHM
2002 
2003  // initialize the graphics system - order is imporant here - it must be done before
2004  // the QColormap::initialize() call
2007 
2008  // Support protocols
2009  X11->xdndSetup();
2010 
2011  // Finally create all atoms
2013 
2014  // initialize NET lists
2017 
2018 #ifndef QT_NO_XRANDR
2019  // See if XRandR is supported on the connected display
2020  if (XQueryExtension(X11->display, "RANDR", &X11->xrandr_major,
2021  &X11->xrandr_eventbase, &X11->xrandr_errorbase)) {
2022 
2023 # ifdef QT_RUNTIME_XRANDR
2024  X11->ptrXRRSelectInput = 0;
2025  X11->ptrXRRUpdateConfiguration = 0;
2026  X11->ptrXRRRootToScreen = 0;
2027  X11->ptrXRRQueryExtension = 0;
2028  QLibrary xrandrLib(QLatin1String("Xrandr"), 2);
2029  xrandrLib.setLoadHints(QLibrary::ImprovedSearchHeuristics);
2030  if (!xrandrLib.load()) { // try without the version number
2031  xrandrLib.setFileName(QLatin1String("Xrandr"));
2032  xrandrLib.load();
2033  }
2034  if (xrandrLib.isLoaded()) {
2035  X11->ptrXRRSelectInput =
2036  (PtrXRRSelectInput) xrandrLib.resolve("XRRSelectInput");
2037  X11->ptrXRRUpdateConfiguration =
2038  (PtrXRRUpdateConfiguration) xrandrLib.resolve("XRRUpdateConfiguration");
2039  X11->ptrXRRRootToScreen =
2040  (PtrXRRRootToScreen) xrandrLib.resolve("XRRRootToScreen");
2041  X11->ptrXRRQueryExtension =
2042  (PtrXRRQueryExtension) xrandrLib.resolve("XRRQueryExtension");
2043  }
2044 # else
2045  X11->ptrXRRSelectInput = XRRSelectInput;
2046  X11->ptrXRRUpdateConfiguration = XRRUpdateConfiguration;
2047  X11->ptrXRRRootToScreen = XRRRootToScreen;
2048  X11->ptrXRRQueryExtension = XRRQueryExtension;
2049 # endif
2050 
2051  if (X11->ptrXRRQueryExtension
2052  && X11->ptrXRRQueryExtension(X11->display, &X11->xrandr_eventbase, &X11->xrandr_errorbase)) {
2053  // XRandR is supported
2054  X11->use_xrandr = true;
2055  }
2056  }
2057 #endif // QT_NO_XRANDR
2058 
2059 #ifndef QT_NO_XRENDER
2060  if (X11->use_xrender) {
2061  // XRender is supported, let's see if we have a PictFormat for the
2062  // default visual
2063  XRenderPictFormat *format =
2064  XRenderFindVisualFormat(X11->display,
2065  (Visual *) QX11Info::appVisual(X11->defaultScreen));
2066 
2067  if (!format) {
2068  X11->use_xrender = false;
2069  }
2070  }
2071 #endif // QT_NO_XRENDER
2072 
2073 #ifndef QT_NO_XFIXES
2074  // See if Xfixes is supported on the connected display
2075  if (XQueryExtension(X11->display, "XFIXES", &X11->xfixes_major,
2076  &X11->xfixes_eventbase, &X11->xfixes_errorbase)) {
2077  X11->ptrXFixesQueryExtension = XFIXES_LOAD_V1(XFixesQueryExtension);
2078  X11->ptrXFixesQueryVersion = XFIXES_LOAD_V1(XFixesQueryVersion);
2079  X11->ptrXFixesSetCursorName = XFIXES_LOAD_V2(XFixesSetCursorName);
2080  X11->ptrXFixesSelectSelectionInput = XFIXES_LOAD_V2(XFixesSelectSelectionInput);
2081 
2082  if(X11->ptrXFixesQueryExtension && X11->ptrXFixesQueryVersion
2083  && X11->ptrXFixesQueryExtension(X11->display, &X11->xfixes_eventbase,
2084  &X11->xfixes_errorbase)) {
2085  // Xfixes is supported.
2086  // Note: the XFixes protocol version is negotiated using QueryVersion.
2087  // We supply the highest version we support, the X server replies with
2088  // the highest version it supports, but no higher than the version we
2089  // asked for. The version sent back is the protocol version the X server
2090  // will use to talk us. If this call is removed, the behavior of the
2091  // X server when it receives an XFixes request is undefined.
2092  int major = 3;
2093  int minor = 0;
2094  X11->ptrXFixesQueryVersion(X11->display, &major, &minor);
2095  X11->use_xfixes = (major >= 1);
2096  X11->xfixes_major = major;
2097  }
2098  } else {
2099  X11->ptrXFixesQueryExtension = 0;
2100  X11->ptrXFixesQueryVersion = 0;
2101  X11->ptrXFixesSetCursorName = 0;
2102  X11->ptrXFixesSelectSelectionInput = 0;
2103  }
2104 #endif // QT_NO_XFIXES
2105 
2106 #ifndef QT_NO_XCURSOR
2107 #ifdef QT_RUNTIME_XCURSOR
2108  X11->ptrXcursorLibraryLoadCursor = 0;
2109  QLibrary xcursorLib(QLatin1String("Xcursor"), 1);
2110  xcursorLib.setLoadHints(QLibrary::ImprovedSearchHeuristics);
2111  bool xcursorFound = xcursorLib.load();
2112  if (!xcursorFound) { //try without the version number
2113  xcursorLib.setFileName(QLatin1String("Xcursor"));
2114  xcursorFound = xcursorLib.load();
2115  }
2116  if (xcursorFound) {
2117  X11->ptrXcursorLibraryLoadCursor =
2118  (PtrXcursorLibraryLoadCursor) xcursorLib.resolve("XcursorLibraryLoadCursor");
2119  }
2120 #else
2121  X11->ptrXcursorLibraryLoadCursor = XcursorLibraryLoadCursor;
2122 #endif // QT_RUNTIME_XCURSOR
2123 #endif // QT_NO_XCURSOR
2124 
2125 #ifndef QT_NO_XSYNC
2126  int xsync_evbase, xsync_errbase;
2127  int major, minor;
2128  if (XSyncQueryExtension(X11->display, &xsync_evbase, &xsync_errbase))
2129  XSyncInitialize(X11->display, &major, &minor);
2130 #endif // QT_NO_XSYNC
2131 
2132 #ifndef QT_NO_XINERAMA
2133 #ifdef QT_RUNTIME_XINERAMA
2134  X11->ptrXineramaQueryExtension = 0;
2135  X11->ptrXineramaIsActive = 0;
2136  X11->ptrXineramaQueryScreens = 0;
2137  QLibrary xineramaLib(QLatin1String("Xinerama"), 1);
2138  xineramaLib.setLoadHints(QLibrary::ImprovedSearchHeuristics);
2139  bool xineramaFound = xineramaLib.load();
2140  if (!xineramaFound) { //try without the version number
2141  xineramaLib.setFileName(QLatin1String("Xinerama"));
2142  xineramaFound = xineramaLib.load();
2143  }
2144  if (xineramaFound) {
2145  X11->ptrXineramaQueryExtension =
2146  (PtrXineramaQueryExtension) xineramaLib.resolve("XineramaQueryExtension");
2147  X11->ptrXineramaIsActive =
2148  (PtrXineramaIsActive) xineramaLib.resolve("XineramaIsActive");
2149  X11->ptrXineramaQueryScreens =
2150  (PtrXineramaQueryScreens) xineramaLib.resolve("XineramaQueryScreens");
2151  }
2152 #else
2153  X11->ptrXineramaQueryScreens = XineramaQueryScreens;
2154  X11->ptrXineramaIsActive = XineramaIsActive;
2155  X11->ptrXineramaQueryExtension = XineramaQueryExtension;
2156 #endif // QT_RUNTIME_XINERAMA
2157 #endif // QT_NO_XINERAMA
2158 
2159 #ifndef QT_NO_XINPUT
2160  // See if Xinput is supported on the connected display
2161  X11->ptrXCloseDevice = 0;
2162  X11->ptrXListInputDevices = 0;
2163  X11->ptrXOpenDevice = 0;
2164  X11->ptrXFreeDeviceList = 0;
2165  X11->ptrXSelectExtensionEvent = 0;
2166  X11->use_xinput = XQueryExtension(X11->display, "XInputExtension", &X11->xinput_major,
2167  &X11->xinput_eventbase, &X11->xinput_errorbase);
2168  if (X11->use_xinput) {
2169  X11->ptrXCloseDevice = XINPUT_LOAD(XCloseDevice);
2170  X11->ptrXListInputDevices = XINPUT_LOAD(XListInputDevices);
2171  X11->ptrXOpenDevice = XINPUT_LOAD(XOpenDevice);
2172  X11->ptrXFreeDeviceList = XINPUT_LOAD(XFreeDeviceList);
2173  X11->ptrXSelectExtensionEvent = XINPUT_LOAD(XSelectExtensionEvent);
2174  }
2175 #endif // QT_NO_XINPUT
2176 
2177 #ifndef QT_NO_XKB
2178  int xkblibMajor = XkbMajorVersion;
2179  int xkblibMinor = XkbMinorVersion;
2180  X11->use_xkb = XkbQueryExtension(X11->display,
2181  &X11->xkb_major,
2182  &X11->xkb_eventbase,
2183  &X11->xkb_errorbase,
2184  &xkblibMajor,
2185  &xkblibMinor);
2186  if (X11->use_xkb) {
2187  // If XKB is detected, set the GrabsUseXKBState option so input method
2188  // compositions continue to work (ie. deadkeys)
2189  unsigned int state = XkbPCF_GrabsUseXKBStateMask;
2190  (void) XkbSetPerClientControls(X11->display, state, &state);
2191 
2192  // select for group change events
2193  XkbSelectEventDetails(X11->display,
2194  XkbUseCoreKbd,
2195  XkbStateNotify,
2196  XkbAllStateComponentsMask,
2197  XkbGroupStateMask);
2198 
2199  // current group state is queried when creating the keymapper, no need to do it here
2200  }
2201 #endif
2202 
2203 
2204 #if !defined(QT_NO_FONTCONFIG)
2205  int dpi = 0;
2206  getXDefault("Xft", FC_DPI, &dpi);
2207  if (dpi) {
2208  for (int s = 0; s < ScreenCount(X11->display); ++s) {
2209  QX11Info::setAppDpiX(s, dpi);
2210  QX11Info::setAppDpiY(s, dpi);
2211  }
2212  }
2213  double fc_scale = 1.;
2214  getXDefault("Xft", FC_SCALE, &fc_scale);
2215  X11->fc_scale = fc_scale;
2216  for (int s = 0; s < ScreenCount(X11->display); ++s) {
2217  int subpixel = FC_RGBA_UNKNOWN;
2218 #if !defined(QT_NO_XRENDER) && (RENDER_MAJOR > 0 || RENDER_MINOR >= 6)
2219  if (X11->use_xrender) {
2220  int rsp = XRenderQuerySubpixelOrder(X11->display, s);
2221  switch (rsp) {
2222  default:
2223  case SubPixelUnknown:
2224  subpixel = FC_RGBA_UNKNOWN;
2225  break;
2226  case SubPixelHorizontalRGB:
2227  subpixel = FC_RGBA_RGB;
2228  break;
2229  case SubPixelHorizontalBGR:
2230  subpixel = FC_RGBA_BGR;
2231  break;
2232  case SubPixelVerticalRGB:
2233  subpixel = FC_RGBA_VRGB;
2234  break;
2235  case SubPixelVerticalBGR:
2236  subpixel = FC_RGBA_VBGR;
2237  break;
2238  case SubPixelNone:
2239  subpixel = FC_RGBA_NONE;
2240  break;
2241  }
2242  }
2243 #endif
2244 
2245  char *rgba = XGetDefault(X11->display, "Xft", FC_RGBA);
2246  if (rgba) {
2247  char *end = 0;
2248  int v = strtol(rgba, &end, 0);
2249  if (rgba != end) {
2250  subpixel = v;
2251  } else if (qstrncmp(rgba, "unknown", 7) == 0) {
2252  subpixel = FC_RGBA_UNKNOWN;
2253  } else if (qstrncmp(rgba, "rgb", 3) == 0) {
2254  subpixel = FC_RGBA_RGB;
2255  } else if (qstrncmp(rgba, "bgr", 3) == 0) {
2256  subpixel = FC_RGBA_BGR;
2257  } else if (qstrncmp(rgba, "vrgb", 4) == 0) {
2258  subpixel = FC_RGBA_VRGB;
2259  } else if (qstrncmp(rgba, "vbgr", 4) == 0) {
2260  subpixel = FC_RGBA_VBGR;
2261  } else if (qstrncmp(rgba, "none", 4) == 0) {
2262  subpixel = FC_RGBA_NONE;
2263  }
2264  }
2265  X11->screens[s].subpixel = subpixel;
2266  }
2267  getXDefault("Xft", FC_ANTIALIAS, &X11->fc_antialias);
2268 #ifdef FC_HINT_STYLE
2269  X11->fc_hint_style = -1;
2270  getXDefault("Xft", FC_HINT_STYLE, &X11->fc_hint_style);
2271 #endif
2272 #if 0
2273  // ###### these are implemented by Xft, not sure we need them
2274  getXDefault("Xft", FC_AUTOHINT, &X11->fc_autohint);
2275  getXDefault("Xft", FC_HINTING, &X11->fc_autohint);
2276  getXDefault("Xft", FC_MINSPACE, &X11->fc_autohint);
2277 #endif
2278 #endif // QT_NO_XRENDER
2279 
2280  // initialize key mapper
2282 
2283  // Misc. initialization
2284 #if 0 //disabled for now..
2285  QSegfaultHandler::initialize(priv->argv, priv->argc);
2286 #endif
2288  }
2290 
2291  if(qt_is_gui_used) {
2292  qApp->setObjectName(QString::fromLocal8Bit(appName));
2293 
2294  int screen;
2295  for (screen = 0; screen < X11->screenCount; ++screen) {
2296  XSelectInput(X11->display, QX11Info::appRootWindow(screen),
2297  KeymapStateMask | EnterWindowMask | LeaveWindowMask | PropertyChangeMask);
2298 
2299 #ifndef QT_NO_XRANDR
2300  if (X11->use_xrandr)
2301  X11->ptrXRRSelectInput(X11->display, QX11Info::appRootWindow(screen), True);
2302 #endif // QT_NO_XRANDR
2303  }
2304  }
2305 
2306  if (qt_is_gui_used) {
2307  // Attempt to determine the current running X11 Desktop Enviornment
2308  // Use dbus if/when we can, but fall back to using windowManagerName() for now
2309 
2310 #ifndef QT_NO_XFIXES
2311  if (X11->ptrXFixesSelectSelectionInput)
2312  X11->ptrXFixesSelectSelectionInput(X11->display, QX11Info::appRootWindow(), ATOM(_NET_WM_CM_S0),
2313  XFixesSetSelectionOwnerNotifyMask
2314  | XFixesSelectionWindowDestroyNotifyMask
2315  | XFixesSelectionClientCloseNotifyMask);
2316 #endif // QT_NO_XFIXES
2317  X11->compositingManagerRunning = XGetSelectionOwner(X11->display,
2318  ATOM(_NET_WM_CM_S0));
2319  X11->desktopEnvironment = DE_UNKNOWN;
2320  X11->desktopVersion = 0;
2321 
2322  Atom type;
2323  int format;
2324  unsigned long length, after;
2325  uchar *data = 0;
2326  int rc;
2327 
2328  do {
2329  if (!qgetenv("KDE_FULL_SESSION").isEmpty()) {
2330  X11->desktopEnvironment = DE_KDE;
2331  X11->desktopVersion = qgetenv("KDE_SESSION_VERSION").toInt();
2332  break;
2333  }
2334 
2335  if (qgetenv("DESKTOP_SESSION") == "gnome") {
2336  X11->desktopEnvironment = DE_GNOME;
2337  break;
2338  }
2339 
2340  // GNOME_DESKTOP_SESSION_ID is deprecated for some reason, but still check it
2341  if (!qgetenv("GNOME_DESKTOP_SESSION_ID").isEmpty()) {
2342  X11->desktopEnvironment = DE_GNOME;
2343  break;
2344  }
2345 
2346  rc = XGetWindowProperty(X11->display, QX11Info::appRootWindow(), ATOM(_DT_SAVE_MODE),
2347  0, 2, False, XA_STRING, &type, &format, &length,
2348  &after, &data);
2349  if (rc == Success && length) {
2350  if (!strcmp(reinterpret_cast<char *>(data), "xfce4")) {
2351  // Pretend that xfce4 is gnome, as it uses the same libraries.
2352  // The detection above is stolen from xdg-open.
2353  X11->desktopEnvironment = DE_GNOME;
2354  break;
2355  }
2356 
2357  // We got the property but it wasn't xfce4. Free data before it gets overwritten.
2358  XFree(data);
2359  data = 0;
2360  }
2361 
2362  rc = XGetWindowProperty(X11->display, QX11Info::appRootWindow(), ATOM(DTWM_IS_RUNNING),
2363  0, 1, False, AnyPropertyType, &type, &format, &length,
2364  &after, &data);
2365  if (rc == Success && length) {
2366  // DTWM is running, meaning most likely CDE is running...
2367  X11->desktopEnvironment = DE_CDE;
2368  break;
2369  }
2370 
2371  rc = XGetWindowProperty(X11->display, QX11Info::appRootWindow(),
2372  ATOM(_SGI_DESKS_MANAGER), 0, 1, False, XA_WINDOW,
2373  &type, &format, &length, &after, &data);
2374  if (rc == Success && length) {
2375  X11->desktopEnvironment = DE_4DWM;
2376  break;
2377  }
2378 
2379  if (XGetWindowProperty(X11->display, QX11Info::appRootWindow(),
2381  0, 1024, False, XA_WINDOW, &type,
2382  &format, &length, &after, &data) == Success) {
2383  if (type == XA_WINDOW && format == 32) {
2384  Window windowManagerWindow = *((Window*) data);
2385  XFree(data);
2386  data = 0;
2387 
2388  if (windowManagerWindow != XNone) {
2389  Atom utf8atom = ATOM(UTF8_STRING);
2390  if (XGetWindowProperty(QX11Info::display(), windowManagerWindow, ATOM(_NET_WM_NAME),
2391  0, 1024, False, utf8atom, &type,
2392  &format, &length, &after, &data) == Success) {
2393  if (type == utf8atom && format == 8) {
2394  if (qstrcmp((const char *)data, "MCompositor") == 0)
2395  X11->desktopEnvironment = DE_MEEGO_COMPOSITOR;
2396  }
2397  }
2398  }
2399  }
2400  }
2401 
2402  } while(0);
2403 
2404  if (data)
2405  XFree((char *)data);
2406 
2407 #if !defined(QT_NO_STYLE_GTK)
2408  if (X11->desktopEnvironment == DE_GNOME) {
2409  static bool menusHaveIcons = QGtkStyle::getGConfBool(QLatin1String("/desktop/gnome/interface/menus_have_icons"), true);
2411  }
2412 #endif
2414 
2416 
2417  // be smart about the size of the default font. most X servers have helvetica
2418  // 12 point available at 2 resolutions:
2419  // 75dpi (12 pixels) and 100dpi (17 pixels).
2420  // At 95 DPI, a 12 point font should be 16 pixels tall - in which case a 17
2421  // pixel font is a closer match than a 12 pixel font
2422  int ptsz = (X11->use_xrender
2423  ? 9
2424  : (int) (((QX11Info::appDpiY() >= 95 ? 17. : 12.) *
2425  72. / (float) QX11Info::appDpiY()) + 0.5));
2426 
2428  // no font from settings or RESOURCE_MANAGER, provide a fallback
2429  QFont f(X11->has_fontconfig ? QLatin1String("Sans Serif") : QLatin1String("Helvetica"),
2430  ptsz);
2432  }
2433 
2434 #if !defined (QT_NO_TABLET)
2435  if (X11->use_xinput) {
2436  int ndev,
2437  i,
2438  j;
2439  bool gotStylus,
2440  gotEraser;
2441  XDeviceInfo *devices = 0, *devs;
2442  XInputClassInfo *ip;
2443  XAnyClassPtr any;
2444  XValuatorInfoPtr v;
2445  XAxisInfoPtr a;
2446  XDevice *dev = 0;
2447 
2448  if (X11->ptrXListInputDevices) {
2449  devices = X11->ptrXListInputDevices(X11->display, &ndev);
2450  if (!devices)
2451  qWarning("QApplication: Failed to get list of tablet devices");
2452  }
2453  if (!devices)
2454  ndev = -1;
2455  QTabletEvent::TabletDevice deviceType;
2456  for (devs = devices, i = 0; i < ndev && devs; i++, devs++) {
2457  dev = 0;
2458  deviceType = QTabletEvent::NoDevice;
2459  gotStylus = false;
2460  gotEraser = false;
2461 
2462 #if defined(Q_OS_IRIX)
2463  QString devName = QString::fromLocal8Bit(devs->name).toLower();
2464  if (devName == QLatin1String(WACOM_NAME)) {
2465  deviceType = QTabletEvent::Stylus;
2466  gotStylus = true;
2467  }
2468 #else
2469  // qDebug() << "found input device" << devs->name << "type" << devs->type << XGetAtomName(X11->display, devs->type);
2470  if (devs->type == ATOM(XWacomStylus) || devs->type == ATOM(XTabletStylus) || devs->type == ATOM(XTablet)) {
2471  deviceType = QTabletEvent::Stylus;
2472  if (wacomDeviceName()->isEmpty())
2473  wacomDeviceName()->append(devs->name);
2474  gotStylus = true;
2475  } else if (devs->type == ATOM(XWacomEraser) || devs->type == ATOM(XTabletEraser)) {
2476  deviceType = QTabletEvent::XFreeEraser;
2477  gotEraser = true;
2478  }
2479 #endif
2480  if (deviceType == QTabletEvent::NoDevice)
2481  continue;
2482 
2483  if (gotStylus || gotEraser) {
2484  if (X11->ptrXOpenDevice)
2485  dev = X11->ptrXOpenDevice(X11->display, devs->id);
2486 
2487  if (!dev)
2488  continue;
2489 
2490  QTabletDeviceData device_data;
2491  device_data.deviceType = deviceType;
2492  device_data.eventCount = 0;
2493  device_data.device = dev;
2494  device_data.xinput_motion = -1;
2495  device_data.xinput_key_press = -1;
2496  device_data.xinput_key_release = -1;
2497  device_data.xinput_button_press = -1;
2498  device_data.xinput_button_release = -1;
2499  device_data.xinput_proximity_in = -1;
2500  device_data.xinput_proximity_out = -1;
2501  device_data.widgetToGetPress = 0;
2502 
2503  if (dev->num_classes > 0) {
2504  for (ip = dev->classes, j = 0; j < dev->num_classes;
2505  ip++, j++) {
2506  switch (ip->input_class) {
2507  case KeyClass:
2508  DeviceKeyPress(dev, device_data.xinput_key_press,
2509  device_data.eventList[device_data.eventCount]);
2510  if (device_data.eventList[device_data.eventCount])
2511  ++device_data.eventCount;
2512  DeviceKeyRelease(dev, device_data.xinput_key_release,
2513  device_data.eventList[device_data.eventCount]);
2514  if (device_data.eventList[device_data.eventCount])
2515  ++device_data.eventCount;
2516  break;
2517  case ButtonClass:
2518  DeviceButtonPress(dev, device_data.xinput_button_press,
2519  device_data.eventList[device_data.eventCount]);
2520  if (device_data.eventList[device_data.eventCount])
2521  ++device_data.eventCount;
2522  DeviceButtonRelease(dev, device_data.xinput_button_release,
2523  device_data.eventList[device_data.eventCount]);
2524  if (device_data.eventList[device_data.eventCount])
2525  ++device_data.eventCount;
2526  break;
2527  case ValuatorClass:
2528  // I'm only going to be interested in motion when the
2529  // stylus is already down anyway!
2530  DeviceMotionNotify(dev, device_data.xinput_motion,
2531  device_data.eventList[device_data.eventCount]);
2532  if (device_data.eventList[device_data.eventCount])
2533  ++device_data.eventCount;
2534  ProximityIn(dev, device_data.xinput_proximity_in, device_data.eventList[device_data.eventCount]);
2535  if (device_data.eventList[device_data.eventCount])
2536  ++device_data.eventCount;
2537  ProximityOut(dev, device_data.xinput_proximity_out, device_data.eventList[device_data.eventCount]);
2538  if (device_data.eventList[device_data.eventCount])
2539  ++device_data.eventCount;
2540  default:
2541  break;
2542  }
2543  }
2544  }
2545 
2546  // get the min/max value for pressure!
2547  any = (XAnyClassPtr) (devs->inputclassinfo);
2548  for (j = 0; j < devs->num_classes; j++) {
2549  if (any->c_class == ValuatorClass) {
2550  v = (XValuatorInfoPtr) any;
2551  a = (XAxisInfoPtr) ((char *) v +
2552  sizeof (XValuatorInfo));
2553 #if defined (Q_OS_IRIX)
2554  // I'm not exaclty wild about this, but the
2555  // dimensions of the tablet are more relevant here
2556  // than the min and max values from the axis
2557  // (actually it seems to be 2/3 or what is in the
2558  // axis. So we'll try to parse it from this
2559  // string. --tws
2560  char returnString[SGIDeviceRtrnLen];
2561  int tmp;
2562  if (XSGIMiscQueryExtension(X11->display, &tmp, &tmp)
2563  && XSGIDeviceQuery(X11->display, devs->id,
2564  "dimensions", returnString)) {
2565  QString str = QLatin1String(returnString);
2566  int comma = str.indexOf(',');
2567  device_data.minX = 0;
2568  device_data.minY = 0;
2569  device_data.maxX = str.left(comma).toInt();
2570  device_data.maxY = str.mid(comma + 1).toInt();
2571  } else {
2572  device_data.minX = a[WAC_XCOORD_I].min_value;
2573  device_data.maxX = a[WAC_XCOORD_I].max_value;
2574  device_data.minY = a[WAC_YCOORD_I].min_value;
2575  device_data.maxY = a[WAC_YCOORD_I].max_value;
2576  }
2577  device_data.minPressure = a[WAC_PRESSURE_I].min_value;
2578  device_data.maxPressure = a[WAC_PRESSURE_I].max_value;
2579  device_data.minTanPressure = a[WAC_TAN_PRESSURE_I].min_value;
2580  device_data.maxTanPressure = a[WAC_TAN_PRESSURE_I].max_value;
2581  device_data.minZ = a[WAC_ZCOORD_I].min_value;
2582  device_data.maxZ = a[WAC_ZCOORD_I].max_value;
2583 #else
2584  device_data.minX = a[0].min_value;
2585  device_data.maxX = a[0].max_value;
2586  device_data.minY = a[1].min_value;
2587  device_data.maxY = a[1].max_value;
2588  device_data.minPressure = a[2].min_value;
2589  device_data.maxPressure = a[2].max_value;
2590  device_data.minTanPressure = 0;
2591  device_data.maxTanPressure = 0;
2592  device_data.minZ = 0;
2593  device_data.maxZ = 0;
2594 #endif
2595 
2596  // got the max pressure no need to go further...
2597  break;
2598  }
2599  any = (XAnyClassPtr) ((char *) any + any->length);
2600  } // end of for loop
2601 
2602  tablet_devices()->append(device_data);
2603  } // if (gotStylus || gotEraser)
2604  }
2605  if (X11->ptrXFreeDeviceList)
2606  X11->ptrXFreeDeviceList(devices);
2607  }
2608 #endif // QT_NO_TABLET
2609 
2610  X11->startupId = getenv("DESKTOP_STARTUP_ID");
2611  if (X11->startupId) {
2612 #ifndef QT_NO_UNSETENV
2613  unsetenv("DESKTOP_STARTUP_ID");
2614 #else
2615  // it's a small memory leak, however we won't crash if Qt is
2616  // unloaded and someones tries to use the envoriment.
2617  putenv(strdup("DESKTOP_STARTUP_ID="));
2618 #endif
2619  }
2620  } else {
2621  // read some non-GUI settings when not using the X server...
2622 
2624  QSettings settings(QSettings::UserScope, QLatin1String("Trolltech"));
2625  settings.beginGroup(QLatin1String("Qt"));
2626 
2627  // read library (ie. plugin) path list
2628  QString libpathkey = QString::fromLatin1("%1.%2/libraryPath")
2629  .arg(QT_VERSION >> 16)
2630  .arg((QT_VERSION & 0xff00) >> 8);
2631  QStringList pathlist =
2632  settings.value(libpathkey).toString().split(QLatin1Char(':'));
2633  if (! pathlist.isEmpty()) {
2635  while (it != pathlist.constEnd())
2637  }
2638 
2639  QString defaultcodec = settings.value(QLatin1String("defaultCodec"),
2640  QVariant(QLatin1String("none"))).toString();
2641  if (defaultcodec != QLatin1String("none")) {
2643  if (codec)
2645  }
2646 
2647  settings.endGroup(); // Qt
2648  }
2649  }
2650 
2651 #if !defined (Q_OS_IRIX) && !defined (QT_NO_TABLET)
2652  QLibrary wacom(QString::fromLatin1("wacomcfg"), 0); // version 0 is the latest release at time of writing this.
2653  wacom.setLoadHints(QLibrary::ImprovedSearchHeuristics);
2654  // NOTE: C casts instead of reinterpret_cast for GCC 3.3.x
2655  ptrWacomConfigInit = (PtrWacomConfigInit)wacom.resolve("WacomConfigInit");
2656  ptrWacomConfigOpenDevice = (PtrWacomConfigOpenDevice)wacom.resolve("WacomConfigOpenDevice");
2657  ptrWacomConfigGetRawParam = (PtrWacomConfigGetRawParam)wacom.resolve("WacomConfigGetRawParam");
2658  ptrWacomConfigCloseDevice = (PtrWacomConfigCloseDevice)wacom.resolve("WacomConfigCloseDevice");
2659  ptrWacomConfigTerm = (PtrWacomConfigTerm)wacom.resolve("WacomConfigTerm");
2660 
2662  || ptrWacomConfigCloseDevice == 0 || ptrWacomConfigTerm == 0) { // either we have all, or we have none.
2663  ptrWacomConfigInit = 0;
2667  ptrWacomConfigTerm = 0;
2668  }
2669 #endif
2670 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
TabletDevice
This enum defines what type of device is generating the event.
Definition: qevent.h:182
static PtrWacomConfigInit ptrWacomConfigInit
Bool(* PtrXineramaQueryExtension)(Display *dpy, int *event_base, int *error_base)
Definition: qt_x11_p.h:223
Q_CORE_EXPORT QByteArray qgetenv(const char *varName)
static QString fromLocal8Bit(const char *, int size=-1)
Returns a QString initialized with the first size characters of the 8-bit string str.
Definition: qstring.cpp:4245
int type
Definition: qmetatype.cpp:239
int qstrncmp(const char *str1, const char *str2, uint len)
Definition: qbytearray.h:101
static PtrWacomConfigTerm ptrWacomConfigTerm
static const char * appFont
static void reset_instance_pointer()
int toInt(bool *ok=0, int base=10) const
Returns the string converted to an int using base base, which is 10 by default and must be between 2 ...
Definition: qstring.cpp:6090
XIMStyle qt_xim_preferred_style
#define it(className, varName)
The QSettings class provides persistent platform-independent application settings.
Definition: qsettings.h:73
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
static Qt::HANDLE appRootWindow(int screen=-1)
Returns a handle for the applications root window on the given screen.
static void setAttribute(Qt::ApplicationAttribute attribute, bool on=true)
Sets the attribute attribute if on is true; otherwise clears the attribute.
static void addLibraryPath(const QString &)
Prepends path to the beginning of the library path list, ensuring that it is searched for libraries f...
static const char * appName
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the list.
Definition: qlist.h:269
int(* PtrXRRUpdateConfiguration)(XEvent *)
Definition: qt_x11_p.h:230
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
long ASN1_INTEGER_get ASN1_INTEGER * a
static void qt_get_net_virtual_roots()
The QString class provides a Unicode character string.
Definition: qstring.h:83
int qstrcmp(const char *str1, const char *str2)
A safe strcmp() function.
Definition: qbytearray.cpp:231
#define X11
Definition: qt_x11_p.h:724
WACOMDEVICE *(* PtrWacomConfigOpenDevice)(WACOMCONFIG *, const char *)
static QFont * sys_font
int *(* PtrWacomConfigGetRawParam)(WACOMDEVICE *, int, int *, int, unsigned *)
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
QPointer< QWidget > widgetToGetPress
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
int(* PtrWacomConfigCloseDevice)(WACOMDEVICE *)
static const char * appClass
#define ATOM(x)
Definition: qt_x11_p.h:723
Q_CORE_EXPORT void qDebug(const char *,...)
static void initialize(char **, int)
unsigned char uchar
Definition: qglobal.h:994
static void qt_set_input_encoding()
static void setSystemFont(const QFont &font)
static bool appSync
static const char * appBTNCol
static QGraphicsSystem * create(const QString &)
Q_GUI_EXPORT EGLDisplay display()
Definition: qegl.cpp:589
static bool isEmpty(const char *str)
static PtrWacomConfigCloseDevice ptrWacomConfigCloseDevice
QString left(int n) const Q_REQUIRED_RESULT
Returns a substring that contains the n leftmost characters of the string.
Definition: qstring.cpp:3664
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
static void initialize()
Internal function that initializes the font system.
Definition: qfont_mac.cpp:131
#define qApp
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
static void setAppDpiY(int screen, int dpi)
Sets the vertical resolution of the given screen to the number of dots per inch specified by ydpi...
static int toInt(const QByteArray &str)
Definition: generator.cpp:167
Q_CORE_EXPORT void qWarning(const char *,...)
static bool getGConfBool(const QString &key, bool fallback=0)
Returns the configuration boolean for key.
Definition: qgtkstyle.cpp:144
static const char * data(const QByteArray &arr)
#define XINPUT_LOAD(symbol)
int indexOf(QChar c, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.cpp:2838
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
static QTextCodec * codec(MYSQL *mysql)
Definition: qsql_mysql.cpp:220
T value(int i) const
Returns the value at index position i in the list.
Definition: qlist.h:661
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
Definition: qstring.cpp:3993
#define XFIXES_LOAD_V2(symbol)
XineramaScreenInfo *(* PtrXineramaQueryScreens)(Display *dpy, int *number)
Definition: qt_x11_p.h:225
quint16 values[128]
WACOMCONFIG *(* PtrWacomConfigInit)(Display *, WACOMERRORFUNC)
bool isNull() const
Returns true if this byte array is null; otherwise returns false.
static QString graphics_system_name
static PtrWacomConfigGetRawParam ptrWacomConfigGetRawParam
char * qt_ximServer
Bool(* PtrXineramaIsActive)(Display *dpy)
Definition: qt_x11_p.h:224
int(* PtrXRRRootToScreen)(Display *, Window)
Definition: qt_x11_p.h:231
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a string that contains n characters of this string, starting at the specified position index...
Definition: qstring.cpp:3706
static void qt_set_x11_resources(const char *font=0, const char *fg=0, const char *bg=0, const char *button=0)
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
Definition: qstring.cpp:7186
static const char * mwTitle
static QInputContext * inputContext
The QFont class specifies a font used for drawing text.
Definition: qfont.h:64
static void * appVisual(int screen=-1)
Returns the current visual used by the application on the given screen.
int lastIndexOf(QChar c, int from=-1, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.cpp:3000
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
static void changeKeyboard()
Definition: qkeymapper.cpp:90
int toInt(bool *ok=0, int base=10) const
Returns the byte array converted to an int using base base, which is 10 by default and must be betwee...
static void initialize()
const_iterator ConstIterator
Qt-style synonym for QList::const_iterator.
Definition: qlist.h:279
QString toLower() const Q_REQUIRED_RESULT
Returns a lowercase copy of the string.
Definition: qstring.cpp:5389
long unsigned int eventList[TOTAL_XINPUT_EVENTS]
static bool desktopSettingsAware()
Returns true if Qt is set to use the system&#39;s standard colors, fonts, etc.
static int qt_x_errhandler(Display *dpy, XErrorEvent *err)
bool qt_is_gui_used
static int qt_xio_errhandler(Display *)
if(void) toggleToolbarShown
static QGraphicsSystem * graphics_system
static void qt_get_net_supported()
static QTextCodec * codecForName(const QByteArray &name)
Searches all installed QTextCodec objects and returns the one which best matches name; the match is c...
Bool(* PtrXRRQueryExtension)(Display *, int *, int *)
Definition: qt_x11_p.h:232
void(* PtrWacomConfigTerm)(WACOMCONFIG *)
char * qstrdup(const char *src)
Returns a duplicate string.
Definition: qbytearray.cpp:114
static const char * mwGeometry
static void initialize()
Definition: qcursor.cpp:417
QStringList split(const QString &sep, SplitBehavior behavior=KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const Q_REQUIRED_RESULT
Splits the string into substrings wherever sep occurs, and returns the list of those strings...
Definition: qstring.cpp:6526
static int(* original_x_errhandler)(Display *dpy, XErrorEvent *)
static void getXDefault(const char *group, const char *key, int *val)
static const char * appBGCol
static bool appNoGrab
static bool testAttribute(Qt::ApplicationAttribute attribute)
Returns true if attribute attribute is set; otherwise returns false.
static const char * appFGCol
The QTextCodec class provides conversions between text encodings.
Definition: qtextcodec.h:62
static const KeyPair *const end
static int(* original_xio_errhandler)(Display *dpy)
bool runningUnderDebugger()
static void qt_x11_create_intern_atoms()
void(* PtrXRRSelectInput)(Display *, Window, int)
Definition: qt_x11_p.h:229
static void setAppDpiX(int screen, int dpi)
Sets the horizontal resolution of the given screen to the number of dots per inch specified by xdpi...
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
static void setCodecForTr(QTextCodec *c)
Definition: qtextcodec.h:156
static Display * display()
Returns the default display for the application.
static bool isNull(const QVariant::Private *d)
Definition: qvariant.cpp:300
Cursor(* PtrXcursorLibraryLoadCursor)(Display *, const char *)
Definition: qt_x11_p.h:219
The QLibrary class loads shared libraries at runtime.
Definition: qlibrary.h:62
QBool contains(char c) const
Returns true if the byte array contains the character ch; otherwise returns false.
Definition: qbytearray.h:525
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the list...
Definition: qlist.h:272
#define XFIXES_LOAD_V1(symbol)
#define QT_VERSION
This macro expands a numeric value of the form 0xMMNNPP (MM = major, NN = minor, PP = patch) that spe...
Definition: qglobal.h:51
static PtrWacomConfigOpenDevice ptrWacomConfigOpenDevice
static bool appDoGrab
static int appDpiY(int screen=-1)
Returns the vertical resolution of the given screen in terms of the number of dots per inch...

◆ qt_installX11EventFilter()

Q_GUI_EXPORT void qt_installX11EventFilter ( QX11FilterFunction  func)

Definition at line 407 of file qapplication_x11.cpp.

Referenced by QMeeGoGraphicsSystemSwitchHandler::QMeeGoGraphicsSystemSwitchHandler().

408 {
409  Q_ASSERT(func);
410 
411  if (QList<QX11FilterFunction> *list = x11Filters())
412  list->append(func);
413 }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ qt_load_library_runtime()

static void* qt_load_library_runtime ( const char *  library,
int  vernum,
int  highestVernum,
const char *  symbol 
)
static

Try to resolve a symbol from library with the version specified by vernum.

Warning
This function is not part of the public interface.

Note that, in the case of the Xfixes library, vernum is not the same as XFIXES_MAJOR - it is a part of soname and may differ from the Xfixes version.

Definition at line 474 of file qapplication_x11.cpp.

476 {
477  QList<int> versions;
478  // we try to load in the following order:
479  // explicit version -> the default one -> (from the highest (highestVernum) to the lowest (vernum) )
480  if (vernum != -1)
481  versions << vernum;
482  versions << -1;
483  if (vernum != -1) {
484  for(int i = highestVernum; i > vernum; --i)
485  versions << i;
486  }
487  Q_FOREACH(int version, versions) {
488  QLatin1String libName(library);
489  QLibrary xfixesLib(libName, version);
490  xfixesLib.setLoadHints(QLibrary::ImprovedSearchHeuristics);
491  void *ptr = xfixesLib.resolve(symbol);
492  if (ptr)
493  return ptr;
494  }
495  return 0;
496 }
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
const T * ptr(const T &t)
#define Q_FOREACH(variable, container)
Same as foreach(variable, container).
Definition: qglobal.h:2435
The QLibrary class loads shared libraries at runtime.
Definition: qlibrary.h:62

◆ qt_mouseMotion_scanner()

static Bool qt_mouseMotion_scanner ( Display ,
XEvent event,
XPointer  arg 
)
static

Definition at line 4662 of file qapplication_x11.cpp.

Referenced by QETWidget::translateXinputEvent().

4663 {
4665  if (data->error)
4666  return false;
4667 
4668  if (event->type == MotionNotify)
4669  return true;
4670 
4671  data->error = event->type != data->tabletMotionType; // we stop compression when another event gets in between.
4672  return false;
4673 }
EventRef event
static const char * data(const QByteArray &arr)

◆ qt_net_remove_user_time()

void qt_net_remove_user_time ( QWidget tlw)

Definition at line 1508 of file qapplication_x11.cpp.

Referenced by QWidgetPrivate::isBackgroundInherited(), and qt_net_update_user_time().

1509 {
1510  Q_ASSERT(tlw);
1511  QTLWExtra *extra = tlw->d_func()->maybeTopData();
1512  if (extra && extra->userTimeWindow) {
1513  Q_ASSERT(tlw->internalWinId());
1514  XDeleteProperty(X11->display, tlw->internalWinId(), ATOM(_NET_WM_USER_TIME_WINDOW));
1515  XDestroyWindow(X11->display, extra->userTimeWindow);
1516  extra->userTimeWindow = 0;
1517  }
1518 }
WId userTimeWindow
Definition: qwidget_p.h:199
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define X11
Definition: qt_x11_p.h:724
#define ATOM(x)
Definition: qt_x11_p.h:723
WId internalWinId() const
Returns the window system identifier of the widget, or 0 if the widget is not created yet...
Definition: qwidget.h:244

◆ qt_net_update_user_time()

void qt_net_update_user_time ( QWidget tlw,
unsigned long  timestamp 
)

Definition at line 1520 of file qapplication_x11.cpp.

Referenced by qstring_to_xtp(), and QApplication::x11ProcessEvent().

1521 {
1522  Q_ASSERT(tlw);
1523  Q_ASSERT(tlw->isWindow());
1525  QTLWExtra *extra = tlw->d_func()->topData();
1526  WId wid = tlw->internalWinId();
1527  const bool isSupportedByWM = X11->isSupportedByWM(ATOM(_NET_WM_USER_TIME_WINDOW));
1528  if (extra->userTimeWindow || isSupportedByWM) {
1529  if (!extra->userTimeWindow) {
1530  extra->userTimeWindow = XCreateSimpleWindow(X11->display,
1531  tlw->internalWinId(),
1532  -1, -1, 1, 1, 0, 0, 0);
1533  wid = extra->userTimeWindow;
1534  XChangeProperty(X11->display, tlw->internalWinId(), ATOM(_NET_WM_USER_TIME_WINDOW),
1535  XA_WINDOW, 32, PropModeReplace,
1536  (unsigned char *)&wid, 1);
1537  XDeleteProperty(X11->display, tlw->internalWinId(), ATOM(_NET_WM_USER_TIME));
1538  } else if (!isSupportedByWM) {
1539  // WM no longer supports it, then we should remove the
1540  // _NET_WM_USER_TIME_WINDOW atom.
1542  } else {
1543  wid = extra->userTimeWindow;
1544  }
1545  }
1546  XChangeProperty(X11->display, wid, ATOM(_NET_WM_USER_TIME),
1547  XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &timestamp, 1);
1548 }
unsigned long WId
Definition: qwindowdefs.h:119
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define X11
Definition: qt_x11_p.h:724
#define ATOM(x)
Definition: qt_x11_p.h:723
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
WId internalWinId() const
Returns the window system identifier of the widget, or 0 if the widget is not created yet...
Definition: qwidget.h:244
void qt_net_remove_user_time(QWidget *tlw)

◆ qt_nograb()

bool qt_nograb ( )

Definition at line 2825 of file qapplication_x11.cpp.

Referenced by QWidget::grabKeyboard(), QWidget::grabMouse(), qstring_to_xtp(), qt_grab_cursor(), qt_tablet_cleanup(), QWidget::releaseKeyboard(), and QWidget::releaseMouse().

2826 {
2827 #if defined(QT_DEBUG)
2828  return appNoGrab;
2829 #else
2830  return false;
2831 #endif
2832 }
static bool appNoGrab

◆ qt_removeX11EventFilter()

Q_GUI_EXPORT void qt_removeX11EventFilter ( QX11FilterFunction  func)

Definition at line 415 of file qapplication_x11.cpp.

416 {
417  Q_ASSERT(func);
418 
419  if (QList<QX11FilterFunction> *list = x11Filters())
420  list->removeOne(func);
421 }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ qt_save_rootinfo()

void qt_save_rootinfo ( )
static

Definition at line 2762 of file qapplication_x11.cpp.

Referenced by qt_cleanup().

2763 {
2764  Atom type;
2765  int format;
2766  unsigned long length, after;
2767  uchar *data = 0;
2768 
2769  if (ATOM(_XSETROOT_ID)) { // kill old pixmap
2770  if (XGetWindowProperty(X11->display, QX11Info::appRootWindow(),
2771  ATOM(_XSETROOT_ID), 0, 1,
2772  True, AnyPropertyType, &type, &format,
2773  &length, &after, &data) == Success) {
2774  if (type == XA_PIXMAP && format == 32 && length == 1 &&
2775  after == 0 && data) {
2776  XKillClient(X11->display, *((Pixmap*)data));
2777  }
2778  Pixmap dummy = XCreatePixmap(X11->display, QX11Info::appRootWindow(),
2779  1, 1, 1);
2780  XChangeProperty(X11->display, QX11Info::appRootWindow(),
2781  ATOM(_XSETROOT_ID), XA_PIXMAP, 32,
2782  PropModeReplace, (uchar *)&dummy, 1);
2783  XSetCloseDownMode(X11->display, RetainPermanent);
2784  }
2785  }
2786  if (data)
2787  XFree((char *)data);
2788 }
int type
Definition: qmetatype.cpp:239
static Qt::HANDLE appRootWindow(int screen=-1)
Returns a handle for the applications root window on the given screen.
#define X11
Definition: qt_x11_p.h:724
#define ATOM(x)
Definition: qt_x11_p.h:723
unsigned char uchar
Definition: qglobal.h:994
static const char * data(const QByteArray &arr)

◆ qt_set_input_encoding()

static void qt_set_input_encoding ( )
static

Definition at line 1092 of file qapplication_x11.cpp.

Referenced by QApplication::x11ProcessEvent().

1093 {
1094  Atom type;
1095  int format;
1096  ulong nitems, after = 1;
1097  unsigned char *data = 0;
1098 
1099  int e = XGetWindowProperty(X11->display, QX11Info::appRootWindow(),
1100  ATOM(_QT_INPUT_ENCODING), 0, 1024,
1101  False, XA_STRING, &type, &format, &nitems,
1102  &after, &data);
1103  if (e != Success || !nitems || type == XNone) {
1104  // Always use the locale codec, since we have no examples of non-local
1105  // XIMs, and since we cannot get a sensible answer about the encoding
1106  // from the XIM.
1108 
1109  } else {
1110  if (!qstricmp((char *)data, "locale"))
1112  else
1113  qt_input_mapper = QTextCodec::codecForName((char *)data);
1114  // make sure we have an input codec
1115  if(!qt_input_mapper)
1116  qt_input_mapper = QTextCodec::codecForName("ISO 8859-1");
1117  }
1118  if (qt_input_mapper && qt_input_mapper->mibEnum() == 11) // 8859-8
1119  qt_input_mapper = QTextCodec::codecForName("ISO 8859-8-I");
1120  if(data)
1121  XFree((char *)data);
1122 }
static QTextCodec * codecForLocale()
Returns a pointer to the codec most suitable for this locale.
int type
Definition: qmetatype.cpp:239
static Qt::HANDLE appRootWindow(int screen=-1)
Returns a handle for the applications root window on the given screen.
#define X11
Definition: qt_x11_p.h:724
#define ATOM(x)
Definition: qt_x11_p.h:723
virtual int mibEnum() const =0
Subclasses of QTextCodec must reimplement this function.
static const char * data(const QByteArray &arr)
unsigned long ulong
Definition: qglobal.h:997
int qstricmp(const char *str1, const char *str2)
A safe stricmp() function.
Definition: qbytearray.cpp:279
QTextCodec * qt_input_mapper
static QTextCodec * codecForName(const QByteArray &name)
Searches all installed QTextCodec objects and returns the one which best matches name; the match is c...

◆ qt_set_x11_resources()

static void qt_set_x11_resources ( const char *  font = 0,
const char *  fg = 0,
const char *  bg = 0,
const char *  button = 0 
)
static

Definition at line 1126 of file qapplication_x11.cpp.

Referenced by QApplication::x11ProcessEvent().

1128 {
1129 
1130  QString resFont, resFG, resBG, resButton, resEF, sysFont, selectBackground, selectForeground;
1131 
1139 
1140  bool paletteAlreadySet = false;
1142  // first, read from settings
1144  // the call to QApplication::style() below creates the system
1145  // palette, which breaks the logic after the RESOURCE_MANAGER
1146  // loop... so I have to save this value to be able to use it later
1147  paletteAlreadySet = (QApplicationPrivate::sys_pal != 0);
1148 
1149  // second, parse the RESOURCE_MANAGER property
1150  int format;
1151  ulong nitems, after = 1;
1152  QString res;
1153  long offset = 0;
1154  Atom type = XNone;
1155 
1156  while (after > 0) {
1157  uchar *data = 0;
1158  if (XGetWindowProperty(X11->display, QX11Info::appRootWindow(0),
1160  offset, 8192, False, AnyPropertyType,
1161  &type, &format, &nitems, &after,
1162  &data) != Success) {
1163  res = QString();
1164  break;
1165  }
1166  if (type == XA_STRING)
1167  res += QString::fromLatin1((char*)data);
1168  else
1169  res += QString::fromLocal8Bit((char*)data);
1170  offset += 2048; // offset is in 32bit quantities... 8192/4 == 2048
1171  if (data)
1172  XFree((char *)data);
1173  }
1174 
1175  QString key, value;
1176  int l = 0, r;
1179  int apnl = apn.length();
1180  int apcl = apc.length();
1181  int resl = res.length();
1182 
1183  while (l < resl) {
1184  r = res.indexOf(QLatin1Char('\n'), l);
1185  if (r < 0)
1186  r = resl;
1187  while (res.at(l).isSpace())
1188  l++;
1189  bool mine = false;
1190  QChar sc = res.at(l + 1);
1191  if (res.at(l) == QLatin1Char('*') &&
1192  (sc == QLatin1Char('f') || sc == QLatin1Char('b') || sc == QLatin1Char('g') ||
1193  sc == QLatin1Char('F') || sc == QLatin1Char('B') || sc == QLatin1Char('G') ||
1194  sc == QLatin1Char('s') || sc == QLatin1Char('S')
1195  // capital T only, since we're looking for "Text.selectSomething"
1196  || sc == QLatin1Char('T'))) {
1197  // OPTIMIZED, since we only want "*[fbgsT].."
1198  QString item = res.mid(l, r - l).simplified();
1199  int i = item.indexOf(QLatin1Char(':'));
1200  key = item.left(i).trimmed().mid(1).toLower();
1201  value = item.right(item.length() - i - 1).trimmed();
1202  mine = true;
1203  } else if ((apnl && res.at(l) == apn.at(0)) || (appClass && apcl && res.at(l) == apc.at(0))) {
1204  if (res.mid(l,apnl) == apn && (res.at(l+apnl) == QLatin1Char('.')
1205  || res.at(l+apnl) == QLatin1Char('*'))) {
1206  QString item = res.mid(l, r - l).simplified();
1207  int i = item.indexOf(QLatin1Char(':'));
1208  key = item.left(i).trimmed().mid(apnl+1).toLower();
1209  value = item.right(item.length() - i - 1).trimmed();
1210  mine = true;
1211  } else if (res.mid(l,apcl) == apc && (res.at(l+apcl) == QLatin1Char('.')
1212  || res.at(l+apcl) == QLatin1Char('*'))) {
1213  QString item = res.mid(l, r - l).simplified();
1214  int i = item.indexOf(QLatin1Char(':'));
1215  key = item.left(i).trimmed().mid(apcl+1).toLower();
1216  value = item.right(item.length() - i - 1).trimmed();
1217  mine = true;
1218  }
1219  }
1220 
1221  if (mine) {
1222  if (!font && key == QLatin1String("systemfont"))
1223  sysFont = value.left(value.lastIndexOf(QLatin1Char(':')));
1224  if (!font && key == QLatin1String("font"))
1225  resFont = value;
1226  else if (!fg && !paletteAlreadySet) {
1227  if (key == QLatin1String("foreground"))
1228  resFG = value;
1229  else if (!bg && key == QLatin1String("background"))
1230  resBG = value;
1231  else if (!bg && !button && key == QLatin1String("button.background"))
1232  resButton = value;
1233  else if (key == QLatin1String("text.selectbackground")) {
1234  selectBackground = value;
1235  } else if (key == QLatin1String("text.selectforeground")) {
1236  selectForeground = value;
1237  }
1238  } else if (key == QLatin1String("guieffects"))
1239  resEF = value;
1240  // NOTE: if you add more, change the [fbg] stuff above
1241  }
1242 
1243  l = r + 1;
1244  }
1245  }
1246  if (!sysFont.isEmpty())
1247  resFont = sysFont;
1248  if (resFont.isEmpty())
1249  resFont = QString::fromLocal8Bit(font);
1250  if (resFG.isEmpty())
1251  resFG = QString::fromLocal8Bit(fg);
1252  if (resBG.isEmpty())
1253  resBG = QString::fromLocal8Bit(bg);
1254  if (resButton.isEmpty())
1255  resButton = QString::fromLocal8Bit(button);
1256  if (!resFont.isEmpty()
1257  && !X11->has_fontconfig
1259  // set application font
1260  QFont fnt;
1261  fnt.setRawName(resFont);
1262 
1263  // the font we get may actually be an alias for another font,
1264  // so we reset the application font to the real font info.
1265  if (! fnt.exactMatch()) {
1266  QFontInfo fontinfo(fnt);
1267  fnt.setFamily(fontinfo.family());
1268  fnt.setRawMode(fontinfo.rawMode());
1269 
1270  if (! fnt.rawMode()) {
1271  fnt.setItalic(fontinfo.italic());
1272  fnt.setWeight(fontinfo.weight());
1273  fnt.setUnderline(fontinfo.underline());
1274  fnt.setStrikeOut(fontinfo.strikeOut());
1275  fnt.setStyleHint(fontinfo.styleHint());
1276 
1277  if (fnt.pointSize() <= 0 && fnt.pixelSize() <= 0) {
1278  // size is all wrong... fix it
1279  qreal pointSize = fontinfo.pixelSize() * 72. / (float) QX11Info::appDpiY();
1280  if (pointSize <= 0)
1281  pointSize = 12;
1282  fnt.setPointSize(qRound(pointSize));
1283  }
1284  }
1285  }
1286 
1288  }
1289  // QGtkStyle sets it's own system palette
1291  bool kdeColors = (QApplication::desktopSettingsAware() && X11->desktopEnvironment == DE_KDE);
1292  if (!gtkStyle && (kdeColors || (button || !resBG.isEmpty() || !resFG.isEmpty()))) {// set app colors
1295 
1296  (void) QApplication::style(); // trigger creation of application style and system palettes
1297  QColor btn;
1298  QColor bg;
1299  QColor fg;
1300  QColor bfg;
1301  QColor wfg;
1302  if (!resBG.isEmpty())
1303  bg = QColor(resBG);
1304  if (!bg.isValid())
1306 
1307  if (!resFG.isEmpty())
1308  fg = QColor(resFG);
1309  if (!fg.isValid())
1311 
1312  if (!resButton.isEmpty())
1313  btn = QColor(resButton);
1314  else if (!resBG.isEmpty())
1315  btn = bg;
1316  if (!btn.isValid())
1318 
1319  int h,s,v;
1320  fg.getHsv(&h,&s,&v);
1321  QColor base = Qt::white;
1322  bool bright_mode = false;
1323  if (v >= 255 - 50) {
1324  base = btn.darker(150);
1325  bright_mode = true;
1326  }
1327 
1328  QPalette pal(fg, btn, btn.lighter(125), btn.darker(130), btn.darker(120), wfg.isValid() ? wfg : fg, Qt::white, base, bg);
1329  QColor disabled((fg.red() + btn.red()) / 2,
1330  (fg.green() + btn.green())/ 2,
1331  (fg.blue() + btn.blue()) / 2);
1332  pal.setColorGroup(QPalette::Disabled, disabled, btn, btn.lighter(125),
1333  btn.darker(130), btn.darker(150), disabled, Qt::white, Qt::white, bg);
1334 
1335  QColor highlight, highlightText;
1336  if (!selectBackground.isEmpty() && !selectForeground.isEmpty()) {
1337  highlight = QColor(selectBackground);
1338  highlightText = QColor(selectForeground);
1339  }
1340 
1341  if (highlight.isValid() && highlightText.isValid()) {
1342  pal.setColor(QPalette::Highlight, highlight);
1343  pal.setColor(QPalette::HighlightedText, highlightText);
1344 
1345  // calculate disabled colors by removing saturation
1346  highlight.setHsv(highlight.hue(), 0, highlight.value(), highlight.alpha());
1347  highlightText.setHsv(highlightText.hue(), 0, highlightText.value(), highlightText.alpha());
1348  pal.setColor(QPalette::Disabled, QPalette::Highlight, highlight);
1349  pal.setColor(QPalette::Disabled, QPalette::HighlightedText, highlightText);
1350  } else if (bright_mode) {
1351  pal.setColor(QPalette::HighlightedText, base);
1352  pal.setColor(QPalette::Highlight, Qt::white);
1353  pal.setColor(QPalette::Disabled, QPalette::HighlightedText, base);
1354  pal.setColor(QPalette::Disabled, QPalette::Highlight, Qt::white);
1355  } else {
1356  pal.setColor(QPalette::HighlightedText, Qt::white);
1357  pal.setColor(QPalette::Highlight, Qt::darkBlue);
1358  pal.setColor(QPalette::Disabled, QPalette::HighlightedText, Qt::white);
1360  }
1361 
1362  pal = qt_guiPlatformPlugin()->palette().resolve(pal);
1364  QColor::setAllowX11ColorNames(allowX11ColorNames);
1365  }
1366 
1367  if (!resEF.isEmpty()) {
1368  QStringList effects = resEF.split(QLatin1Char(' '));
1371  effects.contains(QLatin1String("animatemenu")));
1373  effects.contains(QLatin1String("fademenu")));
1375  effects.contains(QLatin1String("animatecombo")));
1377  effects.contains(QLatin1String("animatetooltip")));
1379  effects.contains(QLatin1String("fadetooltip")));
1381  effects.contains(QLatin1String("animatetoolbox")));
1382  }
1383 
1385 }
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
void setPointSize(int)
Sets the point size to pointSize.
Definition: qfont.cpp:1099
virtual QPalette palette()
static QString fromLocal8Bit(const char *, int size=-1)
Returns a QString initialized with the first size characters of the 8-bit string str.
Definition: qstring.cpp:4245
int type
Definition: qmetatype.cpp:239
double qreal
Definition: qglobal.h:1193
#define disabled
ushort hue
Returns the hue color component of this color.
Definition: qcolor.h:250
const QChar at(int i) const
Returns the character at the given index position in the string.
Definition: qstring.h:698
void setUnderline(bool)
If enable is true, sets underline on; otherwise sets underline off.
Definition: qfont.cpp:1331
int pixelSize() const
Returns the pixel size of the font if it was set with setPixelSize().
Definition: qfont.cpp:1178
static Qt::HANDLE appRootWindow(int screen=-1)
Returns a handle for the applications root window on the given screen.
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
static const char * appName
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
QGuiPlatformPlugin * qt_guiPlatformPlugin()
Return (an construct if necesseray) the Gui Platform plugin.
static QStyle * style()
Returns the application&#39;s style object.
void setRawMode(bool)
If enable is true, turns raw mode on; otherwise turns raw mode off.
Definition: qfont.cpp:1842
ushort red
Returns the red color component of this color.
Definition: qcolor.h:243
The QString class provides a Unicode character string.
Definition: qstring.h:83
void setItalic(bool b)
Sets the style() of the font to QFont::StyleItalic if enable is true; otherwise the style is set to Q...
Definition: qfont.h:360
#define X11
Definition: qt_x11_p.h:724
static const uint base
Definition: qurl.cpp:268
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
static QFont * sys_font
bool isSpace() const
Returns true if the character is a separator character (Separator_* categories); otherwise returns fa...
Definition: qchar.cpp:609
void getHsv(int *h, int *s, int *v, int *a=0) const
Sets the contents pointed to by h, s, v, and a, to the hue, saturation, value, and alpha-channel (tra...
Definition: qcolor.cpp:679
void setHsv(int h, int s, int v, int a=255)
Sets a HSV color value; h is the hue, s is the saturation, v is the value and a is the alpha componen...
Definition: qcolor.cpp:734
static const char * appClass
void setFamily(const QString &)
Sets the family name of the font.
Definition: qfont.cpp:924
#define ATOM(x)
Definition: qt_x11_p.h:723
QColor darker(int f=200) const
Returns a darker (or lighter) color, but does not change this object.
Definition: qcolor.h:301
unsigned char uchar
Definition: qglobal.h:994
static void setSystemFont(const QFont &font)
static bool allowX11ColorNames()
Returns true if setNamedColor() is allowed to look up colors in the X11 color database.
Definition: qcolor.cpp:2535
ushort value
Returns the value color component of this color.
Definition: qcolor.h:252
QString left(int n) const Q_REQUIRED_RESULT
Returns a substring that contains the n leftmost characters of the string.
Definition: qstring.cpp:3664
QString trimmed() const Q_REQUIRED_RESULT
Returns a string that has whitespace removed from the start and the end.
Definition: qstring.cpp:4506
static bool x11_apply_settings()
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
void setStrikeOut(bool)
If enable is true, sets strikeout on; otherwise sets strikeout off.
Definition: qfont.cpp:1378
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
static const char * data(const QByteArray &arr)
int indexOf(QChar c, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.cpp:2838
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
static QStyle * app_style
QBool contains(const QString &str, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the list contains the string str; otherwise returns false.
Definition: qstringlist.h:172
QString right(int n) const Q_REQUIRED_RESULT
Returns a substring that contains the n rightmost characters of the string.
Definition: qstring.cpp:3682
static QPalette * sys_pal
unsigned long ulong
Definition: qglobal.h:997
void setStyleHint(StyleHint, StyleStrategy=PreferDefault)
Sets the style hint and strategy to hint and strategy, respectively.
Definition: qfont.cpp:1554
static void setAllowX11ColorNames(bool enabled)
Allow setNamedColor() to look up colors in the X11 color database if enabled.
Definition: qcolor.cpp:2549
bool inherits(const char *classname) const
Returns true if this object is an instance of a class that inherits className or a QObject subclass t...
Definition: qobject.h:275
The QFontInfo class provides general information about fonts.
Definition: qfontinfo.h:54
static QIconLoader * instance()
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a string that contains n characters of this string, starting at the specified position index...
Definition: qstring.cpp:3706
ushort blue
Returns the blue color component of this color.
Definition: qcolor.h:245
QString trimmed(QString source)
Definition: generator.cpp:233
ushort alpha
Returns the alpha color component of this color.
Definition: qcolor.h:242
The QFont class specifies a font used for drawing text.
Definition: qfont.h:64
QString simplified() const Q_REQUIRED_RESULT
Returns a string that has whitespace removed from the start and the end, and that has each sequence o...
Definition: qstring.cpp:4415
int lastIndexOf(QChar c, int from=-1, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.cpp:3000
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
void updateSystemTheme()
static bool allowX11ColorNames
Definition: qcolor.cpp:55
int key
QString toLower() const Q_REQUIRED_RESULT
Returns a lowercase copy of the string.
Definition: qstring.cpp:5389
static bool desktopSettingsAware()
Returns true if Qt is set to use the system&#39;s standard colors, fonts, etc.
void setWeight(int)
Sets the weight the font to weight, which should be a value from the QFont::Weight enumeration...
Definition: qfont.cpp:1278
QFactoryLoader * l
static void setSystemPalette(const QPalette &pal)
int pointSize() const
Returns the point size of the font.
Definition: qfont.cpp:981
void setRawName(const QString &)
Sets a font by its system specific name.
Definition: qfont_mac.cpp:88
QStringList split(const QString &sep, SplitBehavior behavior=KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const Q_REQUIRED_RESULT
Splits the string into substrings wherever sep occurs, and returns the list of those strings...
Definition: qstring.cpp:6526
bool isValid() const
Returns true if the color is valid; otherwise returns false.
Definition: qcolor.h:295
bool rawMode() const
Returns true if raw mode is used for font name matching; otherwise returns false. ...
Definition: qfont.cpp:1974
QColor lighter(int f=150) const
Returns a lighter (or darker) color, but does not change this object.
Definition: qcolor.h:298
ushort green
Returns the green color component of this color.
Definition: qcolor.h:244
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
static float pointSize(const QFontDef &fd, int dpi)
Definition: qfont_win.cpp:90
bool exactMatch() const
Returns true if a window system font exactly matching the settings of this font is available...
Definition: qfont.cpp:1857
Q_DECL_CONSTEXPR int qRound(qreal d)
Definition: qglobal.h:1203
static void setEffectEnabled(Qt::UIEffect, bool enable=true)
Enables the UI effect effect if enable is true, otherwise the effect will not be used.
QPalette resolve(const QPalette &) const
Returns a new QPalette that has attributes copied from other.
Definition: qpalette.cpp:1101
The QPalette class contains color groups for each widget state.
Definition: qpalette.h:61
static int appDpiY(int screen=-1)
Returns the vertical resolution of the given screen in terms of the number of dots per inch...

◆ qt_sync_request_scanner()

static Bool qt_sync_request_scanner ( Display ,
XEvent event,
XPointer  arg 
)
static

Definition at line 796 of file qapplication_x11.cpp.

Referenced by QETWidget::translateConfigEvent().

797 {
799  reinterpret_cast<qt_sync_request_event_data*>(arg);
800  if (event->type == ClientMessage &&
801  event->xany.window == data->window &&
802  event->xclient.message_type == ATOM(WM_PROTOCOLS) &&
803  (Atom)event->xclient.data.l[0] == ATOM(_NET_WM_SYNC_REQUEST)) {
804  QWidget *w = QWidget::find(event->xany.window);
805  if (QTLWExtra *tlw = ((QETWidget*)w)->d_func()->maybeTopData()) {
806  const ulong timestamp = (const ulong) event->xclient.data.l[1];
807  if (timestamp > X11->time)
808  X11->time = timestamp;
809  if (timestamp == CurrentTime || timestamp > tlw->syncRequestTimestamp) {
810  tlw->syncRequestTimestamp = timestamp;
811  tlw->newCounterValueLo = event->xclient.data.l[2];
812  tlw->newCounterValueHi = event->xclient.data.l[3];
813  }
814  }
815  return true;
816  }
817  return false;
818 }
EventRef event
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define X11
Definition: qt_x11_p.h:724
#define ATOM(x)
Definition: qt_x11_p.h:723
static QWidget * find(WId)
Returns a pointer to the widget with window identifer/handle id.
Definition: qwidget.cpp:2517
static const char * data(const QByteArray &arr)
unsigned long ulong
Definition: qglobal.h:997
if(void) toggleToolbarShown

◆ qt_tablet_devices()

QTabletDeviceDataList* qt_tablet_devices ( )

Definition at line 395 of file qapplication_x11.cpp.

Referenced by getNetWmState(), qt_cleanup(), QETWidget::translateMouseEvent(), QETWidget::translateXinputEvent(), and QApplication::x11ProcessEvent().

396 {
397  return tablet_devices();
398 }

◆ qt_tabletMotion_scanner()

static Bool qt_tabletMotion_scanner ( Display ,
XEvent event,
XPointer  arg 
)
static

Definition at line 4675 of file qapplication_x11.cpp.

Referenced by QETWidget::translateXinputEvent().

4676 {
4678  if (data->error)
4679  return false;
4680  if (event->type == data->tabletMotionType) {
4681  const XDeviceMotionEvent *const motion = reinterpret_cast<const XDeviceMotionEvent*>(event);
4682  if (data->filterByWidget) {
4683  const QPoint curr(motion->x, motion->y);
4684  const QWidget *w = data->etWidget;
4685  const QWidget *const child = w->childAt(curr);
4686  if (child) {
4687  w = child;
4688  }
4689  if (w == data->widget)
4690  return true;
4691  } else {
4692  return true;
4693  }
4694  }
4695 
4696  data->error = event->type != MotionNotify; // we stop compression when another event gets in between.
4697  return false;
4698 }
EventRef event
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
QWidget * childAt(int x, int y) const
Returns the visible child widget at the position ({x}, {y}) in the widget&#39;s coordinate system...
Definition: qwidget.h:934
static const char * data(const QByteArray &arr)
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53

◆ qt_try_modal()

bool qt_try_modal ( QWidget widget,
XEvent event 
)

Definition at line 3995 of file qapplication_x11.cpp.

Referenced by QApplication::x11ProcessEvent().

3996 {
3997  if (qt_xdnd_dragging) {
3998  // allow mouse events while DnD is active
3999  switch (event->type) {
4000  case ButtonPress:
4001  case ButtonRelease:
4002  case MotionNotify:
4003  return true;
4004  default:
4005  break;
4006  }
4007  }
4008 
4009  // allow mouse release events to be sent to widgets that have been pressed
4010  if (event->type == ButtonRelease) {
4011  QWidget *alienWidget = widget->childAt(widget->mapFromGlobal(QPoint(event->xbutton.x_root,
4012  event->xbutton.y_root)));
4013  if (widget == qt_button_down || (alienWidget && alienWidget == qt_button_down))
4014  return true;
4015  }
4016 
4018  return true;
4019 
4020  // disallow mouse/key events
4021  switch (event->type) {
4022  case ButtonPress:
4023  case ButtonRelease:
4024  case MotionNotify:
4025  case XKeyPress:
4026  case XKeyRelease:
4027  case EnterNotify:
4028  case LeaveNotify:
4029  case ClientMessage:
4030  return false;
4031  default:
4032  break;
4033  }
4034 
4035  return true;
4036 }
EventRef event
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
bool qt_xdnd_dragging
Definition: qdnd_x11.cpp:237
QWidget * qt_button_down
QWidget * childAt(int x, int y) const
Returns the visible child widget at the position ({x}, {y}) in the widget&#39;s coordinate system...
Definition: qwidget.h:934
static bool tryModalHelper(QWidget *widget, QWidget **rettop=0)
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
QPoint mapFromGlobal(const QPoint &) const
Translates the global screen coordinate pos to widget coordinates.

◆ qt_updated_rootinfo()

void qt_updated_rootinfo ( )

Definition at line 2790 of file qapplication_x11.cpp.

2791 {
2792  app_save_rootinfo = true;
2793 }
static bool app_save_rootinfo

◆ qt_wstate_iconified()

bool qt_wstate_iconified ( WId  winid)

Definition at line 2796 of file qapplication_x11.cpp.

2797 {
2798  Atom type;
2799  int format;
2800  unsigned long length, after;
2801  uchar *data = 0;
2802  int r = XGetWindowProperty(X11->display, winid, ATOM(WM_STATE), 0, 2,
2803  False, AnyPropertyType, &type, &format,
2804  &length, &after, &data);
2805  bool iconic = false;
2806  if (r == Success && data && format == 32) {
2807  // quint32 *wstate = (quint32*)data;
2808  unsigned long *wstate = (unsigned long *) data;
2809  iconic = (*wstate == IconicState);
2810  XFree((char *)data);
2811  }
2812  return iconic;
2813 }
int type
Definition: qmetatype.cpp:239
#define X11
Definition: qt_x11_p.h:724
#define ATOM(x)
Definition: qt_x11_p.h:723
unsigned char uchar
Definition: qglobal.h:994
static const char * data(const QByteArray &arr)

◆ qt_x11_apply_settings_in_all_apps()

Q_GUI_EXPORT void qt_x11_apply_settings_in_all_apps ( )

Definition at line 853 of file qapplication_x11.cpp.

854 {
855  QByteArray stamp;
858 
859  XChangeProperty(QX11Info::display(), QX11Info::appRootWindow(0),
861  PropModeReplace, (unsigned char *)stamp.data(), stamp.size());
862 }
char * data()
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:429
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
static Qt::HANDLE appRootWindow(int screen=-1)
Returns a handle for the applications root window on the given screen.
#define ATOM(x)
Definition: qt_x11_p.h:723
static QDateTime currentDateTime()
Returns the current datetime, as reported by the system clock, in the local time zone.
Definition: qdatetime.cpp:3138
int size() const
Returns the number of bytes in this byte array.
Definition: qbytearray.h:402
The QDataStream class provides serialization of binary data to a QIODevice.
Definition: qdatastream.h:71
static Display * display()
Returns the default display for the application.

◆ qt_x11_create_intern_atoms()

static void qt_x11_create_intern_atoms ( )
static

Definition at line 825 of file qapplication_x11.cpp.

Referenced by qt_init().

826 {
827  const char *names[QX11Data::NAtoms];
828  const char *ptr = x11_atomnames;
829 
830  int i = 0;
831  while (*ptr) {
832  names[i++] = ptr;
833  while (*ptr)
834  ++ptr;
835  ++ptr;
836  }
837 
839 
840  QByteArray settings_atom_name("_QT_SETTINGS_TIMESTAMP_");
841  settings_atom_name += XDisplayName(X11->displayName);
842  names[i++] = settings_atom_name;
843 
845 #if defined(XlibSpecificationRelease) && (XlibSpecificationRelease >= 6)
846  XInternAtoms(X11->display, (char **)names, i, False, X11->atoms);
847 #else
848  for (i = 0; i < QX11Data::NAtoms; ++i)
849  X11->atoms[i] = XInternAtom(X11->display, (char *)names[i], False);
850 #endif
851 }
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define X11
Definition: qt_x11_p.h:724
const T * ptr(const T &t)
static const char * x11_atomnames

◆ qt_x11EventFilter()

static bool qt_x11EventFilter ( XEvent ev)
static

Definition at line 424 of file qapplication_x11.cpp.

Referenced by QETWidget::translateConfigEvent(), QETWidget::translateMouseEvent(), QETWidget::translatePaintEvent(), and QApplication::x11ProcessEvent().

425 {
426  long unused;
427  if (qApp->filterEvent(ev, &unused))
428  return true;
429  if (const QList<QX11FilterFunction> *list = x11Filters()) {
430  for (QList<QX11FilterFunction>::const_iterator it = list->constBegin(); it != list->constEnd(); ++it) {
431  if ((*it)(ev))
432  return true;
433  }
434  }
435 
436  return qApp->x11EventFilter(ev);
437 }
#define it(className, varName)
The QList::const_iterator class provides an STL-style const iterator for QList and QQueue...
Definition: qlist.h:228
#define qApp
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ qt_x_errhandler()

static int qt_x_errhandler ( Display dpy,
XErrorEvent *  err 
)
static

Definition at line 655 of file qapplication_x11.cpp.

Referenced by QGtkStylePrivate::getIconThemeName(), QGtkStylePrivate::initGtkWidgets(), and qt_init().

656 {
657  if (X11->display != dpy) {
658  // only handle X errors for our display
659  return 0;
660  }
661 
662  switch (err->error_code) {
663  case BadAtom:
664  if (err->request_code == 20 /* X_GetProperty */
665  && (err->resourceid == XA_RESOURCE_MANAGER
666  || err->resourceid == XA_RGB_DEFAULT_MAP
667  || err->resourceid == ATOM(_NET_SUPPORTED)
668  || err->resourceid == ATOM(_NET_SUPPORTING_WM_CHECK)
669  || err->resourceid == ATOM(XdndProxy)
670  || err->resourceid == ATOM(XdndAware))) {
671  // Perhaps we're running under SECURITY reduction? :/
672  return 0;
673  }
674  break;
675 
676  case BadWindow:
677  if (err->request_code == 2 /* X_ChangeWindowAttributes */
678  || err->request_code == 38 /* X_QueryPointer */) {
679  for (int i = 0; i < ScreenCount(dpy); ++i) {
680  if (err->resourceid == RootWindow(dpy, i)) {
681  // Perhaps we're running under SECURITY reduction? :/
682  return 0;
683  }
684  }
685  }
686  X11->seen_badwindow = true;
687  if (err->request_code == 25 /* X_SendEvent */) {
688  for (int i = 0; i < ScreenCount(dpy); ++i) {
689  if (err->resourceid == RootWindow(dpy, i)) {
690  // Perhaps we're running under SECURITY reduction? :/
691  return 0;
692  }
693  }
694  if (X11->xdndHandleBadwindow()) {
695  qDebug("xdndHandleBadwindow returned true");
696  return 0;
697  }
698  }
699  if (X11->ignore_badwindow)
700  return 0;
701  break;
702 
703  default:
704 #if !defined(QT_NO_XINPUT)
705  if (err->request_code == X11->xinput_major
706  && err->error_code == (X11->xinput_errorbase + XI_BadDevice)
707  && err->minor_code == 3 /* X_OpenDevice */) {
708  return 0;
709  }
710 #endif
711  break;
712  }
713 
714  char errstr[256];
715  XGetErrorText( dpy, err->error_code, errstr, 256 );
716  char buffer[256];
717  char request_str[256];
718  qsnprintf(buffer, 256, "%d", err->request_code);
719  XGetErrorDatabaseText(dpy, "XRequest", buffer, "", request_str, 256);
720  if (err->request_code < 128) {
721  // X error for a normal protocol request
722  qWarning( "X Error: %s %d\n"
723  " Major opcode: %d (%s)\n"
724  " Resource id: 0x%lx",
725  errstr, err->error_code,
726  err->request_code,
727  request_str,
728  err->resourceid );
729  } else {
730  // X error for an extension request
731  const char *extensionName = 0;
732  if (err->request_code == X11->xrender_major)
733  extensionName = "RENDER";
734  else if (err->request_code == X11->xrandr_major)
735  extensionName = "RANDR";
736  else if (err->request_code == X11->xinput_major)
737  extensionName = "XInputExtension";
738  else if (err->request_code == X11->mitshm_major)
739  extensionName = "MIT-SHM";
740 #ifndef QT_NO_XKB
741  else if(err->request_code == X11->xkb_major)
742  extensionName = "XKEYBOARD";
743 #endif
744 
745  char minor_str[256];
746  if (extensionName) {
747  qsnprintf(buffer, 256, "%s.%d", extensionName, err->minor_code);
748  XGetErrorDatabaseText(dpy, "XRequest", buffer, "", minor_str, 256);
749  } else {
750  extensionName = "Uknown extension";
751  qsnprintf(minor_str, 256, "Unknown request");
752  }
753  qWarning( "X Error: %s %d\n"
754  " Extension: %d (%s)\n"
755  " Minor opcode: %d (%s)\n"
756  " Resource id: 0x%lx",
757  errstr, err->error_code,
758  err->request_code,
759  extensionName,
760  err->minor_code,
761  minor_str,
762  err->resourceid );
763  }
764 
765  // ### we really should distinguish between severe, non-severe and
766  // ### application specific errors
767 
768  return 0;
769 }
#define X11
Definition: qt_x11_p.h:724
#define ATOM(x)
Definition: qt_x11_p.h:723
Q_CORE_EXPORT void qDebug(const char *,...)
Q_CORE_EXPORT void qWarning(const char *,...)
int qsnprintf(char *str, size_t n, const char *fmt,...)
A portable snprintf() function, calls qvsnprintf.
Definition: qvsnprintf.cpp:128

◆ qt_xfixes_clipboard_changed()

bool qt_xfixes_clipboard_changed ( Window  clipboardOwner,
Time  timestamp 
)

Definition at line 1538 of file qclipboard_x11.cpp.

Referenced by QApplication::x11ProcessEvent().

1539 {
1541 #ifdef QCLIPBOARD_DEBUG
1542  DEBUG("qt_xfixes_clipboard_changed: owner = %u; clipboardOwner = %u; internal timestamp = %u; external timestamp = %u",
1543  (unsigned int)(owner ? (int)owner->internalWinId() : 0), (unsigned int)clipboardOwner,
1544  (unsigned int)(d ? d->timestamp : 0), (unsigned int)timestamp);
1545 #endif
1546  if (!owner || (clipboardOwner && clipboardOwner != owner->internalWinId()) ||
1547  (!clipboardOwner && (d->timestamp == CurrentTime || d->timestamp < timestamp)))
1548  return qt_check_clipboard_sentinel();
1549  return false;
1550 }
double d
Definition: qnumeric_p.h:62
bool qt_check_clipboard_sentinel()
static QWidget * owner
static QClipboardData * clipboardData()
WId internalWinId() const
Returns the window system identifier of the widget, or 0 if the widget is not created yet...
Definition: qwidget.h:244
#define DEBUG

◆ qt_xfixes_scanner()

static Bool qt_xfixes_scanner ( Display ,
XEvent event,
XPointer  arg 
)
static

Definition at line 549 of file qapplication_x11.cpp.

Referenced by QApplication::x11ProcessEvent().

550 {
552  reinterpret_cast<qt_xfixes_selection_event_data*>(arg);
553  if (event->type == X11->xfixes_eventbase + XFixesSelectionNotify) {
554  XFixesSelectionNotifyEvent *xfixes_event = reinterpret_cast<XFixesSelectionNotifyEvent*>(event);
555  if (xfixes_event->selection == data->selection)
556  return true;
557  }
558  return false;
559 }
EventRef event
#define X11
Definition: qt_x11_p.h:724
static const char * data(const QByteArray &arr)

◆ qt_xfixes_selection_changed()

bool qt_xfixes_selection_changed ( Window  selectionOwner,
Time  timestamp 
)

Definition at line 1524 of file qclipboard_x11.cpp.

Referenced by QApplication::x11ProcessEvent().

1525 {
1527 #ifdef QCLIPBOARD_DEBUG
1528  DEBUG("qt_xfixes_selection_changed: owner = %u; selectionOwner = %u; internal timestamp = %u; external timestamp = %u",
1529  (unsigned int)(owner ? (int)owner->internalWinId() : 0), (unsigned int)selectionOwner,
1530  (unsigned int)(d ? d->timestamp : 0), (unsigned int)timestamp);
1531 #endif
1532  if (!owner || (selectionOwner && selectionOwner != owner->internalWinId()) ||
1533  (!selectionOwner && (d->timestamp == CurrentTime || d->timestamp < timestamp)))
1534  return qt_check_selection_sentinel();
1535  return false;
1536 }
double d
Definition: qnumeric_p.h:62
static QWidget * owner
static QClipboardData * selectionData()
WId internalWinId() const
Returns the window system identifier of the widget, or 0 if the widget is not created yet...
Definition: qwidget.h:244
#define DEBUG
bool qt_check_selection_sentinel()

◆ qt_xio_errhandler()

static int qt_xio_errhandler ( Display )
static

Definition at line 772 of file qapplication_x11.cpp.

Referenced by qt_init().

773 {
774  qWarning("%s: Fatal IO error: client killed", appName);
776  exit(1);
777  //### give the application a chance for a proper shutdown instead,
778  //### exit(1) doesn't help.
779  return 0;
780 }
static void reset_instance_pointer()
static const char * appName
Q_CORE_EXPORT void qWarning(const char *,...)

◆ resetSmState()

static void resetSmState ( )
static

Definition at line 5618 of file qapplication_x11.cpp.

Referenced by sm_dieCallback(), sm_saveCompleteCallback(), sm_saveYourselfCallback(), sm_shutdownCancelledCallback(), and QSmSocketReceiver::socketActivated().

5619 {
5620 // sm_waitingForPhase2 = false; ### never used?!?
5621  sm_waitingForInteraction = false;
5622  sm_interactionActive = false;
5623  sm_interactStyle = SmInteractStyleNone;
5624  sm_smActive = false;
5625  qt_sm_blockUserInput = false;
5626  sm_isshutdown = false;
5627 // sm_shouldbefast = false; ### never used?!?
5628  sm_phase2 = false;
5629  sm_in_phase2 = false;
5630 }
static bool sm_phase2
static bool sm_interactionActive
bool qt_sm_blockUserInput
static bool sm_isshutdown
static bool sm_smActive
static bool sm_waitingForInteraction
static int sm_interactStyle
static bool sm_in_phase2

◆ runningUnderDebugger()

bool runningUnderDebugger ( )

Definition at line 1641 of file qapplication_x11.cpp.

Referenced by qt_init().

1642 {
1643  const QString parentProc = QLatin1String("/proc/") + QString::number(getppid());
1644  const QFileInfo parentProcExe(parentProc + QLatin1String("/exe"));
1645  if (parentProcExe.isSymLink())
1646  return parentProcExe.symLinkTarget().endsWith(QLatin1String("/gdb"));
1647  QFile f(parentProc + QLatin1String("/cmdline"));
1648  if (!f.open(QIODevice::ReadOnly))
1649  return false;
1650  QByteArray s;
1651  char c;
1652  while (f.getChar(&c) && c) {
1653  if (c == '/')
1654  s.clear();
1655  else
1656  s += c;
1657  }
1658  return s == "gdb";
1659 }
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qstring.cpp:6448
unsigned char c[8]
Definition: qnumeric_p.h:62
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QFile class provides an interface for reading from and writing to files.
Definition: qfile.h:65
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:60
void clear()
Clears the contents of the byte array and makes it empty.

◆ sm_dieCallback()

static void sm_dieCallback ( SmcConn  smcConn,
SmPointer  clientData 
)
static

Definition at line 5811 of file qapplication_x11.cpp.

Referenced by QSmSocketReceiver::socketActivated().

5812 {
5813  if (smcConn != smcConnection)
5814  return;
5815  resetSmState();
5816  QEvent quitEvent(QEvent::Quit);
5817  QApplication::sendEvent(qApp, &quitEvent);
5818 }
static SmcConn smcConnection
#define qApp
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
static void resetSmState()
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56

◆ sm_interactCallback()

static void sm_interactCallback ( SmcConn  smcConn,
SmPointer  clientData 
)
static

Definition at line 5836 of file qapplication_x11.cpp.

Referenced by QSmSocketReceiver::socketActivated().

5837 {
5838  if (smcConn != smcConnection)
5839  return;
5841  ((QSessionManagerPrivate *) clientData)->eventLoop->exit();
5842 }
static SmcConn smcConnection
static bool sm_waitingForInteraction

◆ sm_performSaveYourself()

static void sm_performSaveYourself ( QSessionManagerPrivate smd)
static

Definition at line 5710 of file qapplication_x11.cpp.

Referenced by sm_saveYourselfCallback(), and sm_saveYourselfPhase2Callback().

5711 {
5712  if (sm_isshutdown)
5713  qt_sm_blockUserInput = true;
5714 
5715  QSessionManager* sm = smd->sm;
5716 
5717  // generate a new session key
5718  timeval tv;
5719  gettimeofday(&tv, 0);
5720  smd->sessionKey = QString::number(qulonglong(tv.tv_sec)) + QLatin1Char('_') + QString::number(qulonglong(tv.tv_usec));
5721 
5722  QStringList arguments = qApp->arguments();
5723  QString argument0 = arguments.isEmpty() ? qApp->applicationFilePath() : arguments.at(0);
5724 
5725  // tell the session manager about our program in best POSIX style
5726  sm_setProperty(QString::fromLatin1(SmProgram), argument0);
5727  // tell the session manager about our user as well.
5728  struct passwd *entryPtr = 0;
5729 #if defined(_POSIX_THREAD_SAFE_FUNCTIONS) && (_POSIX_THREAD_SAFE_FUNCTIONS - 0 > 0)
5730  QVarLengthArray<char, 1024> buf(qMax<long>(sysconf(_SC_GETPW_R_SIZE_MAX), 1024L));
5731  struct passwd entry;
5732  while (getpwuid_r(geteuid(), &entry, buf.data(), buf.size(), &entryPtr) == ERANGE) {
5733  if (buf.size() >= 32768) {
5734  // too big already, fail
5735  static char badusername[] = "";
5736  entryPtr = &entry;
5737  entry.pw_name = badusername;
5738  break;
5739  }
5740 
5741  // retry with a bigger buffer
5742  buf.resize(buf.size() * 2);
5743  }
5744 #else
5745  entryPtr = getpwuid(geteuid());
5746 #endif
5747  if (entryPtr)
5748  sm_setProperty(QString::fromLatin1(SmUserID), QString::fromLatin1(entryPtr->pw_name));
5749 
5750  // generate a restart and discard command that makes sense
5751  QStringList restart;
5752  restart << argument0 << QLatin1String("-session")
5753  << smd->sessionId + QLatin1Char('_') + smd->sessionKey;
5754  if (qstricmp(appName, QX11Info::appClass()) != 0)
5755  restart << QLatin1String("-name") << qAppName();
5756  sm->setRestartCommand(restart);
5757  QStringList discard;
5758  sm->setDiscardCommand(discard);
5759 
5760  switch (sm_saveType) {
5761  case SmSaveBoth:
5762  qApp->commitData(*sm);
5763  if (sm_isshutdown && sm_cancel)
5764  break; // we cancelled the shutdown, no need to save state
5765  // fall through
5766  case SmSaveLocal:
5767  qApp->saveState(*sm);
5768  break;
5769  case SmSaveGlobal:
5770  qApp->commitData(*sm);
5771  break;
5772  default:
5773  break;
5774  }
5775 
5776  if (sm_phase2 && !sm_in_phase2) {
5777  SmcRequestSaveYourselfPhase2(smcConnection, sm_saveYourselfPhase2Callback, (SmPointer*) smd);
5778  qt_sm_blockUserInput = false;
5779  }
5780  else {
5781  // close eventual interaction monitors and cancel the
5782  // shutdown, if required. Note that we can only cancel when
5783  // performing a shutdown, it does not work for checkpoints
5784  if (sm_interactionActive) {
5785  SmcInteractDone(smcConnection, sm_isshutdown && sm_cancel);
5786  sm_interactionActive = false;
5787  }
5788  else if (sm_cancel && sm_isshutdown) {
5789  if (sm->allowsErrorInteraction()) {
5790  SmcInteractDone(smcConnection, True);
5791  sm_interactionActive = false;
5792  }
5793  }
5794 
5795  // set restart and discard command in session manager
5796  sm_setProperty(QString::fromLatin1(SmRestartCommand), sm->restartCommand());
5797  sm_setProperty(QString::fromLatin1(SmDiscardCommand), sm->discardCommand());
5798 
5799  // set the restart hint
5800  SmPropValue prop;
5801  prop.length = sizeof(int);
5802  int value = sm->restartHint();
5803  prop.value = (SmPointer) &value;
5804  sm_setProperty(SmRestartStyleHint, SmCARD8, 1, &prop);
5805 
5806  // we are done
5807  SmcSaveYourselfDone(smcConnection, !sm_cancel);
5808  }
5809 }
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qstring.cpp:6448
static bool sm_cancel
bool allowsErrorInteraction()
Returns true if error interaction is permitted; otherwise returns false.
static int sm_saveType
static const char * appClass()
Returns the X11 application class.
static SmcConn smcConnection
static bool sm_phase2
static bool sm_interactionActive
static const char * appName
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
QStringList restartCommand() const
Returns the currently set restart command.
The QString class provides a Unicode character string.
Definition: qstring.h:83
void setDiscardCommand(const QStringList &)
Sets the discard command to the given list.
QString qAppName()
bool qt_sm_blockUserInput
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
static bool sm_isshutdown
void setRestartCommand(const QStringList &)
If the session manager is capable of restoring sessions it will execute command in order to restore t...
The QSessionManager class provides access to the session manager.
#define qApp
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
int qstricmp(const char *str1, const char *str2)
A safe stricmp() function.
Definition: qbytearray.cpp:279
QStringList discardCommand() const
Returns the currently set discard command.
static void sm_setProperty(const char *name, const char *type, int num_vals, SmPropValue *vals)
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
RestartHint restartHint() const
Returns the application&#39;s current restart hint.
quint64 qulonglong
Definition: qglobal.h:952
static void sm_saveYourselfPhase2Callback(SmcConn smcConn, SmPointer clientData)
static bool sm_in_phase2
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ sm_saveCompleteCallback()

static void sm_saveCompleteCallback ( SmcConn  smcConn,
SmPointer  clientData 
)
static

Definition at line 5829 of file qapplication_x11.cpp.

Referenced by QSmSocketReceiver::socketActivated().

5830 {
5831  if (smcConn != smcConnection)
5832  return;
5833  resetSmState();
5834 }
static SmcConn smcConnection
static void resetSmState()

◆ sm_saveYourselfCallback()

static void sm_saveYourselfCallback ( SmcConn  smcConn,
SmPointer  clientData,
int  saveType,
Bool  shutdown,
int  interactStyle,
Bool  fast 
)
static

Definition at line 5687 of file qapplication_x11.cpp.

Referenced by QSmSocketReceiver::socketActivated().

5689 {
5690  if (smcConn != smcConnection)
5691  return;
5692  sm_cancel = false;
5693  sm_smActive = true;
5694  sm_isshutdown = shutdown;
5695  sm_saveType = saveType;
5696  sm_interactStyle = interactStyle;
5697 // sm_shouldbefast = fast; ### never used?!?
5698 
5699  // ugly workaround for broken libSM. libSM should do that _before_
5700  // actually invoking the callback in sm_process.c
5701  ((QT_smcConn*)smcConn)->save_yourself_in_progress = true;
5702  if (sm_isshutdown)
5703  ((QT_smcConn*)smcConn)->shutdown_in_progress = true;
5704 
5706  if (!sm_isshutdown) // we cannot expect a confirmation message in that case
5707  resetSmState();
5708 }
static bool sm_cancel
static int sm_saveType
static SmcConn smcConnection
static void sm_performSaveYourself(QSessionManagerPrivate *)
static bool sm_isshutdown
static bool sm_smActive
static int sm_interactStyle
static void resetSmState()

◆ sm_saveYourselfPhase2Callback()

static void sm_saveYourselfPhase2Callback ( SmcConn  smcConn,
SmPointer  clientData 
)
static

Definition at line 5844 of file qapplication_x11.cpp.

Referenced by sm_performSaveYourself().

5845 {
5846  if (smcConn != smcConnection)
5847  return;
5848  sm_in_phase2 = true;
5850 }
static SmcConn smcConnection
static void sm_performSaveYourself(QSessionManagerPrivate *)
static bool sm_in_phase2

◆ sm_setProperty() [1/3]

static void sm_setProperty ( const char *  name,
const char *  type,
int  num_vals,
SmPropValue *  vals 
)
static

Definition at line 5635 of file qapplication_x11.cpp.

Referenced by sm_performSaveYourself(), and sm_setProperty().

5637 {
5638  if (num_vals) {
5639  SmProp prop;
5640  prop.name = (char*)name;
5641  prop.type = (char*)type;
5642  prop.num_vals = num_vals;
5643  prop.vals = vals;
5644 
5645  SmProp* props[1];
5646  props[0] = &prop;
5647  SmcSetProperties(smcConnection, 1, props);
5648  }
5649  else {
5650  char* names[1];
5651  names[0] = (char*) name;
5652  SmcDeleteProperties(smcConnection, 1, names);
5653  }
5654 }
int type
Definition: qmetatype.cpp:239
static SmcConn smcConnection
const char * name

◆ sm_setProperty() [2/3]

static void sm_setProperty ( const QString name,
const QString value 
)
static

Definition at line 5656 of file qapplication_x11.cpp.

5657 {
5658  QByteArray v = value.toUtf8();
5659  SmPropValue prop;
5660  prop.length = v.length();
5661  prop.value = (SmPointer) v.constData();
5662  sm_setProperty(name.toLatin1().data(), SmARRAY8, 1, &prop);
5663 }
char * data()
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:429
QByteArray toUtf8() const Q_REQUIRED_RESULT
Returns a UTF-8 representation of the string as a QByteArray.
Definition: qstring.cpp:4074
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
Definition: qstring.cpp:3993
int length() const
Same as size().
Definition: qbytearray.h:356
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
static void sm_setProperty(const char *name, const char *type, int num_vals, SmPropValue *vals)

◆ sm_setProperty() [3/3]

static void sm_setProperty ( const QString name,
const QStringList value 
)
static

Definition at line 5665 of file qapplication_x11.cpp.

5666 {
5667  SmPropValue *prop = new SmPropValue[value.count()];
5668  int count = 0;
5669  QList<QByteArray> vl;
5670  for (QStringList::ConstIterator it = value.begin(); it != value.end(); ++it) {
5671  prop[count].length = (*it).length();
5672  vl.append((*it).toUtf8());
5673  prop[count].value = (char*)vl.last().data();
5674  ++count;
5675  }
5676  sm_setProperty(name.toLatin1().data(), SmLISTofARRAY8, count, prop);
5677  delete [] prop;
5678 }
char * data()
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:429
#define it(className, varName)
iterator begin()
Returns an STL-style iterator pointing to the first item in the list.
Definition: qlist.h:267
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the list...
Definition: qlist.h:270
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
Definition: qstring.cpp:3993
static void sm_setProperty(const char *name, const char *type, int num_vals, SmPropValue *vals)
int length() const
This function is identical to count().
Definition: qlist.h:281
const_iterator ConstIterator
Qt-style synonym for QList::const_iterator.
Definition: qlist.h:279
T & last()
Returns a reference to the last item in the list.
Definition: qlist.h:284

◆ sm_shutdownCancelledCallback()

static void sm_shutdownCancelledCallback ( SmcConn  smcConn,
SmPointer  clientData 
)
static

Definition at line 5820 of file qapplication_x11.cpp.

Referenced by QSmSocketReceiver::socketActivated().

5821 {
5822  if (smcConn != smcConnection)
5823  return;
5825  ((QSessionManagerPrivate *) clientData)->eventLoop->exit();
5826  resetSmState();
5827 }
static SmcConn smcConnection
static bool sm_waitingForInteraction
static void resetSmState()

◆ translateBySips()

static bool translateBySips ( QWidget that,
QRect paintRect 
)
static

Definition at line 5185 of file qapplication_x11.cpp.

Referenced by QETWidget::translatePaintEvent().

5186 {
5187  int dx=0, dy=0;
5188  int sips=0;
5189  for (int i = 0; i < X11->sip_list.size(); ++i) {
5190  const QX11Data::ScrollInProgress &sip = X11->sip_list.at(i);
5191  if (sip.scrolled_widget == that) {
5192  if (sips) {
5193  dx += sip.dx;
5194  dy += sip.dy;
5195  }
5196  sips++;
5197  }
5198  }
5199  if (sips > 1) {
5200  paintRect.translate(dx, dy);
5201  return true;
5202  }
5203  return false;
5204 }
#define X11
Definition: qt_x11_p.h:724
void translate(int dx, int dy)
Moves the rectangle dx along the x axis and dy along the y axis, relative to the current position...
Definition: qrect.h:312

◆ translateMouseButtons()

static Qt::MouseButtons translateMouseButtons ( int  s)
static

Definition at line 4186 of file qapplication_x11.cpp.

Referenced by QETWidget::translateMouseEvent().

4187 {
4188  Qt::MouseButtons ret = 0;
4189  if (s & Button1Mask)
4190  ret |= Qt::LeftButton;
4191  if (s & Button2Mask)
4192  ret |= Qt::MidButton;
4193  if (s & Button3Mask)
4194  ret |= Qt::RightButton;
4195  return ret;
4196 }

Variable Documentation

◆ app_do_modal

bool app_do_modal = false
static

◆ app_save_rootinfo

bool app_save_rootinfo = false
static

Definition at line 351 of file qapplication_x11.cpp.

Referenced by qt_cleanup(), and qt_updated_rootinfo().

◆ appBGCol

const char* appBGCol = 0
static

Definition at line 340 of file qapplication_x11.cpp.

Referenced by qt_init().

◆ appBTNCol

const char* appBTNCol = 0
static

Definition at line 342 of file qapplication_x11.cpp.

Referenced by qt_init().

◆ appClass

const char* appClass = 0
static

◆ appDoGrab

bool appDoGrab = false
static

Definition at line 349 of file qapplication_x11.cpp.

Referenced by qt_init().

◆ appFGCol

const char* appFGCol = 0
static

Definition at line 341 of file qapplication_x11.cpp.

Referenced by qt_init().

◆ appFont

const char* appFont = 0
static

Definition at line 339 of file qapplication_x11.cpp.

Referenced by qt_init(), and QApplicationPrivate::x11_apply_settings().

◆ appName

const char* appName = 0
static

◆ appNoGrab

bool appNoGrab = false
static

Definition at line 348 of file qapplication_x11.cpp.

Referenced by qt_init(), and qt_nograb().

◆ appSync

bool appSync = false
static

Definition at line 346 of file qapplication_x11.cpp.

Referenced by qt_init().

◆ curWin

Window curWin = 0
static

◆ mouseActWindow

Window mouseActWindow = 0
static

Definition at line 373 of file qapplication_x11.cpp.

Referenced by QETWidget::translateMouseEvent().

◆ mouseButtonPressed

Qt::MouseButton mouseButtonPressed = Qt::NoButton
static

Definition at line 374 of file qapplication_x11.cpp.

Referenced by QETWidget::translateMouseEvent().

◆ mouseButtonPressTime

Time mouseButtonPressTime = 0
static

Definition at line 376 of file qapplication_x11.cpp.

Referenced by QETWidget::translateMouseEvent().

◆ mouseButtonState

Qt::MouseButtons mouseButtonState = Qt::NoButton
static

◆ mouseGlobalXPos

short mouseGlobalXPos
static

Definition at line 378 of file qapplication_x11.cpp.

Referenced by QETWidget::translateMouseEvent().

◆ mouseGlobalYPos

short mouseGlobalYPos
static

Definition at line 378 of file qapplication_x11.cpp.

Referenced by QETWidget::translateMouseEvent().

◆ mouseXPos

short mouseXPos
static

Definition at line 377 of file qapplication_x11.cpp.

Referenced by QETWidget::translateMouseEvent().

◆ mouseYPos

short mouseYPos
static

Definition at line 377 of file qapplication_x11.cpp.

Referenced by QETWidget::translateMouseEvent().

◆ mwGeometry

const char* mwGeometry = 0
static

◆ mwTitle

const char* mwTitle = 0
static

◆ openPopupCount

int openPopupCount = 0
static

Definition at line 4054 of file qapplication_x11.cpp.

Referenced by QETWidget::translateMouseEvent().

◆ original_x_errhandler

int(* original_x_errhandler) (Display *dpy, XErrorEvent *)
static

Definition at line 652 of file qapplication_x11.cpp.

Referenced by qt_cleanup(), and qt_init().

◆ original_xio_errhandler

int(* original_xio_errhandler) (Display *dpy)
static

Definition at line 653 of file qapplication_x11.cpp.

Referenced by qt_cleanup(), and qt_init().

◆ popupGrabOk

bool popupGrabOk
static

Definition at line 387 of file qapplication_x11.cpp.

◆ pressed_window

Window pressed_window = XNone
static

Definition at line 383 of file qapplication_x11.cpp.

Referenced by QApplication::x11ProcessEvent().

◆ ptrWacomConfigCloseDevice

PtrWacomConfigCloseDevice ptrWacomConfigCloseDevice = 0
static

Definition at line 1577 of file qapplication_x11.cpp.

Referenced by fetchWacomToolId().

◆ ptrWacomConfigGetRawParam

PtrWacomConfigGetRawParam ptrWacomConfigGetRawParam = 0
static

Definition at line 1576 of file qapplication_x11.cpp.

Referenced by fetchWacomToolId().

◆ ptrWacomConfigInit

PtrWacomConfigInit ptrWacomConfigInit = 0
static

Definition at line 1574 of file qapplication_x11.cpp.

Referenced by fetchWacomToolId().

◆ ptrWacomConfigOpenDevice

PtrWacomConfigOpenDevice ptrWacomConfigOpenDevice = 0
static

Definition at line 1575 of file qapplication_x11.cpp.

Referenced by fetchWacomToolId().

◆ ptrWacomConfigTerm

PtrWacomConfigTerm ptrWacomConfigTerm = 0
static

Definition at line 1578 of file qapplication_x11.cpp.

Referenced by fetchWacomToolId().

◆ qt_alt_mask

uchar qt_alt_mask = 0

◆ qt_button_down

QWidget* qt_button_down = 0

◆ qt_hyper_mask

uchar qt_hyper_mask = 0

Definition at line 367 of file qapplication_x11.cpp.

Referenced by q_getKeyboardLocale(), and translateKeySym().

◆ qt_input_mapper

QTextCodec* qt_input_mapper = 0

Definition at line 443 of file qapplication_x11.cpp.

Referenced by translateKeySym().

◆ qt_is_gui_used

bool qt_is_gui_used

Definition at line 492 of file qapplication.cpp.

Referenced by qt_cleanup(), and qt_init().

◆ qt_last_mouse_receiver

QPointer<QWidget> qt_last_mouse_receiver = 0

◆ qt_meta_mask

uchar qt_meta_mask = 0

◆ qt_modal_stack

QWidgetList* qt_modal_stack

Definition at line 564 of file qapplication.cpp.

Referenced by QApplication::x11EventFilter().

◆ qt_mode_switch_mask

uchar qt_mode_switch_mask = 0

Definition at line 368 of file qapplication_x11.cpp.

Referenced by q_getKeyboardLocale(), and QX11Data::translateModifiers().

◆ qt_popup_down

QWidget* qt_popup_down = 0
static

Definition at line 455 of file qapplication_x11.cpp.

◆ qt_sm_blockUserInput

bool qt_sm_blockUserInput = false

◆ qt_super_mask

uchar qt_super_mask = 0

Definition at line 366 of file qapplication_x11.cpp.

Referenced by q_getKeyboardLocale(), and translateKeySym().

◆ qt_tabletChokeMouse

bool qt_tabletChokeMouse

◆ qt_use_rtl_extensions

bool qt_use_rtl_extensions = false

◆ qt_x11Data

QX11Data * qt_x11Data = 0

Definition at line 332 of file qapplication_x11.cpp.

Referenced by QX11Data::badwindow(), QX11Data::ignoreBadwindow(), and x11Time().

◆ qt_xdnd_dragging

bool qt_xdnd_dragging

◆ qt_xfocusout_grab_counter

Q_GUI_EXPORT int qt_xfocusout_grab_counter = 0

Definition at line 391 of file qapplication_x11.cpp.

Referenced by QApplication::x11ProcessEvent().

◆ qt_ximComposingKeycode

int qt_ximComposingKeycode =0

Definition at line 442 of file qapplication_x11.cpp.

Referenced by translateKeySym(), and QXIMInputContext::x11FilterEvent().

◆ qt_ximServer

char* qt_ximServer = 0

Definition at line 345 of file qapplication_x11.cpp.

Referenced by qt_init(), and QXIMInputContext::QXIMInputContext().

◆ replayPopupMouseEvent

bool replayPopupMouseEvent = false
static

Definition at line 386 of file qapplication_x11.cpp.

Referenced by QETWidget::translateMouseEvent().

◆ sm_cancel

bool sm_cancel
static

Definition at line 5596 of file qapplication_x11.cpp.

◆ sm_in_phase2

bool sm_in_phase2
static

Definition at line 5602 of file qapplication_x11.cpp.

◆ sm_interactionActive

bool sm_interactionActive
static

Definition at line 5592 of file qapplication_x11.cpp.

◆ sm_interactStyle

int sm_interactStyle
static

Definition at line 5594 of file qapplication_x11.cpp.

◆ sm_isshutdown

bool sm_isshutdown
static

Definition at line 5599 of file qapplication_x11.cpp.

◆ sm_phase2

bool sm_phase2
static

Definition at line 5601 of file qapplication_x11.cpp.

◆ sm_receiver

QSmSocketReceiver* sm_receiver = 0
static

Definition at line 5604 of file qapplication_x11.cpp.

Referenced by QSmSocketReceiver::socketActivated().

◆ sm_saveType

int sm_saveType
static

Definition at line 5595 of file qapplication_x11.cpp.

◆ sm_smActive

bool sm_smActive
static

Definition at line 5593 of file qapplication_x11.cpp.

◆ sm_waitingForInteraction

bool sm_waitingForInteraction
static

Definition at line 5598 of file qapplication_x11.cpp.

◆ smcConnection

SmcConn smcConnection = 0
static

Definition at line 5591 of file qapplication_x11.cpp.

Referenced by QSmSocketReceiver::socketActivated().

◆ wPRmapper

QWidgetMapper* wPRmapper = 0
static

Definition at line 3111 of file qapplication_x11.cpp.

Referenced by qPRCleanup().

◆ x11_atomnames

const char* x11_atomnames
static

Definition at line 173 of file qapplication_x11.cpp.

Referenced by qt_x11_create_intern_atoms().