Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QX11Info Class Reference

\inmodule QtGui More...

#include <qtx11extras_p.h>

+ Collaboration diagram for QX11Info:

Public Types

enum  PeekOption { PeekDefault = 0 , PeekFromCachedIndex = 1 }
 An enum to tune the behavior of QX11Info::peekEventQueue(). More...
 
typedef bool(* PeekerCallback) (xcb_generic_event_t *event, void *peekerData)
 Typedef for a pointer to a function with the following signature:
 

Static Public Member Functions

static bool isPlatformX11 ()
 Returns true if the application is currently running on X11.
 
static int appDpiX (int screen=-1)
 Returns the horizontal resolution of the given screen in terms of the number of dots per inch.
 
static int appDpiY (int screen=-1)
 Returns the vertical resolution of the given screen in terms of the number of dots per inch.
 
static quint32 appRootWindow (int screen=-1)
 Returns a handle for the applications root window on the given screen.
 
static int appScreen ()
 Returns the number of the screen where the application is being displayed.
 
static quint32 appTime ()
 Returns the X11 time.
 
static quint32 appUserTime ()
 Returns the X11 user time.
 
static void setAppTime (quint32 time)
 Sets the X11 time to the value specified by time.
 
static void setAppUserTime (quint32 time)
 Sets the X11 user time as specified by time.
 
static quint32 getTimestamp ()
 Fetches the current X11 time stamp from the X Server.
 
static QByteArray nextStartupId ()
 Returns the startup ID that will be used for the next window to be shown by this process.
 
static void setNextStartupId (const QByteArray &id)
 Sets the next startup ID to id.
 
static Displaydisplay ()
 Returns the default display for the application.
 
static xcb_connection_t * connection ()
 Returns the default XCB connection for the application.
 
static bool isCompositingManagerRunning (int screen=-1)
 Returns true if there is a compositing manager running for the connection attached to screen.
 
static qint32 generatePeekerId ()
 Returns a new peeker id or -1 if some internal error has occurred.
 
static bool removePeekerId (qint32 peekerId)
 Removes peekerId, which was earlier obtained via generatePeekerId().
 
static bool peekEventQueue (PeekerCallback peeker, void *peekerData=nullptr, PeekOptions option=PeekDefault, qint32 peekerId=-1)
 Peek into the buffered XCB event queue.
 

Detailed Description

\inmodule QtGui

Since
6.2

Provides information about the X display configuration.

The class provides two APIs: a set of non-static functions that provide information about a specific widget or pixmap, and a set of static functions that provide the default information for the application.

Warning
This class is only available on X11. For querying per-screen information in a portable way, use QScreen.

Definition at line 27 of file qtx11extras_p.h.

Member Typedef Documentation

◆ PeekerCallback

QX11Info::PeekerCallback

Typedef for a pointer to a function with the following signature:

bool (*PeekerCallback)(xcb_generic_event_t *event, void *peekerData);
bool(* PeekerCallback)(xcb_generic_event_t *event, void *peekerData)
Typedef for a pointer to a function with the following signature:
struct _cl_event * event

The event is a native XCB event. The peekerData is a pointer to data, passed in via peekEventQueue().

Return true from this function to stop examining the buffered native event queue or false to continue.

Note
A non-capturing lambda can serve as a PeekerCallback.

Definition at line 62 of file qtx11extras_p.h.

Member Enumeration Documentation

◆ PeekOption

An enum to tune the behavior of QX11Info::peekEventQueue().

\value PeekDefault Peek from the beginning of the buffered native event queue. A peeker id is optional with PeekDefault. If a peeker id is provided to peekEventQueue() when using PeekDefault, then peeking starts from the beginning of the queue, not from the cached index; thus, this can be used to manually reset a cached index to peek from the start of the queue. When this operation completes, the associated index will be updated to the new position in the queue.

\value PeekFromCachedIndex QX11Info::peekEventQueue() can optimize the peeking algorithm by skipping events that it already has seen in earlier calls to peekEventQueue(). When control returns to the main event loop, which causes the buffered native event queue to be flushed to Qt's event queue, the cached indices are marked invalid and will be reset on the next access. The same is true if the program explicitly flushes the buffered native event queue by QCoreApplication::processEvents().

Enumerator
PeekDefault 
PeekFromCachedIndex 

Definition at line 30 of file qtx11extras_p.h.

Member Function Documentation

◆ appDpiX()

int QX11Info::appDpiX ( int screen = -1)
static

Returns the horizontal resolution of the given screen in terms of the number of dots per inch.

The screen argument is an X screen number. Be aware that if the user's system uses Xinerama (as opposed to traditional X11 multiscreen), there is only one X screen. Use QScreen to query for information about Xinerama screens.

