mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-22 11:46:34 +01:00
Ported all X11 specific code to xcb
It now also runtime checks for X11 platform, so it should work on Wayland without recompilation;
This commit is contained in:
parent
daee137862
commit
748e6ce020
8
BUILDING
8
BUILDING
@ -33,7 +33,7 @@ Linux / Unix
|
|||||||
|
|
||||||
You need to have Qt 4 (>= 4.7) or Qt 5 development libraries, pkg-config is
|
You need to have Qt 4 (>= 4.7) or Qt 5 development libraries, pkg-config is
|
||||||
highly recommended to correctly detect QtWebKit version.
|
highly recommended to correctly detect QtWebKit version.
|
||||||
Next compulsory requirement is OpenSSL (libcrypto). X11 libraries are also
|
Next compulsory requirement is OpenSSL (libcrypto). xcb libraries are also
|
||||||
required unless you specify NO_X11 build option.
|
required unless you specify NO_X11 build option.
|
||||||
|
|
||||||
To build spellcheck plugin, you need:
|
To build spellcheck plugin, you need:
|
||||||
@ -151,8 +151,10 @@ Available Defines
|
|||||||
|
|
||||||
Linux / Unix specific defines:
|
Linux / Unix specific defines:
|
||||||
|
|
||||||
NO_X11 Disable all direct X11 calls.
|
NO_X11 Disable all X11 calls.
|
||||||
Enable this when building for Wayland.
|
Enable this when building for Wayland-only.
|
||||||
|
All X11 calls are guarded by runtime X11 platform check
|
||||||
|
even without this option.
|
||||||
|
|
||||||
example:
|
example:
|
||||||
$ export NO_X11="true"
|
$ export NO_X11="true"
|
||||||
|
@ -86,8 +86,9 @@
|
|||||||
#include <QScrollArea>
|
#include <QScrollArea>
|
||||||
|
|
||||||
#ifdef QZ_WS_X11
|
#ifdef QZ_WS_X11
|
||||||
#include <X11/Xlib.h>
|
#include <QX11Info>
|
||||||
#include <X11/Xatom.h>
|
#include <xcb/xcb.h>
|
||||||
|
#include <xcb/xcb_atom.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
@ -1469,47 +1470,67 @@ bool BrowserWindow::restoreState(const QByteArray &state, int version)
|
|||||||
#ifdef QZ_WS_X11
|
#ifdef QZ_WS_X11
|
||||||
int BrowserWindow::getCurrentVirtualDesktop() const
|
int BrowserWindow::getCurrentVirtualDesktop() const
|
||||||
{
|
{
|
||||||
Display* display = static_cast<Display*>(QzTools::X11Display(this));
|
if (!QX11Info::isPlatformX11())
|
||||||
Atom actual_type;
|
return 0;
|
||||||
int actual_format;
|
|
||||||
unsigned long nitems;
|
|
||||||
unsigned long bytes;
|
|
||||||
unsigned long* data;
|
|
||||||
|
|
||||||
Atom net_wm_desktop = XInternAtom(display, "_NET_WM_DESKTOP", False);
|
xcb_intern_atom_cookie_t intern_atom;
|
||||||
if (net_wm_desktop == None) {
|
xcb_intern_atom_reply_t *atom_reply = 0;
|
||||||
return -1;
|
xcb_atom_t atom;
|
||||||
}
|
xcb_get_property_cookie_t cookie;
|
||||||
|
xcb_get_property_reply_t *reply = 0;
|
||||||
|
uint32_t value;
|
||||||
|
|
||||||
int status = XGetWindowProperty(display, winId(), net_wm_desktop, 0, 1,
|
intern_atom = xcb_intern_atom(QX11Info::connection(), false, qstrlen("_NET_WM_DESKTOP"), "_NET_WM_DESKTOP");
|
||||||
False, XA_CARDINAL, &actual_type, &actual_format,
|
atom_reply = xcb_intern_atom_reply(QX11Info::connection(), intern_atom, 0);
|
||||||
&nitems, &bytes, (unsigned char**) &data);
|
|
||||||
|
|
||||||
if (status != Success || data == NULL) {
|
if (!atom_reply)
|
||||||
return -1;
|
goto error;
|
||||||
}
|
|
||||||
|
|
||||||
int desktop = *data;
|
atom = atom_reply->atom;
|
||||||
XFree(data);
|
|
||||||
|
|
||||||
return desktop;
|
cookie = xcb_get_property(QX11Info::connection(), false, winId(), atom, XCB_ATOM_CARDINAL, 0, 1);
|
||||||
|
reply = xcb_get_property_reply(QX11Info::connection(), cookie, 0);
|
||||||
|
|
||||||
|
if (!reply || reply->type != XCB_ATOM_CARDINAL || reply->value_len != 1 || reply->format != sizeof(uint32_t) * 8)
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
value = *reinterpret_cast<uint32_t*>(xcb_get_property_value(reply));
|
||||||
|
|
||||||
|
free(reply);
|
||||||
|
free(atom_reply);
|
||||||
|
return value;
|
||||||
|
|
||||||
|
error:
|
||||||
|
free(reply);
|
||||||
|
free(atom_reply);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowserWindow::moveToVirtualDesktop(int desktopId)
|
void BrowserWindow::moveToVirtualDesktop(int desktopId)
|
||||||
{
|
{
|
||||||
|
if (!QX11Info::isPlatformX11())
|
||||||
|
return;
|
||||||
|
|
||||||
// Don't move when window is already visible or it is first app window
|
// Don't move when window is already visible or it is first app window
|
||||||
if (desktopId < 0 || isVisible() || m_windowType == Qz::BW_FirstAppWindow) {
|
if (desktopId < 0 || isVisible() || m_windowType == Qz::BW_FirstAppWindow)
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
Display* display = static_cast<Display*>(QzTools::X11Display(this));
|
xcb_intern_atom_cookie_t intern_atom;
|
||||||
|
xcb_intern_atom_reply_t *atom_reply = 0;
|
||||||
|
xcb_atom_t atom;
|
||||||
|
|
||||||
Atom net_wm_desktop = XInternAtom(display, "_NET_WM_DESKTOP", False);
|
intern_atom = xcb_intern_atom(QX11Info::connection(), false, qstrlen("_NET_WM_DESKTOP"), "_NET_WM_DESKTOP");
|
||||||
if (net_wm_desktop == None) {
|
atom_reply = xcb_intern_atom_reply(QX11Info::connection(), intern_atom, 0);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
XChangeProperty(display, winId(), net_wm_desktop, XA_CARDINAL,
|
if (!atom_reply)
|
||||||
32, PropModeReplace, (unsigned char*) &desktopId, 1L);
|
goto error;
|
||||||
|
|
||||||
|
atom = atom_reply->atom;
|
||||||
|
|
||||||
|
xcb_change_property(QX11Info::connection(), XCB_PROP_MODE_REPLACE, winId(), atom,
|
||||||
|
XCB_ATOM_CARDINAL, 32, 1, (const void*) &desktopId);
|
||||||
|
|
||||||
|
error:
|
||||||
|
free(atom_reply);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -504,7 +504,7 @@ qtHaveModule(ftp) {
|
|||||||
INSTALLS += target
|
INSTALLS += target
|
||||||
|
|
||||||
!contains(DEFINES, NO_X11) {
|
!contains(DEFINES, NO_X11) {
|
||||||
LIBS += -lX11
|
LIBS += -lxcb
|
||||||
QT *= x11extras
|
QT *= x11extras
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,8 +45,7 @@
|
|||||||
#endif
|
#endif
|
||||||
#ifdef QZ_WS_X11
|
#ifdef QZ_WS_X11
|
||||||
#include <QX11Info>
|
#include <QX11Info>
|
||||||
#include <X11/Xlib.h>
|
#include <xcb/xcb.h>
|
||||||
#include <X11/Xutil.h>
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
@ -818,26 +817,26 @@ QString QzTools::escape(const QString &string)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void* QzTools::X11Display(const QWidget* widget)
|
|
||||||
{
|
|
||||||
Q_UNUSED(widget)
|
|
||||||
|
|
||||||
#ifdef QZ_WS_X11
|
|
||||||
return QX11Info::display();
|
|
||||||
#else
|
|
||||||
return 0;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void QzTools::setWmClass(const QString &name, const QWidget* widget)
|
void QzTools::setWmClass(const QString &name, const QWidget* widget)
|
||||||
{
|
{
|
||||||
#ifdef QZ_WS_X11
|
#ifdef QZ_WS_X11
|
||||||
QByteArray nameData = name.toUtf8();
|
if (!QX11Info::isPlatformX11())
|
||||||
|
return;
|
||||||
|
|
||||||
|
const QByteArray &nameData = name.toUtf8();
|
||||||
|
const QByteArray &classData = QByteArrayLiteral("QupZilla");
|
||||||
|
|
||||||
|
uint32_t class_len = nameData.length() + 1 + classData.length() + 1;
|
||||||
|
char *class_hint = (char*) malloc(class_len);
|
||||||
|
|
||||||
|
qstrcpy(class_hint, nameData.constData());
|
||||||
|
qstrcpy(class_hint + nameData.length() + 1, classData.constData());
|
||||||
|
|
||||||
|
xcb_change_property(QX11Info::connection(), XCB_PROP_MODE_REPLACE, widget->winId(),
|
||||||
|
XCB_ATOM_WM_CLASS, XCB_ATOM_STRING, 8, class_len, class_hint);
|
||||||
|
|
||||||
|
free(class_hint);
|
||||||
|
|
||||||
XClassHint classHint;
|
|
||||||
classHint.res_name = const_cast<char*>(nameData.constData());
|
|
||||||
classHint.res_class = const_cast<char*>("QupZilla");
|
|
||||||
XSetClassHint((Display*)X11Display(widget), widget->winId(), &classHint);
|
|
||||||
#else
|
#else
|
||||||
Q_UNUSED(name)
|
Q_UNUSED(name)
|
||||||
Q_UNUSED(widget)
|
Q_UNUSED(widget)
|
||||||
|
@ -86,7 +86,6 @@ public:
|
|||||||
static bool isCertificateValid(const QSslCertificate &cert);
|
static bool isCertificateValid(const QSslCertificate &cert);
|
||||||
static QString escape(const QString &string);
|
static QString escape(const QString &string);
|
||||||
|
|
||||||
static void* X11Display(const QWidget* widget);
|
|
||||||
static void setWmClass(const QString &name, const QWidget* widget);
|
static void setWmClass(const QString &name, const QWidget* widget);
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
Loading…
Reference in New Issue
Block a user