mirror of
https://bitbucket.org/smil3y/katie.git
synced 2025-02-24 02:42:55 +00:00
fix possible crashes in case QCursor is used when qt_x11Data is null
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
1d8cc1be87
commit
48f864a5f4
1 changed files with 16 additions and 7 deletions
|
@ -114,7 +114,7 @@ Qt::HANDLE QCursor::handle() const
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Display *dpy = qt_x11Data->display;
|
Display *dpy = (qt_x11Data ? qt_x11Data->display : nullptr);
|
||||||
if (!dpy) {
|
if (!dpy) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -185,11 +185,14 @@ Qt::HANDLE QCursor::handle() const
|
||||||
*/
|
*/
|
||||||
int QCursor::x11Screen()
|
int QCursor::x11Screen()
|
||||||
{
|
{
|
||||||
|
Display *dpy = (qt_x11Data ? qt_x11Data->display : nullptr);
|
||||||
|
if (!dpy) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
Window root;
|
Window root;
|
||||||
Window child;
|
Window child;
|
||||||
int root_x, root_y, win_x, win_y;
|
int root_x, root_y, win_x, win_y;
|
||||||
uint buttons;
|
uint buttons;
|
||||||
Display* dpy = qt_x11Data->display;
|
|
||||||
for (int i = 0; i < ScreenCount(dpy); ++i) {
|
for (int i = 0; i < ScreenCount(dpy); ++i) {
|
||||||
if (XQueryPointer(dpy, QX11Info::appRootWindow(i), &root, &child, &root_x, &root_y,
|
if (XQueryPointer(dpy, QX11Info::appRootWindow(i), &root, &child, &root_x, &root_y,
|
||||||
&win_x, &win_y, &buttons)) {
|
&win_x, &win_y, &buttons)) {
|
||||||
|
@ -202,11 +205,14 @@ int QCursor::x11Screen()
|
||||||
|
|
||||||
QPoint QCursor::pos()
|
QPoint QCursor::pos()
|
||||||
{
|
{
|
||||||
|
Display *dpy = (qt_x11Data ? qt_x11Data->display : nullptr);
|
||||||
|
if (!dpy) {
|
||||||
|
return QPoint();
|
||||||
|
}
|
||||||
Window root;
|
Window root;
|
||||||
Window child;
|
Window child;
|
||||||
int root_x, root_y, win_x, win_y;
|
int root_x, root_y, win_x, win_y;
|
||||||
uint buttons;
|
uint buttons;
|
||||||
Display* dpy = qt_x11Data->display;
|
|
||||||
for (int i = 0; i < ScreenCount(dpy); ++i) {
|
for (int i = 0; i < ScreenCount(dpy); ++i) {
|
||||||
if (XQueryPointer(dpy, QX11Info::appRootWindow(i), &root, &child, &root_x, &root_y,
|
if (XQueryPointer(dpy, QX11Info::appRootWindow(i), &root, &child, &root_x, &root_y,
|
||||||
&win_x, &win_y, &buttons)) {
|
&win_x, &win_y, &buttons)) {
|
||||||
|
@ -218,18 +224,21 @@ QPoint QCursor::pos()
|
||||||
|
|
||||||
void QCursor::setPos(int x, int y)
|
void QCursor::setPos(int x, int y)
|
||||||
{
|
{
|
||||||
|
Display *dpy = (qt_x11Data ? qt_x11Data->display : nullptr);
|
||||||
|
if (!dpy) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
QPoint current;
|
QPoint current;
|
||||||
QPoint target(x, y);
|
QPoint target(x, y);
|
||||||
|
|
||||||
// this is copied from pos(), since we need the screen number for the correct
|
// this is copied from pos(), since we need the screen number for the correct
|
||||||
// root window in the XWarpPointer call
|
// root window in the XWarpPointer call
|
||||||
Window root;
|
Window root;
|
||||||
Window child;
|
Window child;
|
||||||
int root_x, root_y, win_x, win_y;
|
int root_x, root_y, win_x, win_y;
|
||||||
uint buttons;
|
uint buttons;
|
||||||
Display* dpy = qt_x11Data->display;
|
int screen = 0;
|
||||||
int screen;
|
for (; screen < ScreenCount(dpy); ++screen) {
|
||||||
for (screen = 0; screen < ScreenCount(dpy); ++screen) {
|
|
||||||
if (XQueryPointer(dpy, QX11Info::appRootWindow(screen), &root, &child, &root_x, &root_y,
|
if (XQueryPointer(dpy, QX11Info::appRootWindow(screen), &root, &child, &root_x, &root_y,
|
||||||
&win_x, &win_y, &buttons)) {
|
&win_x, &win_y, &buttons)) {
|
||||||
current = QPoint(root_x, root_y);
|
current = QPoint(root_x, root_y);
|
||||||
|
|
Loading…
Add table
Reference in a new issue