See also
appDpiY()

Definition at line 78 of file qtx11extras.cpp.

References findScreenForVirtualDesktop(), QScreen::logicalDotsPerInchX, QGuiApplication::primaryScreen, qRound(), and screen.

+ Here is the call graph for this function:

◆ appDpiY()

int QX11Info::appDpiY ( int screen = -1)
static

Returns the vertical resolution of the given screen in terms of the number of dots per inch.

The screen argument is an X screen number. Be aware that if the user's system uses Xinerama (as opposed to traditional X11 multiscreen), there is only one X screen. Use QScreen to query for information about Xinerama screens.

See also
appDpiX()

Definition at line 105 of file qtx11extras.cpp.

References findScreenForVirtualDesktop(), QScreen::logicalDotsPerInchY, QGuiApplication::primaryScreen, qRound(), and screen.

+ Here is the call graph for this function:

◆ appRootWindow()

quint32 QX11Info::appRootWindow ( int screen = -1)
static

Returns a handle for the applications root window on the given screen.

The screen argument is an X screen number. Be aware that if the user's system uses Xinerama (as opposed to traditional X11 multiscreen), there is only one X screen. Use QScreen to query for information about Xinerama screens.

Definition at line 129 of file qtx11extras.cpp.

References findScreenForVirtualDesktop(), QPlatformNativeInterface::nativeResourceForScreen(), QGuiApplication::primaryScreen, qApp, QByteArrayLiteral, and screen.

+ Here is the call graph for this function:

◆ appScreen()

int QX11Info::appScreen ( )
static

Returns the number of the screen where the application is being displayed.

This method refers to screens in the original X11 meaning with a different DISPLAY environment variable per screen. This information is only useful if your application needs to know on which X screen it is running.

In a typical multi-head configuration, multiple physical monitors are combined in one X11 screen. This means this method returns the same number for each of the physical monitors. In such a setup you are interested in the monitor information as provided by the X11 RandR extension. This is available through QScreen.

See also
display()

Definition at line 159 of file qtx11extras.cpp.

References QPlatformNativeInterface::nativeResourceForIntegration(), qApp, and QByteArrayLiteral.

+ Here is the call graph for this function:

◆ appTime()

quint32 QX11Info::appTime ( )
static

Returns the X11 time.

See also
setAppTime(), appUserTime()

Definition at line 174 of file qtx11extras.cpp.

References QPlatformNativeInterface::nativeResourceForScreen(), QGuiApplication::primaryScreen, qApp, and screen.

+ Here is the call graph for this function:

◆ appUserTime()

quint32 QX11Info::appUserTime ( )
static

Returns the X11 user time.

See also
setAppUserTime(), appTime()

Definition at line 190 of file qtx11extras.cpp.

References QPlatformNativeInterface::nativeResourceForScreen(), QGuiApplication::primaryScreen, qApp, and screen.

+ Here is the call graph for this function:

◆ connection()

xcb_connection_t * QX11Info::connection ( )
static

Returns the default XCB connection for the application.

See also
display()

Definition at line 327 of file qtx11extras.cpp.

References connection(), QPlatformNativeInterface::nativeResourceForIntegration(), qApp, and QByteArray().

Referenced by connection().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ display()

Display * QX11Info::display ( )
static

Returns the default display for the application.

See also
appScreen()

Definition at line 310 of file qtx11extras.cpp.

References display(), QPlatformNativeInterface::nativeResourceForIntegration(), qApp, and QByteArray().

Referenced by display().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ generatePeekerId()

qint32 QX11Info::generatePeekerId ( )
static

Returns a new peeker id or -1 if some internal error has occurred.

Each peeker id is associated with an index in the buffered native event queue.

For more details see QX11Info::PeekOption and peekEventQueue().

See also
peekEventQueue(), removePeekerId()

Definition at line 371 of file qtx11extras.cpp.

References QPlatformNativeInterface::nativeResourceFunctionForIntegration(), qApp, qWarning, and void.

+ Here is the call graph for this function:

◆ getTimestamp()

quint32 QX11Info::getTimestamp ( )
static

Fetches the current X11 time stamp from the X Server.

This method creates a property notify event and blocks till it is received back from the X Server.

Definition at line 249 of file qtx11extras.cpp.

References QPlatformNativeInterface::nativeResourceForScreen(), QGuiApplication::primaryScreen, qApp, and screen.

+ Here is the call graph for this function:

◆ isCompositingManagerRunning()

bool QX11Info::isCompositingManagerRunning ( int screen = -1)
static

Returns true if there is a compositing manager running for the connection attached to screen.

If screen equals -1, the application's primary screen is used.

