53 #define class class_name 54 #include <xcb/xcb_icccm.h> 57 #ifdef XCB_ICCCM_NUM_WM_SIZE_HINTS_ELEMENTS 58 #define xcb_wm_hints_t xcb_icccm_wm_hints_t 59 #define xcb_wm_hints_set_iconic xcb_icccm_wm_hints_set_iconic 60 #define xcb_wm_hints_set_normal xcb_icccm_wm_hints_set_normal 61 #define xcb_set_wm_hints xcb_icccm_set_wm_hints 63 #define xcb_wm_hints_t xcb_icccm_wm_hints_t 64 #define xcb_get_wm_hints_reply xcb_icccm_get_wm_hints_reply 65 #define xcb_get_wm_hints xcb_icccm_get_wm_hints 66 #define xcb_set_wm_hints xcb_icccm_set_wm_hints 67 #define xcb_set_wm_normal_hints xcb_icccm_set_wm_normal_hints 68 #define xcb_size_hints_set_base_size xcb_icccm_size_hints_set_base_size 69 #define xcb_size_hints_set_max_size xcb_icccm_size_hints_set_max_size 70 #define xcb_size_hints_set_min_size xcb_icccm_size_hints_set_min_size 71 #define xcb_size_hints_set_position xcb_icccm_size_hints_set_position 72 #define xcb_size_hints_set_resize_inc xcb_icccm_size_hints_set_resize_inc 73 #define xcb_size_hints_set_size xcb_icccm_size_hints_set_size 74 #define xcb_size_hints_set_win_gravity xcb_icccm_size_hints_set_win_gravity 75 #define xcb_wm_hints_t xcb_icccm_wm_hints_t 76 #define XCB_WM_STATE_ICONIC XCB_ICCCM_WM_STATE_ICONIC 79 #include <private/qapplication_p.h> 80 #include <private/qwindowsurface_p.h> 82 #include <QtGui/QWindowSystemInterface> 88 #include <X11/Xutil.h> 91 #if defined(XCB_USE_GLX) 92 #include "qglxintegration.h" 94 #elif defined(XCB_USE_EGL) 95 #include "../eglconvenience/qeglplatformcontext.h" 96 #include "../eglconvenience/qeglconvenience.h" 97 #include "../eglconvenience/qxlibeglintegration.h" 121 const quint32 mask = XCB_CW_BACK_PIXMAP | XCB_CW_EVENT_MASK;
126 XCB_EVENT_MASK_EXPOSURE
127 | XCB_EVENT_MASK_STRUCTURE_NOTIFY
128 | XCB_EVENT_MASK_KEY_PRESS
129 | XCB_EVENT_MASK_KEY_RELEASE
130 | XCB_EVENT_MASK_BUTTON_PRESS
131 | XCB_EVENT_MASK_BUTTON_RELEASE
132 | XCB_EVENT_MASK_BUTTON_MOTION
133 | XCB_EVENT_MASK_ENTER_WINDOW
134 | XCB_EVENT_MASK_LEAVE_WINDOW
135 | XCB_EVENT_MASK_PROPERTY_CHANGE
136 | XCB_EVENT_MASK_FOCUS_CHANGE
139 #if defined(XCB_USE_GLX) || defined(XCB_USE_EGL) 142 || tlw->platformWindowFormat().alpha())
144 #if defined(XCB_USE_GLX) 146 #elif defined(XCB_USE_EGL) 147 EGLDisplay eglDisplay =
connection()->egl_display();
151 XVisualInfo visualInfoTemplate;
152 memset(&visualInfoTemplate, 0,
sizeof(XVisualInfo));
153 visualInfoTemplate.visualid = id;
155 XVisualInfo *visualInfo;
156 int matchingCount = 0;
157 visualInfo = XGetVisualInfo(
DISPLAY_FROM_XCB(
this), VisualIDMask, &visualInfoTemplate, &matchingCount);
164 XSetWindowAttributes
a;
169 0, visualInfo->depth, InputOutput, visualInfo->visual,
170 CWBackPixel|CWBorderPixel|CWColormap, &
a);
172 printf(
"created GL window: %d\n",
m_window);
177 #endif //defined(XCB_USE_GLX) || defined(XCB_USE_EGL) 184 XCB_COPY_FROM_PARENT,
192 XCB_WINDOW_CLASS_INPUT_OUTPUT,
197 printf(
"created regular window: %d\n",
m_window);
203 int propertyCount = 0;
215 XCB_PROP_MODE_REPLACE,
230 XCB_PROP_MODE_REPLACE,
242 xcb_window_t parentWindow = p->
winId();
244 XCB_ATOM_WM_TRANSIENT_FOR, XCB_ATOM_WINDOW, 32,
268 const quint32 mask = XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y | XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT;
276 xcb_wm_hints_t hints;
278 if (
widget()->isMinimized())
279 xcb_wm_hints_set_iconic(&hints);
281 xcb_wm_hints_set_normal(&hints);
289 xcb_unmap_notify_event_t
event;
290 event.response_type = XCB_UNMAP_NOTIFY;
294 event.from_configure =
false;
296 XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT, (
const char *)&event));
421 if (mwmhints.
flags != 0
l) {
423 XCB_PROP_MODE_REPLACE,
434 if (popup || tooltip) {
435 const quint32 mask = XCB_CW_OVERRIDE_REDIRECT | XCB_CW_SAVE_UNDER;
495 XCB_PROP_MODE_REPLACE,
506 const quint32 mask = XCB_CONFIG_WINDOW_STACK_MODE;
513 const quint32 mask = XCB_CONFIG_WINDOW_STACK_MODE;
527 printf(
"no opengl\n");
531 #if defined(XCB_USE_GLX) 534 #elif defined(XCB_USE_EGL) 538 eglContextAttrs.
append(EGL_CONTEXT_CLIENT_VERSION);
539 eglContextAttrs.
append(2);
540 eglContextAttrs.
append(EGL_NONE);
545 #elif defined(XCB_USE_DRI2) 557 QRect rect(event->x, event->y, event->width, event->height);
569 xcb_client_message_event_t reply = *
event;
571 reply.response_type = XCB_CLIENT_MESSAGE;
574 xcb_send_event(
xcb_connection(), 0,
m_screen->
root(), XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT, (
const char *)&reply);
579 printf(
"Window manager supports _NET_WM_SYNC_REQUEST, syncing resizes\n");
592 if ((event->width ==
geometry().width() && event->
height ==
geometry().height()) || event->x != 0 || event->y != 0) {
597 QRect rect(xpos, ypos, event->width, event->height);
613 Qt::MouseButtons ret = 0;
614 if (s & XCB_BUTTON_MASK_1)
616 if (s & XCB_BUTTON_MASK_2)
618 if (s & XCB_BUTTON_MASK_3)
639 QPoint local(event->event_x, event->event_y);
640 QPoint global(event->root_x, event->root_y);
644 if (event->detail >= 4 && event->detail <= 7) {
646 int delta = 120 * ((
event->detail == 4 ||
event->detail == 6) ? 1 : -1);
647 bool hor = (((
event->detail == 4 ||
event->detail == 5)
649 || (event->detail == 6 || event->detail == 7));
661 QPoint local(event->event_x, event->event_y);
662 QPoint global(event->root_x, event->root_y);
669 QPoint local(event->event_x, event->event_y);
670 QPoint global(event->root_x, event->root_y);
bool m_hasReceivedSyncRequest
void handleFocusOutEvent(const xcb_focus_out_event_t *event)
bool syncRequestSupported() const
QPlatformGLContext * m_context
static void handleWheelEvent(QWidget *w, const QPoint &local, const QPoint &global, int d, Qt::Orientation o)
int count(const T &t) const
Returns the number of occurrences of value in the vector.
QByteArray toUtf8() const Q_REQUIRED_RESULT
Returns a UTF-8 representation of the string as a QByteArray.
#define DISPLAY_FROM_XCB(object)
EGLConfig q_configFromQPlatformWindowFormat(EGLDisplay display, const QPlatformWindowFormat &format, bool highestPixelFormat, int surfaceType)
The QByteArray class provides an array of bytes.
xcb_connection_t * xcb_connection() const
static Qt::MouseButtons buttons
void handleButtonPressEvent(const xcb_button_press_event_t *event)
void setWindowTitle(const QString &title)
Reimplement to set the window title to title.
void setConnection(QXcbConnection *connection)
int width() const
Returns the width of the rectangle.
QPlatformGLContext * glContext() const
Reimplement to return the glContext associated with the window.
void handleConfigureNotifyEvent(const xcb_configure_notify_event_t *event)
long ASN1_INTEGER_get ASN1_INTEGER * a
int height() const
Returns the height of the rectangle.
The QString class provides a Unicode character string.
Qt::WindowFlags setWindowFlags(Qt::WindowFlags flags)
Requests setting the window flags of this surface to type.
NativeWindowType EGLNativeWindowType
static Qt::MouseButton translateMouseButton(xcb_button_t s)
void handleMotionNotifyEvent(const xcb_motion_notify_event_t *event)
QXcbConnection * connection() const
void handleMouseEvent(xcb_button_t detail, uint16_t state, xcb_timestamp_t time, const QPoint &local, const QPoint &global)
void handleFocusInEvent(const xcb_focus_in_event_t *event)
xcb_sync_int64_t m_syncValue
Q_GUI_EXPORT EGLDisplay display()
static VisualID getCompatibleVisualId(Display *display, EGLDisplay eglDisplay, EGLConfig config)
static void handleWindowActivated(QWidget *w)
static Qt::MouseButtons translateMouseButtons(int s)
virtual void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset)=0
Flushes the given region from the specified widget onto the screen.
QSize size() const
Returns the size of the rectangle.
static void handleMouseEvent(QWidget *w, const QPoint &local, const QPoint &global, Qt::MouseButtons b)
tlw == 0 means that ev is in global coords only
void append(const T &t)
Inserts value at the end of the vector.
xcb_window_t root() const
void handleClientMessageEvent(const xcb_client_message_event_t *event)
void setVisible(bool visible)
Reimplemented in subclasses to show the surface if visible is true, and hide it if visible is false...
static void handleCloseEvent(QWidget *w)
static bool isTransient(const QWidget *w)
void setGeometry(const QRect &rect)
This function is called by Qt whenever a window is moved or the window is resized.
void setNetWmWindowTypes(Qt::WindowFlags flags)
void handleButtonReleaseEvent(const xcb_button_release_event_t *event)
The QWindowSurface class provides the drawing area for top-level windows.
void handleEnterNotifyEvent(const xcb_enter_notify_event_t *event)
int length() const
Same as size().
void requestActivateWindow()
Reimplement to let Qt be able to request activation/focus for a window.
void raise()
Reimplement to be able to let Qt rais windows to the top of the desktop.
const char * constData() const
Returns a pointer to the data stored in the byte array.
void handleExposeEvent(const xcb_expose_event_t *event)
xcb_sync_counter_t m_syncCounter
Q_CORE_EXPORT void qFatal(const char *,...)
WId winId() const
Reimplement in subclasses to return a handle to the native window.
The QPlatformGLContext class provides an abstraction for native GL contexts.
void setParent(const QPlatformWindow *window)
This function is called to enable native child widgets in QPA.
int y() const
Returns the y-coordinate of the rectangle's top edge.
xcb_window_t window() const
int x() const
Returns the x-coordinate of the rectangle's left edge.
The QPoint class defines a point in the plane using integer precision.
static void handleGeometryChange(QWidget *w, const QRect &newRect)
The QRect class defines a rectangle in the plane using integer precision.
static const QCssKnownValue properties[NumProperties - 1]
int y() const
Returns the y coordinate of this point.
XVisualInfo * qglx_findVisualInfo(Display *display, int screen, const QPlatformWindowFormat &format)
T * data()
Returns a pointer to the data stored in the vector.
const T * constData() const
Returns a const pointer to the data stored in the vector.
int x() const
Returns the x coordinate of this point.
xcb_atom_t atom(QXcbAtom::Atom atom) const
void lower()
Reimplement to be able to let Qt lower windows to the bottom of the desktop.
static void handleEnterEvent(QWidget *w)
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
static void handleLeaveEvent(QWidget *w)
void handleLeaveNotifyEvent(const xcb_leave_notify_event_t *event)
QPoint topLeft() const
Returns the position of the rectangle's top-left corner.
xcb_screen_t * screen() const
void updateSyncRequestCounter()