提供 X 显示配置的有关信息。 更多...
头: | #include <QX11Info> |
qmake: | QT += x11extras |
Since: | Qt 5.1 |
该类已过时。 提供它是为使旧源代码能继续工作。强烈建议不要在新代码中使用它。
该类在 Qt 5.1 引入。
enum | PeekOption { PeekDefault, PeekFromCachedIndex } |
flags | PeekOptions |
typedef | PeekerCallback |
int | appDpiX (int screen = -1) |
int | appDpiY (int screen = -1) |
unsigned long | appRootWindow (int screen = -1) |
int | appScreen () |
unsigned long | appTime () |
unsigned long | appUserTime () |
xcb_connection_t * | connection () |
Display * | display () |
qint32 | generatePeekerId () |
unsigned long | getTimestamp () |
bool | isCompositingManagerRunning (int screen = -1) |
bool | isPlatformX11 () |
QByteArray | nextStartupId () |
bool | peekEventQueue (QX11Info::PeekerCallback peeker , void * peekerData = nullptr, QX11Info::PeekOptions option = PeekDefault, qint32 peekerId = -1) |
bool | removePeekerId (qint32 peekerId ) |
void | setAppTime (unsigned long time ) |
void | setAppUserTime (unsigned long time ) |
void | setNextStartupId (const QByteArray & id ) |
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.
警告: This class is only available on X11. For querying per-screen information in a portable way, use QDesktopWidget .
An enum to tune the behavior of QX11Info::peekEventQueue ().
常量 | 值 | 描述 |
---|---|---|
QX11Info::PeekDefault
|
0
|
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. |
QX11Info::PeekFromCachedIndex
|
1
|
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 (). |
该枚举在 Qt 5.10 引入或被修改。
PeekOptions 类型是 typedef 对于 QFlags <PeekOption>. It stores an OR combination of PeekOption values.
Typedef 为指向采用以下签名的函数指针:
bool (*PeekerCallback)(xcb_generic_event_t *event, void *peekerData);
The event is a native XCB event. The peekerData is a pointer to data, passed in via peekEventQueue ().
返回
true
from this function to stop examining the buffered native event queue or
false
to continue.
注意: A non-capturing lambda can serve as a PeekerCallback.
该 typedef 在 Qt 5.10 引入。
[static]
int
QX11Info::
appDpiX
(
int
screen
= -1)
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 QDesktopWidget to query for information about Xinerama screens.
另请参阅 appDpiY ().
[static]
int
QX11Info::
appDpiY
(
int
screen
= -1)
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 QDesktopWidget to query for information about Xinerama screens.
另请参阅 appDpiX ().
[static]
unsigned
long
QX11Info::
appRootWindow
(
int
screen
= -1)
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 QDesktopWidget to query for information about Xinerama screens.
另请参阅 QApplication::desktop ().
[static]
int
QX11Info::
appScreen
()
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 QDesktopWidget and QScreen.
另请参阅 display ().
[static]
unsigned
long
QX11Info::
appTime
()
返回 X11 时间。
另请参阅 setAppTime () 和 appUserTime ().
[static]
unsigned
long
QX11Info::
appUserTime
()
返回 X11 用户时间。
另请参阅 setAppUserTime () 和 appTime ().
[static]
xcb_connection_t
*QX11Info::
connection
()
Returns the default XCB connection for the application.
另请参阅 display ().
[static]
显示
*QX11Info::
display
()
返回应用程序的默认显示。
另请参阅 appScreen ().
[static]
qint32
QX11Info::
generatePeekerId
()
Returns a new peeker id or -1 if some interal error has occurred. Each peeker id is associated with an index in the buffered native event queue.
更多细节见 QX11Info::PeekOption and peekEventQueue ().
该函数在 Qt 5.10 引入。
另请参阅 peekEventQueue () 和 removePeekerId ().
[static]
unsigned
long
QX11Info::
getTimestamp
()
从 X 服务器抓取当前 X11 时间戳。
This method creates a property notify event and blocks till it is received back from the X Server.
该函数在 Qt 5.2 引入。
[static]
bool
QX11Info::
isCompositingManagerRunning
(
int
screen
= -1)
Returns true if there is a compositing manager running for the connection attached to screen .
若 screen equals -1, the application's primary screen is used.
该函数在 Qt 5.7 引入。
[static]
bool
QX11Info::
isPlatformX11
()
Returns true if the application is currently running on X11.
该函数在 Qt 5.2 引入。
[static]
QByteArray
QX11Info::
nextStartupId
()
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
该函数在 Qt 5.4 引入。
另请参阅 setNextStartupId ().
[static]
bool
QX11Info::
peekEventQueue
(
QX11Info::PeekerCallback
peeker
,
void
*
peekerData
= nullptr,
QX11Info::PeekOptions
option
= PeekDefault,
qint32
peekerId
= -1)
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.
注意: 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 。 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 ().
此函数返回
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
.
该函数在 Qt 5.10 引入。
另请参阅 generatePeekerId () 和 QAbstractNativeEventFilter::nativeEventFilter ().
[static]
bool
QX11Info::
removePeekerId
(
qint32
peekerId
)
移除 peekerId , which was earlier obtained via generatePeekerId ().
返回
true
当成功时或
false
if unknown peeker id was provided or some interal error has occurred.
该函数在 Qt 5.10 引入。
另请参阅 generatePeekerId ().
[static]
void
QX11Info::
setAppTime
(
unsigned
long
time
)
Sets the X11 time to the value specified by time .
另请参阅 appTime () 和 setAppUserTime ().
[static]
void
QX11Info::
setAppUserTime
(
unsigned
long
time
)
Sets the X11 user time as specified by time .
另请参阅 appUserTime () 和 setAppTime ().
[static]
void
QX11Info::
setNextStartupId
(const
QByteArray
&
id
)
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).
该函数在 Qt 5.4 引入。
另请参阅 nextStartupId ().