Definition at line 345 of file qtx11extras.cpp.

References findScreenForVirtualDesktop(), QPlatformNativeInterface::nativeResourceForScreen(), QGuiApplication::primaryScreen, qApp, QByteArray(), qWarning, and screen.

+ Here is the call graph for this function:

◆ isPlatformX11()

bool QX11Info::isPlatformX11 ( )
static

Returns true if the application is currently running on X11.

Since
6.2

Definition at line 62 of file qtx11extras.cpp.

References QGuiApplication::platformName.

◆ nextStartupId()

QByteArray QX11Info::nextStartupId ( )
static

Returns the startup ID that will be used for the next window to be shown by this process.

After the next window is shown, the next startup ID will be empty.

http://standards.freedesktop.org/startup-notification-spec/startup-notification-latest.txt

See also
setNextStartupId()

Definition at line 269 of file qtx11extras.cpp.

References QPlatformNativeInterface::nativeResourceForIntegration(), qApp, and QByteArray().

+ Here is the call graph for this function:

◆ peekEventQueue()

bool QX11Info::peekEventQueue ( PeekerCallback peeker,
void * peekerData = nullptr,
PeekOptions option = PeekDefault,
qint32 peekerId = -1 )
static

Peek into the buffered XCB event queue.

You can call peekEventQueue() periodically, when your program is busy performing a long-running operation, to peek into the buffered native event queue. The more time the long-running operation blocks the program from returning control to the main event loop, the more events will accumulate in the buffered XCB event queue. Once control returns to the main event loop these events will be flushed to Qt's event queue, which is a separate event queue from the queue this function is peeking into.

Note
It is usually better to run CPU-intensive operations in a non-GUI thread, instead of blocking the main event loop.

The buffered XCB event queue is populated from a non-GUI thread and therefore might be ahead of the current GUI state. To handle native events as they are processed by the GUI thread, see QAbstractNativeEventFilter::nativeEventFilter().

The peeker is a callback function as documented in PeekerCallback. The peekerData can be used to pass in arbitrary data to the peeker callback. The option is an enum that tunes the behavior of peekEventQueue(). The peekerId is used to track an index in the queue, for more details see QX11Info::PeekOption. There can be several indices, each tracked individually by a peeker id obtained via generatePeekerId().

This function returns true when the peeker has stopped the event proccesing by returning true from the callback. If there were no events in the buffered native event queue to peek at or all the events have been processed by the peeker, this function returns false.

See also
generatePeekerId(), QAbstractNativeEventFilter::nativeEventFilter()

Definition at line 494 of file qtx11extras.cpp.

References QPlatformNativeInterface::nativeResourceFunctionForIntegration(), qApp, and qWarning.

+ Here is the call graph for this function:

◆ removePeekerId()

bool QX11Info::removePeekerId ( qint32 peekerId)
static

Removes peekerId, which was earlier obtained via generatePeekerId().

Returns true on success or false if unknown peeker id was provided or some internal error has occurred.

See also
generatePeekerId()

Definition at line 398 of file qtx11extras.cpp.

References QPlatformNativeInterface::nativeResourceFunctionForIntegration(), qApp, qWarning, and removePeekerId().

Referenced by removePeekerId().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setAppTime()

void QX11Info::setAppTime ( quint32 time)
static

Sets the X11 time to the value specified by time.

See also
appTime(), setAppUserTime()

Definition at line 206 of file qtx11extras.cpp.

References QPlatformNativeInterface::nativeResourceFunctionForScreen(), QGuiApplication::primaryScreen, qApp, qWarning, screen, time, and void.

+ Here is the call graph for this function:

◆ setAppUserTime()

void QX11Info::setAppUserTime ( quint32 time)
static

Sets the X11 user time as specified by time.

See also
appUserTime(), setAppTime()

Definition at line 227 of file qtx11extras.cpp.

References QPlatformNativeInterface::nativeResourceFunctionForScreen(), QGuiApplication::primaryScreen, qApp, qWarning, screen, time, and void.

+ Here is the call graph for this function:

◆ setNextStartupId()

void QX11Info::setNextStartupId ( const QByteArray & id)
static

Sets the next startup ID to id.

This is the startup ID that will be used for the next window to be shown by this process.

The startup ID of the first window comes from the environment variable DESKTOP_STARTUP_ID. This method is useful for subsequent windows, when the request comes from another process (e.g. via DBus).

See also
nextStartupId()

Definition at line 290 of file qtx11extras.cpp.

References QPlatformNativeInterface::nativeResourceFunctionForIntegration(), qApp, qWarning, and void.

+ Here is the call graph for this function:

The documentation for this class was generated from the following files: