Fix the xlib backend for lighthouse
Adapt the backend to the changes in lighthouse. Change-Id: If2d795c901143a80eed4f23d14add6ab9f42750b Reviewed-on: http://codereview.qt.nokia.com/3568 Reviewed-by: Jørgen Lind <jorgen.lind@nokia.com>bb10
parent
b2c4c4fc2a
commit
82f95318d6
|
|
@ -54,10 +54,7 @@ public:
|
|||
QStringList QXlibIntegrationPlugin::keys() const
|
||||
{
|
||||
QStringList list;
|
||||
list << "Xlib";
|
||||
#ifndef QT_NO_OPENGL
|
||||
list << "XlibGL";
|
||||
#endif
|
||||
list << "xlib";
|
||||
return list;
|
||||
}
|
||||
|
||||
|
|
@ -66,10 +63,6 @@ QPlatformIntegration* QXlibIntegrationPlugin::create(const QString& system, cons
|
|||
Q_UNUSED(paramList);
|
||||
if (system.toLower() == "xlib")
|
||||
return new QXlibIntegration;
|
||||
#ifndef QT_NO_OPENGL
|
||||
if (system.toLower() == "xlibgl")
|
||||
return new QXlibIntegration(true);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@
|
|||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <GL/glx.h>
|
||||
#include "qglxconvenience.h"
|
||||
#include "private/qglxconvenience_p.h"
|
||||
|
||||
#include "qglxintegration.h"
|
||||
|
||||
|
|
@ -61,34 +61,24 @@
|
|||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QGLXContext::QGLXContext(Window window, QXlibScreen *screen, const QPlatformWindowFormat &format)
|
||||
QGLXContext::QGLXContext(QXlibScreen *screen, const QSurfaceFormat &format, QPlatformGLContext *share)
|
||||
: QPlatformGLContext()
|
||||
, m_screen(screen)
|
||||
, m_drawable((Drawable)window)
|
||||
, m_context(0)
|
||||
{
|
||||
|
||||
const QPlatformGLContext *sharePlatformContext;
|
||||
sharePlatformContext = format.sharedGLContext();
|
||||
GLXContext shareGlxContext = 0;
|
||||
if (sharePlatformContext)
|
||||
shareGlxContext = static_cast<const QGLXContext*>(sharePlatformContext)->glxContext();
|
||||
if (share)
|
||||
shareGlxContext = static_cast<const QGLXContext*>(share)->glxContext();
|
||||
|
||||
GLXFBConfig config = qglx_findConfig(screen->display()->nativeDisplay(),screen->xScreenNumber(),format);
|
||||
m_context = glXCreateNewContext(screen->display()->nativeDisplay(),config,GLX_RGBA_TYPE,shareGlxContext,TRUE);
|
||||
m_windowFormat = qglx_platformWindowFromGLXFBConfig(screen->display()->nativeDisplay(),config,m_context);
|
||||
m_windowFormat = qglx_surfaceFormatFromGLXFBConfig(screen->display()->nativeDisplay(),config,m_context);
|
||||
|
||||
#ifdef MYX11_DEBUG
|
||||
qDebug() << "QGLXGLContext::create context" << m_context;
|
||||
#endif
|
||||
}
|
||||
|
||||
QGLXContext::QGLXContext(QXlibScreen *screen, Drawable drawable, GLXContext context)
|
||||
: QPlatformGLContext(), m_screen(screen), m_drawable(drawable), m_context(context)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QGLXContext::~QGLXContext()
|
||||
{
|
||||
if (m_context) {
|
||||
|
|
@ -97,13 +87,20 @@ QGLXContext::~QGLXContext()
|
|||
}
|
||||
}
|
||||
|
||||
void QGLXContext::makeCurrent()
|
||||
QSurfaceFormat QGLXContext::format() const
|
||||
{
|
||||
QPlatformGLContext::makeCurrent();
|
||||
return m_windowFormat;
|
||||
}
|
||||
|
||||
bool QGLXContext::makeCurrent(QPlatformSurface *surface)
|
||||
{
|
||||
Q_UNUSED(surface);
|
||||
|
||||
GLXDrawable glxDrawable = static_cast<QXlibWindow *>(surface)->winId();
|
||||
#ifdef MYX11_DEBUG
|
||||
qDebug("QGLXGLContext::makeCurrent(window=0x%x, ctx=0x%x)", m_drawable, m_context);
|
||||
qDebug("QGLXGLContext::makeCurrent(window=0x%x, ctx=0x%x)", glxDrawable, m_context);
|
||||
#endif
|
||||
glXMakeCurrent(m_screen->display()->nativeDisplay(), m_drawable, m_context);
|
||||
return glXMakeCurrent(m_screen->display()->nativeDisplay(), glxDrawable, m_context);
|
||||
}
|
||||
|
||||
void QGLXContext::doneCurrent()
|
||||
|
|
@ -112,12 +109,15 @@ void QGLXContext::doneCurrent()
|
|||
glXMakeCurrent(m_screen->display()->nativeDisplay(), 0, 0);
|
||||
}
|
||||
|
||||
void QGLXContext::swapBuffers()
|
||||
void QGLXContext::swapBuffers(QPlatformSurface *surface)
|
||||
{
|
||||
glXSwapBuffers(m_screen->display()->nativeDisplay(), m_drawable);
|
||||
Q_UNUSED(surface);
|
||||
|
||||
GLXDrawable glxDrawable = static_cast<QXlibWindow *>(surface)->winId();
|
||||
glXSwapBuffers(m_screen->display()->nativeDisplay(), glxDrawable);
|
||||
}
|
||||
|
||||
void* QGLXContext::getProcAddress(const QString& procName)
|
||||
void (*QGLXContext::getProcAddress(const QByteArray& procName))()
|
||||
{
|
||||
typedef void *(*qt_glXGetProcAddressARB)(const GLubyte *);
|
||||
static qt_glXGetProcAddressARB glXGetProcAddressARB = 0;
|
||||
|
|
@ -147,10 +147,10 @@ void* QGLXContext::getProcAddress(const QString& procName)
|
|||
}
|
||||
if (!glXGetProcAddressARB)
|
||||
return 0;
|
||||
return glXGetProcAddressARB(reinterpret_cast<const GLubyte *>(procName.toLatin1().data()));
|
||||
return (void (*)())glXGetProcAddressARB(reinterpret_cast<const GLubyte *>(procName.constData()));
|
||||
}
|
||||
|
||||
QPlatformWindowFormat QGLXContext::platformWindowFormat() const
|
||||
QSurfaceFormat QGLXContext::surfaceFormat() const
|
||||
{
|
||||
return m_windowFormat;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@
|
|||
#include "qxlibwindow.h"
|
||||
|
||||
#include <QtGui/QPlatformGLContext>
|
||||
#include <QtGui/QPlatformWindowFormat>
|
||||
#include <QtGui/qsurfaceformat.h>
|
||||
|
||||
#include <QtCore/QMutex>
|
||||
|
||||
|
|
@ -57,25 +57,23 @@ QT_BEGIN_NAMESPACE
|
|||
class QGLXContext : public QPlatformGLContext
|
||||
{
|
||||
public:
|
||||
QGLXContext(Window window, QXlibScreen *xd, const QPlatformWindowFormat &format);
|
||||
QGLXContext(QXlibScreen *xd, const QSurfaceFormat &format, QPlatformGLContext *share);
|
||||
~QGLXContext();
|
||||
|
||||
virtual void makeCurrent();
|
||||
virtual void doneCurrent();
|
||||
virtual void swapBuffers();
|
||||
virtual void* getProcAddress(const QString& procName);
|
||||
QSurfaceFormat format() const;
|
||||
void swapBuffers(QPlatformSurface *surface);
|
||||
bool makeCurrent(QPlatformSurface *surface);
|
||||
void doneCurrent();
|
||||
virtual void (*getProcAddress(const QByteArray& procName))();
|
||||
|
||||
GLXContext glxContext() const {return m_context;}
|
||||
|
||||
QPlatformWindowFormat platformWindowFormat() const;
|
||||
QSurfaceFormat surfaceFormat() const;
|
||||
|
||||
private:
|
||||
QXlibScreen *m_screen;
|
||||
Drawable m_drawable;
|
||||
GLXContext m_context;
|
||||
QPlatformWindowFormat m_windowFormat;
|
||||
|
||||
QGLXContext (QXlibScreen *screen, Drawable drawable, GLXContext context);
|
||||
QSurfaceFormat m_windowFormat;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@
|
|||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qxlibwindowsurface.h"
|
||||
#include "qxlibbackingstore.h"
|
||||
#include "qxlibintegration.h"
|
||||
|
||||
#include <QtCore/qdebug.h>
|
||||
|
|
@ -57,7 +57,6 @@
|
|||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
|
||||
struct QXlibShmImageInfo {
|
||||
QXlibShmImageInfo(Display *xdisplay) : image(0), display(xdisplay) {}
|
||||
~QXlibShmImageInfo() { destroy(); }
|
||||
|
|
@ -80,13 +79,15 @@ void QXlibShmImageInfo::destroy()
|
|||
}
|
||||
#endif
|
||||
|
||||
void QXlibWindowSurface::resizeShmImage(int width, int height)
|
||||
void QXlibBackingStore::resizeShmImage(int width, int height)
|
||||
{
|
||||
QXlibScreen *screen = QXlibScreen::testLiteScreenForWidget(window());
|
||||
QXlibWindow *win = static_cast<QXlibWindow*>(window()->platformWindow());
|
||||
QXlibWindow *win = static_cast<QXlibWindow*>(window()->handle());
|
||||
|
||||
QImage::Format format = win->depth() == 16 ? QImage::Format_RGB16 : QImage::Format_RGB32;
|
||||
|
||||
#ifdef DONT_USE_MIT_SHM
|
||||
shm_img = QImage(width, height, win->format());
|
||||
shm_img = QImage(width, height, format);
|
||||
#else
|
||||
|
||||
if (image_info)
|
||||
|
|
@ -110,69 +111,68 @@ void QXlibWindowSurface::resizeShmImage(int width, int height)
|
|||
|
||||
Q_ASSERT(shm_attach_status == True);
|
||||
|
||||
shm_img = QImage( (uchar*) image->data, image->width, image->height, image->bytes_per_line, win->format() );
|
||||
shm_img = QImage((uchar*) image->data, image->width, image->height, image->bytes_per_line, format);
|
||||
#endif
|
||||
painted = false;
|
||||
}
|
||||
|
||||
|
||||
void QXlibWindowSurface::resizeBuffer(QSize s)
|
||||
void QXlibBackingStore::resizeBuffer(QSize s)
|
||||
{
|
||||
if (shm_img.size() != s)
|
||||
resizeShmImage(s.width(), s.height());
|
||||
}
|
||||
|
||||
QSize QXlibWindowSurface::bufferSize() const
|
||||
QSize QXlibBackingStore::bufferSize() const
|
||||
{
|
||||
return shm_img.size();
|
||||
}
|
||||
|
||||
QXlibWindowSurface::QXlibWindowSurface (QWidget *window)
|
||||
: QWindowSurface(window),
|
||||
QXlibBackingStore::QXlibBackingStore(QWindow *window)
|
||||
: QPlatformBackingStore(window),
|
||||
painted(false), image_info(0)
|
||||
{
|
||||
xw = static_cast<QXlibWindow*>(window->platformWindow());
|
||||
xw = static_cast<QXlibWindow*>(window->handle());
|
||||
// qDebug() << "QTestLiteWindowSurface::QTestLiteWindowSurface:" << xw->window;
|
||||
}
|
||||
|
||||
QXlibWindowSurface::~QXlibWindowSurface()
|
||||
QXlibBackingStore::~QXlibBackingStore()
|
||||
{
|
||||
delete image_info;
|
||||
}
|
||||
|
||||
QPaintDevice *QXlibWindowSurface::paintDevice()
|
||||
QPaintDevice *QXlibBackingStore::paintDevice()
|
||||
{
|
||||
return &shm_img;
|
||||
}
|
||||
|
||||
|
||||
void QXlibWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset)
|
||||
void QXlibBackingStore::flush(QWindow *w, const QRegion ®ion, const QPoint &offset)
|
||||
{
|
||||
Q_UNUSED(widget);
|
||||
Q_UNUSED(region);
|
||||
Q_UNUSED(offset);
|
||||
|
||||
if (!painted)
|
||||
return;
|
||||
|
||||
QXlibScreen *screen = QXlibScreen::testLiteScreenForWidget(widget);
|
||||
QXlibScreen *screen = QXlibScreen::testLiteScreenForWidget(w);
|
||||
GC gc = xw->graphicsContext();
|
||||
Window window = xw->xWindow();
|
||||
#ifdef DONT_USE_MIT_SHM
|
||||
// just convert the image every time...
|
||||
if (!shm_img.isNull()) {
|
||||
QXlibWindow *win = static_cast<QXlibWindow*>(window()->platformWindow());
|
||||
QXlibWindow *win = static_cast<QXlibWindow*>(w->handle());
|
||||
|
||||
QImage image = shm_img;
|
||||
//img.convertToFormat(
|
||||
XImage *xi = XCreateImage(screen->display(), win->visual(), win->depth(), ZPixmap,
|
||||
XImage *xi = XCreateImage(screen->display()->nativeDisplay(), win->visual(), win->depth(), ZPixmap,
|
||||
0, (char *) image.scanLine(0), image.width(), image.height(),
|
||||
32, image.bytesPerLine());
|
||||
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
|
||||
/*int r =*/ XPutImage(screen->display(), window, gc, xi, 0, 0, x, y, image.width(), image.height());
|
||||
/*int r =*/ XPutImage(screen->display()->nativeDisplay(), window, gc, xi, 0, 0, x, y, image.width(), image.height());
|
||||
|
||||
xi->data = 0; // QImage owns these bits
|
||||
XDestroyImage(xi);
|
||||
|
|
@ -195,26 +195,15 @@ void QXlibWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPo
|
|||
#endif
|
||||
}
|
||||
|
||||
// from qwindowsurface.cpp
|
||||
extern void qt_scrollRectInImage(QImage &img, const QRect &rect, const QPoint &offset);
|
||||
|
||||
bool QXlibWindowSurface::scroll(const QRegion &area, int dx, int dy)
|
||||
void QXlibBackingStore::resize(const QSize &size, const QRegion &)
|
||||
{
|
||||
if (shm_img.isNull())
|
||||
return false;
|
||||
|
||||
const QVector<QRect> rects = area.rects();
|
||||
for (int i = 0; i < rects.size(); ++i)
|
||||
qt_scrollRectInImage(shm_img, rects.at(i), QPoint(dx, dy));
|
||||
|
||||
return true;
|
||||
resizeBuffer(size);
|
||||
}
|
||||
|
||||
|
||||
void QXlibWindowSurface::beginPaint(const QRegion ®ion)
|
||||
void QXlibBackingStore::beginPaint(const QRegion ®ion)
|
||||
{
|
||||
Q_UNUSED(region);
|
||||
resizeBuffer(size());
|
||||
|
||||
if (shm_img.hasAlphaChannel()) {
|
||||
QPainter p(&shm_img);
|
||||
|
|
@ -227,9 +216,8 @@ void QXlibWindowSurface::beginPaint(const QRegion ®ion)
|
|||
}
|
||||
}
|
||||
|
||||
void QXlibWindowSurface::endPaint(const QRegion ®ion)
|
||||
void QXlibBackingStore::endPaint()
|
||||
{
|
||||
Q_UNUSED(region);
|
||||
painted = true; //there is content in the buffer
|
||||
}
|
||||
QT_END_NAMESPACE
|
||||
|
|
@ -42,8 +42,8 @@
|
|||
#ifndef QWINDOWSURFACE_TESTLITE_H
|
||||
#define QWINDOWSURFACE_TESTLITE_H
|
||||
|
||||
#include <QtGui/private/qwindowsurface_p.h>
|
||||
|
||||
#include <QtGui/qplatformbackingstore_qpa.h>
|
||||
#include <QtGui/QImage>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
|
|
@ -52,18 +52,19 @@ class QXlibIntegration;
|
|||
class QXlibScreen;
|
||||
class QXlibShmImageInfo;
|
||||
|
||||
class QXlibWindowSurface : public QWindowSurface
|
||||
class QXlibBackingStore : public QPlatformBackingStore
|
||||
{
|
||||
public:
|
||||
QXlibWindowSurface (QWidget *window);
|
||||
~QXlibWindowSurface();
|
||||
QXlibBackingStore (QWindow *window);
|
||||
~QXlibBackingStore();
|
||||
|
||||
QPaintDevice *paintDevice();
|
||||
void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset);
|
||||
bool scroll(const QRegion &area, int dx, int dy);
|
||||
void flush(QWindow *window, const QRegion ®ion, const QPoint &offset);
|
||||
|
||||
void resize(const QSize &size, const QRegion &staticContents);
|
||||
|
||||
void beginPaint(const QRegion ®ion);
|
||||
void endPaint(const QRegion ®ion);
|
||||
void endPaint();
|
||||
|
||||
private:
|
||||
bool painted;
|
||||
|
|
@ -39,14 +39,14 @@
|
|||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <private/qguiapplication_p.h>
|
||||
|
||||
#include "qxlibclipboard.h"
|
||||
|
||||
#include "qxlibscreen.h"
|
||||
#include "qxlibmime.h"
|
||||
#include "qxlibdisplay.h"
|
||||
|
||||
#include <private/qapplication_p.h>
|
||||
|
||||
#include <QtCore/QDebug>
|
||||
|
||||
class QXlibClipboardMime : public QXlibMime
|
||||
|
|
|
|||
|
|
@ -57,12 +57,11 @@ QXlibCursor::QXlibCursor(QXlibScreen *screen)
|
|||
{
|
||||
}
|
||||
|
||||
void QXlibCursor::changeCursor(QCursor *cursor, QWidget *widget)
|
||||
void QXlibCursor::changeCursor(QCursor *cursor, QWindow *window)
|
||||
{
|
||||
QXlibWindow *w = 0;
|
||||
if (widget) {
|
||||
QWidget *window = widget->window();
|
||||
w = static_cast<QXlibWindow*>(window->platformWindow());
|
||||
if (window) {
|
||||
w = static_cast<QXlibWindow*>(window->handle());
|
||||
} else {
|
||||
// No X11 cursor control when there is no widget under the cursor
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ class QXlibCursor : QPlatformCursor
|
|||
public:
|
||||
QXlibCursor(QXlibScreen *screen);
|
||||
|
||||
void changeCursor(QCursor * cursor, QWidget * widget);
|
||||
void changeCursor(QCursor * cursor, QWindow * widget);
|
||||
private:
|
||||
|
||||
Cursor createCursorBitmap(QCursor * cursor);
|
||||
|
|
|
|||
|
|
@ -39,10 +39,13 @@
|
|||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <private/qguiapplication_p.h>
|
||||
#include "qxlibintegration.h"
|
||||
#include "qxlibwindowsurface.h"
|
||||
#include "qxlibbackingstore.h"
|
||||
#include <QtGui/private/qpixmap_raster_p.h>
|
||||
#include <QtCore/qdebug.h>
|
||||
#include <QtGui/qguiglcontext_qpa.h>
|
||||
#include <QtGui/qscreen.h>
|
||||
|
||||
#include "qxlibwindow.h"
|
||||
#include <QtPlatformSupport/private/qgenericunixeventdispatcher_p.h>
|
||||
|
|
@ -51,83 +54,49 @@
|
|||
#include "qxlibclipboard.h"
|
||||
#include "qxlibdisplay.h"
|
||||
#include "qxlibnativeinterface.h"
|
||||
|
||||
#if !defined(QT_NO_OPENGL)
|
||||
#if !defined(QT_OPENGL_ES_2)
|
||||
#include <GL/glx.h>
|
||||
#else
|
||||
#include <EGL/egl.h>
|
||||
#endif //!defined(QT_OPENGL_ES_2)
|
||||
#include <private/qwindowsurface_gl_p.h>
|
||||
#include <qplatformpixmap_gl_p.h>
|
||||
#endif //QT_NO_OPENGL
|
||||
#include "qglxintegration.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QXlibIntegration::QXlibIntegration(bool useOpenGL)
|
||||
: mUseOpenGL(useOpenGL)
|
||||
, mFontDb(new QGenericUnixFontDatabase())
|
||||
QXlibIntegration::QXlibIntegration()
|
||||
: mFontDb(new QGenericUnixFontDatabase())
|
||||
, mClipboard(0)
|
||||
, mNativeInterface(new QXlibNativeInterface)
|
||||
{
|
||||
mEventDispatcher = createUnixEventDispatcher();
|
||||
QGuiApplicationPrivate::instance()->setEventDispatcher(mEventDispatcher);
|
||||
|
||||
mPrimaryScreen = new QXlibScreen();
|
||||
mScreens.append(mPrimaryScreen);
|
||||
screenAdded(mPrimaryScreen);
|
||||
}
|
||||
|
||||
bool QXlibIntegration::hasCapability(QPlatformIntegration::Capability cap) const
|
||||
bool QXlibIntegration::hasCapability(QPlatformIntegration::Capability) const
|
||||
{
|
||||
switch (cap) {
|
||||
case ThreadedPixmaps: return true;
|
||||
case OpenGL: return hasOpenGL();
|
||||
default: return QPlatformIntegration::hasCapability(cap);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
QPlatformPixmap *QXlibIntegration::createPlatformPixmap(QPlatformPixmap::PixelType type) const
|
||||
QPlatformBackingStore *QXlibIntegration::createPlatformBackingStore(QWindow *window) const
|
||||
{
|
||||
#ifndef QT_NO_OPENGL
|
||||
if (mUseOpenGL)
|
||||
return new QGLPlatformPixmap(type);
|
||||
#endif
|
||||
return new QRasterPlatformPixmap(type);
|
||||
return new QXlibBackingStore(window);
|
||||
}
|
||||
|
||||
QWindowSurface *QXlibIntegration::createWindowSurface(QWidget *widget, WId) const
|
||||
QPlatformGLContext *QXlibIntegration::createPlatformGLContext(QGuiGLContext *context) const
|
||||
{
|
||||
#ifndef QT_NO_OPENGL
|
||||
if (mUseOpenGL)
|
||||
return new QGLWindowSurface(widget);
|
||||
#endif
|
||||
return new QXlibWindowSurface(widget);
|
||||
QXlibScreen *screen = static_cast<QXlibScreen *>(context->screen()->handle());
|
||||
|
||||
return new QGLXContext(screen, context->format(), context->shareHandle());
|
||||
}
|
||||
|
||||
|
||||
QPlatformWindow *QXlibIntegration::createPlatformWindow(QWidget *widget, WId /*winId*/) const
|
||||
QPlatformWindow *QXlibIntegration::createPlatformWindow(QWindow *window) const
|
||||
{
|
||||
return new QXlibWindow(widget);
|
||||
return new QXlibWindow(window);
|
||||
}
|
||||
|
||||
QAbstractEventDispatcher *QXlibIntegration::createEventDispatcher() const
|
||||
QAbstractEventDispatcher *QXlibIntegration::guiThreadEventDispatcher() const
|
||||
{
|
||||
return createUnixEventDispatcher();
|
||||
}
|
||||
|
||||
QPixmap QXlibIntegration::grabWindow(WId window, int x, int y, int width, int height) const
|
||||
{
|
||||
QImage image;
|
||||
QWidget *widget = QWidget::find(window);
|
||||
if (widget) {
|
||||
QXlibScreen *screen = QXlibScreen::testLiteScreenForWidget(widget);
|
||||
image = screen->grabWindow(window,x,y,width,height);
|
||||
} else {
|
||||
for (int i = 0; i < mScreens.size(); i++) {
|
||||
QXlibScreen *screen = static_cast<QXlibScreen *>(mScreens[i]);
|
||||
if (screen->rootWindow() == window) {
|
||||
image = screen->grabWindow(window,x,y,width,height);
|
||||
}
|
||||
}
|
||||
}
|
||||
return QPixmap::fromImage(image);
|
||||
return mEventDispatcher;
|
||||
}
|
||||
|
||||
QPlatformFontDatabase *QXlibIntegration::fontDatabase() const
|
||||
|
|
@ -150,28 +119,4 @@ QPlatformNativeInterface * QXlibIntegration::nativeInterface() const
|
|||
return mNativeInterface;
|
||||
}
|
||||
|
||||
bool QXlibIntegration::hasOpenGL() const
|
||||
{
|
||||
#if !defined(QT_NO_OPENGL)
|
||||
#if !defined(QT_OPENGL_ES_2)
|
||||
QXlibScreen *screen = static_cast<QXlibScreen *>(mScreens.at(0));
|
||||
return glXQueryExtension(screen->display()->nativeDisplay(), 0, 0) != 0;
|
||||
#else
|
||||
static bool eglHasbeenInitialized = false;
|
||||
static bool wasEglInitialized = false;
|
||||
if (!eglHasbeenInitialized) {
|
||||
eglHasbeenInitialized = true;
|
||||
QXlibScreen *screen = static_cast<QXlibScreen *>(mScreens.at(0));
|
||||
EGLint major, minor;
|
||||
eglBindAPI(EGL_OPENGL_ES_API);
|
||||
EGLDisplay disp = eglGetDisplay(screen->display()->nativeDisplay());
|
||||
wasEglInitialized = eglInitialize(disp,&major,&minor);
|
||||
screen->setEglDisplay(disp);
|
||||
}
|
||||
return wasEglInitialized;
|
||||
#endif
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -58,13 +58,15 @@ class QXlibScreen;
|
|||
class QXlibIntegration : public QPlatformIntegration
|
||||
{
|
||||
public:
|
||||
QXlibIntegration(bool useOpenGL = false);
|
||||
QXlibIntegration();
|
||||
|
||||
bool hasCapability(Capability cap) const;
|
||||
QPlatformPixmap *createPlatformPixmap(QPlatformPixmap::PixelType type) const;
|
||||
QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId) const;
|
||||
QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const;
|
||||
QAbstractEventDispatcher *createEventDispatcher() const;
|
||||
|
||||
QPlatformWindow *createPlatformWindow(QWindow *window) const;
|
||||
QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const;
|
||||
QPlatformGLContext *createPlatformGLContext(QGuiGLContext *context) const;
|
||||
|
||||
QAbstractEventDispatcher *guiThreadEventDispatcher() const;
|
||||
|
||||
QPixmap grabWindow(WId window, int x, int y, int width, int height) const;
|
||||
|
||||
|
|
@ -76,14 +78,12 @@ public:
|
|||
QPlatformNativeInterface *nativeInterface() const;
|
||||
|
||||
private:
|
||||
bool hasOpenGL() const;
|
||||
|
||||
bool mUseOpenGL;
|
||||
QXlibScreen *mPrimaryScreen;
|
||||
QList<QPlatformScreen *> mScreens;
|
||||
QPlatformFontDatabase *mFontDb;
|
||||
QPlatformClipboard *mClipboard;
|
||||
QPlatformNativeInterface *mNativeInterface;
|
||||
QAbstractEventDispatcher *mEventDispatcher;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -987,7 +987,7 @@ static Qt::KeyboardModifiers modifierFromKeyCode(int qtcode)
|
|||
}
|
||||
}
|
||||
|
||||
void QXlibKeyboard::handleKeyEvent(QWidget *widget, QEvent::Type type, XKeyEvent *ev)
|
||||
void QXlibKeyboard::handleKeyEvent(QWindow *widget, QEvent::Type type, XKeyEvent *ev)
|
||||
{
|
||||
int qtcode = 0;
|
||||
Qt::KeyboardModifiers modifiers = translateModifiers(ev->state);
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ public:
|
|||
|
||||
void changeLayout();
|
||||
|
||||
void handleKeyEvent(QWidget *widget, QEvent::Type type, XKeyEvent *ev);
|
||||
void handleKeyEvent(QWindow *widget, QEvent::Type type, XKeyEvent *ev);
|
||||
|
||||
Qt::KeyboardModifiers translateModifiers(int s);
|
||||
|
||||
|
|
|
|||
|
|
@ -39,10 +39,11 @@
|
|||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <private/qguiapplication_p.h>
|
||||
#include "qxlibnativeinterface.h"
|
||||
|
||||
#include "qxlibdisplay.h"
|
||||
#include <QtGui/private/qapplication_p.h>
|
||||
#include "qscreen.h"
|
||||
|
||||
class QXlibResourceMap : public QMap<QByteArray, QXlibNativeInterface::ResourceType>
|
||||
{
|
||||
|
|
@ -62,7 +63,7 @@ public:
|
|||
Q_GLOBAL_STATIC(QXlibResourceMap, qXlibResourceMap)
|
||||
|
||||
|
||||
void * QXlibNativeInterface::nativeResourceForWidget(const QByteArray &resourceString, QWidget *widget)
|
||||
void * QXlibNativeInterface::nativeResourceForWidget(const QByteArray &resourceString, QWindow *widget)
|
||||
{
|
||||
QByteArray lowerCaseResource = resourceString.toLower();
|
||||
ResourceType resource = qXlibResourceMap()->value(lowerCaseResource);
|
||||
|
|
@ -92,42 +93,37 @@ void * QXlibNativeInterface::nativeResourceForWidget(const QByteArray &resourceS
|
|||
return result;
|
||||
}
|
||||
|
||||
void * QXlibNativeInterface::displayForWidget(QWidget *widget)
|
||||
void * QXlibNativeInterface::displayForWidget(QWindow *widget)
|
||||
{
|
||||
return qPlatformScreenForWidget(widget)->display()->nativeDisplay();
|
||||
}
|
||||
|
||||
void * QXlibNativeInterface::eglDisplayForWidget(QWidget *widget)
|
||||
void * QXlibNativeInterface::eglDisplayForWidget(QWindow *widget)
|
||||
{
|
||||
Q_UNUSED(widget);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void * QXlibNativeInterface::screenForWidget(QWidget *widget)
|
||||
void * QXlibNativeInterface::screenForWidget(QWindow *widget)
|
||||
{
|
||||
Q_UNUSED(widget);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void * QXlibNativeInterface::graphicsDeviceForWidget(QWidget *widget)
|
||||
void * QXlibNativeInterface::graphicsDeviceForWidget(QWindow *widget)
|
||||
{
|
||||
Q_UNUSED(widget);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void * QXlibNativeInterface::eglContextForWidget(QWidget *widget)
|
||||
void * QXlibNativeInterface::eglContextForWidget(QWindow *widget)
|
||||
{
|
||||
Q_UNUSED(widget);
|
||||
return 0;
|
||||
}
|
||||
|
||||
QXlibScreen * QXlibNativeInterface::qPlatformScreenForWidget(QWidget *widget)
|
||||
QXlibScreen * QXlibNativeInterface::qPlatformScreenForWidget(QWindow *widget)
|
||||
{
|
||||
QXlibScreen *screen;
|
||||
if (widget) {
|
||||
screen = static_cast<QXlibScreen *>(QPlatformScreen::platformScreenForWidget(widget));
|
||||
}else {
|
||||
screen = static_cast<QXlibScreen *>(QApplicationPrivate::platformIntegration()->screens()[0]);
|
||||
}
|
||||
return screen;
|
||||
QScreen *screen = widget ? widget->screen() : QGuiApplication::primaryScreen();
|
||||
return static_cast<QXlibScreen *>(screen->handle());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,17 +58,17 @@ public:
|
|||
EglContext
|
||||
};
|
||||
|
||||
void *nativeResourceForWidget(const QByteArray &resourceString, QWidget *widget);
|
||||
void *nativeResourceForWidget(const QByteArray &resourceString, QWindow *widget);
|
||||
|
||||
void *displayForWidget(QWidget *widget);
|
||||
void *eglDisplayForWidget(QWidget *widget);
|
||||
void *connectionForWidget(QWidget *widget);
|
||||
void *screenForWidget(QWidget *widget);
|
||||
void *graphicsDeviceForWidget(QWidget *widget);
|
||||
void *eglContextForWidget(QWidget *widget);
|
||||
void *displayForWidget(QWindow *widget);
|
||||
void *eglDisplayForWidget(QWindow *widget);
|
||||
void *connectionForWidget(QWindow *widget);
|
||||
void *screenForWidget(QWindow *widget);
|
||||
void *graphicsDeviceForWidget(QWindow *widget);
|
||||
void *eglContextForWidget(QWindow *widget);
|
||||
|
||||
private:
|
||||
static QXlibScreen *qPlatformScreenForWidget(QWidget *widget);
|
||||
static QXlibScreen *qPlatformScreenForWidget(QWindow *widget);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@
|
|||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <private/qguiapplication_p.h>
|
||||
#include "qxlibscreen.h"
|
||||
|
||||
#include <X11/extensions/Xfixes.h>
|
||||
|
|
@ -54,7 +55,7 @@
|
|||
#include <QtCore/QSocketNotifier>
|
||||
#include <QtCore/QElapsedTimer>
|
||||
|
||||
#include <private/qapplication_p.h>
|
||||
#include <QtGui/QScreen>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
|
|
@ -263,11 +264,9 @@ unsigned long QXlibScreen::whitePixel()
|
|||
bool QXlibScreen::handleEvent(XEvent *xe)
|
||||
{
|
||||
int quit = false;
|
||||
QXlibWindow *platformWindow = 0;
|
||||
QWidget *widget = QWidget::find(xe->xany.window);
|
||||
if (widget) {
|
||||
platformWindow = static_cast<QXlibWindow *>(widget->platformWindow());
|
||||
}
|
||||
QXlibWindow *platformWindow = QXlibWindow::platformWindowForXWindow(xe->xany.window);
|
||||
if (!platformWindow)
|
||||
return false;
|
||||
|
||||
Atom wmProtocolsAtom = QXlibStatic::atom(QXlibStatic::WM_PROTOCOLS);
|
||||
Atom wmDeleteWindowAtom = QXlibStatic::atom(QXlibStatic::WM_DELETE_WINDOW);
|
||||
|
|
@ -282,56 +281,48 @@ bool QXlibScreen::handleEvent(XEvent *xe)
|
|||
break;
|
||||
|
||||
case Expose:
|
||||
if (platformWindow)
|
||||
if (xe->xexpose.count == 0)
|
||||
platformWindow->paintEvent();
|
||||
// ###
|
||||
// if (xe->xexpose.count == 0)
|
||||
// platformWindow->paintEvent();
|
||||
break;
|
||||
case ConfigureNotify:
|
||||
if (platformWindow)
|
||||
platformWindow->resizeEvent(&xe->xconfigure);
|
||||
platformWindow->resizeEvent(&xe->xconfigure);
|
||||
break;
|
||||
|
||||
case ButtonPress:
|
||||
if (platformWindow)
|
||||
platformWindow->mousePressEvent(&xe->xbutton);
|
||||
platformWindow->mousePressEvent(&xe->xbutton);
|
||||
break;
|
||||
|
||||
case ButtonRelease:
|
||||
if (platformWindow)
|
||||
platformWindow->handleMouseEvent(QEvent::MouseButtonRelease, &xe->xbutton);
|
||||
platformWindow->handleMouseEvent(QEvent::MouseButtonRelease, &xe->xbutton);
|
||||
break;
|
||||
|
||||
case MotionNotify:
|
||||
if (platformWindow)
|
||||
platformWindow->handleMouseEvent(QEvent::MouseMove, &xe->xbutton);
|
||||
platformWindow->handleMouseEvent(QEvent::MouseMove, &xe->xbutton);
|
||||
break;
|
||||
|
||||
case XKeyPress:
|
||||
mKeyboard->handleKeyEvent(widget,QEvent::KeyPress, &xe->xkey);
|
||||
case XKeyPress:
|
||||
mKeyboard->handleKeyEvent(platformWindow->window(), QEvent::KeyPress, &xe->xkey);
|
||||
break;
|
||||
|
||||
case XKeyRelease:
|
||||
mKeyboard->handleKeyEvent(widget,QEvent::KeyRelease, &xe->xkey);
|
||||
mKeyboard->handleKeyEvent(platformWindow->window(), QEvent::KeyRelease, &xe->xkey);
|
||||
break;
|
||||
|
||||
case EnterNotify:
|
||||
if (platformWindow)
|
||||
platformWindow->handleEnterEvent();
|
||||
platformWindow->handleEnterEvent();
|
||||
break;
|
||||
|
||||
case LeaveNotify:
|
||||
if (platformWindow)
|
||||
platformWindow->handleLeaveEvent();
|
||||
platformWindow->handleLeaveEvent();
|
||||
break;
|
||||
|
||||
case XFocusIn:
|
||||
if (platformWindow)
|
||||
platformWindow->handleFocusInEvent();
|
||||
platformWindow->handleFocusInEvent();
|
||||
break;
|
||||
|
||||
case XFocusOut:
|
||||
if (platformWindow)
|
||||
platformWindow->handleFocusOutEvent();
|
||||
platformWindow->handleFocusOutEvent();
|
||||
break;
|
||||
|
||||
case PropertyNotify:
|
||||
|
|
@ -452,10 +443,9 @@ QImage QXlibScreen::grabWindow(Window window, int x, int y, int w, int h)
|
|||
return result;
|
||||
}
|
||||
|
||||
QXlibScreen * QXlibScreen::testLiteScreenForWidget(QWidget *widget)
|
||||
QXlibScreen * QXlibScreen::testLiteScreenForWidget(QWindow *widget)
|
||||
{
|
||||
QPlatformScreen *platformScreen = platformScreenForWidget(widget);
|
||||
return static_cast<QXlibScreen *>(platformScreen);
|
||||
return static_cast<QXlibScreen *>(widget->screen()->handle());
|
||||
}
|
||||
|
||||
QXlibDisplay * QXlibScreen::display() const
|
||||
|
|
@ -480,7 +470,7 @@ QXlibKeyboard * QXlibScreen::keyboard() const
|
|||
|
||||
void QXlibScreen::handleSelectionRequest(XEvent *event)
|
||||
{
|
||||
QPlatformIntegration *integration = QApplicationPrivate::platformIntegration();
|
||||
QPlatformIntegration *integration = QGuiApplicationPrivate::platformIntegration();
|
||||
QXlibClipboard *clipboard = static_cast<QXlibClipboard *>(integration->clipboard());
|
||||
clipboard->handleSelectionRequest(event);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ class QXlibCursor;
|
|||
class QXlibKeyboard;
|
||||
class QXlibDisplay;
|
||||
|
||||
class QXlibScreen : public QPlatformScreen
|
||||
class QXlibScreen : public QObject, public QPlatformScreen
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
|
@ -73,7 +73,7 @@ public:
|
|||
|
||||
QImage grabWindow(Window window, int x, int y, int w, int h);
|
||||
|
||||
static QXlibScreen *testLiteScreenForWidget(QWidget *widget);
|
||||
static QXlibScreen *testLiteScreenForWidget(QWindow *widget);
|
||||
|
||||
QXlibDisplay *display() const;
|
||||
int xScreenNumber() const;
|
||||
|
|
|
|||
|
|
@ -39,13 +39,14 @@
|
|||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <private/qguiapplication_p.h>
|
||||
#include "qxlibstatic.h"
|
||||
#include "qxlibscreen.h"
|
||||
#include "qxlibdisplay.h"
|
||||
|
||||
#include <qplatformdefs.h>
|
||||
#include <QtGui/qscreen.h>
|
||||
|
||||
#include <QtGui/private/qapplication_p.h>
|
||||
#include <QtCore/QBuffer>
|
||||
#include <QtCore/QLibrary>
|
||||
|
||||
|
|
@ -258,7 +259,7 @@ public:
|
|||
, xfixes_eventbase(0)
|
||||
, xfixes_errorbase(0)
|
||||
{
|
||||
QXlibScreen *screen = qobject_cast<QXlibScreen *> (QApplicationPrivate::platformIntegration()->screens().at(0));
|
||||
QXlibScreen *screen = static_cast<QXlibScreen *> (QGuiApplication::primaryScreen()->handle());
|
||||
Q_ASSERT(screen);
|
||||
|
||||
initializeAllAtoms(screen);
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@
|
|||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QtGui/private/qguiapplication_p.h>
|
||||
#include "qxlibwindow.h"
|
||||
|
||||
#include "qxlibintegration.h"
|
||||
|
|
@ -50,7 +51,7 @@
|
|||
#if !defined(QT_NO_OPENGL)
|
||||
#if !defined(QT_OPENGL_ES_2)
|
||||
#include "qglxintegration.h"
|
||||
#include "qglxconvenience.h"
|
||||
#include "private/qglxconvenience_p.h"
|
||||
#else
|
||||
#include "../eglconvenience/qeglconvenience.h"
|
||||
#include "../eglconvenience/qeglplatformcontext.h"
|
||||
|
|
@ -64,14 +65,14 @@
|
|||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
|
||||
#include <QtGui/private/qwindowsurface_p.h>
|
||||
#include <QtGui/private/qapplication_p.h>
|
||||
|
||||
//#define MYX11_DEBUG
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QXlibWindow::QXlibWindow(QWidget *window)
|
||||
QHash<Window, QXlibWindow *> QXlibWindow::windowMap;
|
||||
|
||||
|
||||
QXlibWindow::QXlibWindow(QWindow *window)
|
||||
: QPlatformWindow(window)
|
||||
, mGLContext(0)
|
||||
, mScreen(QXlibScreen::testLiteScreenForWidget(window))
|
||||
|
|
@ -82,11 +83,10 @@ QXlibWindow::QXlibWindow(QWidget *window)
|
|||
int h = window->height();
|
||||
|
||||
#if !defined(QT_NO_OPENGL)
|
||||
if(window->platformWindowFormat().windowApi() == QPlatformWindowFormat::OpenGL
|
||||
&& QApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL)
|
||||
|| window->platformWindowFormat().alpha()) {
|
||||
if(window->surfaceType() == QWindow::OpenGLSurface) {
|
||||
#if !defined(QT_OPENGL_ES_2)
|
||||
XVisualInfo *visualInfo = qglx_findVisualInfo(mScreen->display()->nativeDisplay(),mScreen->xScreenNumber(),window->platformWindowFormat());
|
||||
XVisualInfo *visualInfo = qglx_findVisualInfo(mScreen->display()->nativeDisplay(), mScreen->xScreenNumber(),
|
||||
window->format());
|
||||
#else
|
||||
QPlatformWindowFormat windowFormat = correctColorBuffers(window->platformWindowFormat());
|
||||
|
||||
|
|
@ -156,6 +156,8 @@ QXlibWindow::QXlibWindow(QWidget *window)
|
|||
if (window->windowFlags() & Qt::WindowContextHelpButtonHint)
|
||||
protocols[n++] = QXlibStatic::atom(QXlibStatic::_NET_WM_CONTEXT_HELP);
|
||||
XSetWMProtocols(mScreen->display()->nativeDisplay(), x_window, protocols, n);
|
||||
|
||||
windowMap.insert(x_window, this);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -165,6 +167,9 @@ QXlibWindow::~QXlibWindow()
|
|||
#ifdef MYX11_DEBUG
|
||||
qDebug() << "~QTestLiteWindow" << hex << x_window;
|
||||
#endif
|
||||
|
||||
windowMap.remove(x_window);
|
||||
|
||||
delete mGLContext;
|
||||
XFreeGC(mScreen->display()->nativeDisplay(), gc);
|
||||
XDestroyWindow(mScreen->display()->nativeDisplay(), x_window);
|
||||
|
|
@ -209,7 +214,7 @@ void QXlibWindow::handleMouseEvent(QEvent::Type type, XButtonEvent *e)
|
|||
bool hor = (((e->button == Button4 || e->button == Button5)
|
||||
&& (modifiers & Qt::AltModifier))
|
||||
|| (e->button == 6 || e->button == 7));
|
||||
QWindowSystemInterface::handleWheelEvent(widget(), e->time,
|
||||
QWindowSystemInterface::handleWheelEvent(window(), e->time,
|
||||
QPoint(e->x, e->y),
|
||||
QPoint(e->x_root, e->y_root),
|
||||
delta, hor ? Qt::Horizontal : Qt::Vertical);
|
||||
|
|
@ -222,7 +227,7 @@ void QXlibWindow::handleMouseEvent(QEvent::Type type, XButtonEvent *e)
|
|||
|
||||
buttons ^= button; // X event uses state *before*, Qt uses state *after*
|
||||
|
||||
QWindowSystemInterface::handleMouseEvent(widget(), e->time, QPoint(e->x, e->y),
|
||||
QWindowSystemInterface::handleMouseEvent(window(), e->time, QPoint(e->x, e->y),
|
||||
QPoint(e->x_root, e->y_root),
|
||||
buttons);
|
||||
|
||||
|
|
@ -231,23 +236,23 @@ void QXlibWindow::handleMouseEvent(QEvent::Type type, XButtonEvent *e)
|
|||
|
||||
void QXlibWindow::handleCloseEvent()
|
||||
{
|
||||
QWindowSystemInterface::handleCloseEvent(widget());
|
||||
QWindowSystemInterface::handleCloseEvent(window());
|
||||
}
|
||||
|
||||
|
||||
void QXlibWindow::handleEnterEvent()
|
||||
{
|
||||
QWindowSystemInterface::handleEnterEvent(widget());
|
||||
QWindowSystemInterface::handleEnterEvent(window());
|
||||
}
|
||||
|
||||
void QXlibWindow::handleLeaveEvent()
|
||||
{
|
||||
QWindowSystemInterface::handleLeaveEvent(widget());
|
||||
QWindowSystemInterface::handleLeaveEvent(window());
|
||||
}
|
||||
|
||||
void QXlibWindow::handleFocusInEvent()
|
||||
{
|
||||
QWindowSystemInterface::handleWindowActivated(widget());
|
||||
QWindowSystemInterface::handleWindowActivated(window());
|
||||
}
|
||||
|
||||
void QXlibWindow::handleFocusOutEvent()
|
||||
|
|
@ -313,16 +318,6 @@ GC QXlibWindow::createGC()
|
|||
return gc;
|
||||
}
|
||||
|
||||
void QXlibWindow::paintEvent()
|
||||
{
|
||||
#ifdef MYX11_DEBUG
|
||||
// qDebug() << "QTestLiteWindow::paintEvent" << shm_img.size() << painted;
|
||||
#endif
|
||||
|
||||
if (QWindowSurface *surface = widget()->windowSurface())
|
||||
surface->flush(widget(), widget()->geometry(), QPoint());
|
||||
}
|
||||
|
||||
void QXlibWindow::requestActivateWindow()
|
||||
{
|
||||
XSetInputFocus(mScreen->display()->nativeDisplay(), x_window, XRevertToParent, CurrentTime);
|
||||
|
|
@ -340,11 +335,12 @@ void QXlibWindow::resizeEvent(XConfigureEvent *e)
|
|||
ypos = e->y;
|
||||
}
|
||||
#ifdef MYX11_DEBUG
|
||||
qDebug() << hex << x_window << dec << "ConfigureNotify" << e->x << e->y << e->width << e->height << "geometry" << xpos << ypos << width << height;
|
||||
qDebug() << hex << x_window << dec << "ConfigureNotify" << e->x << e->y << e->width << e->height <<
|
||||
"geometry" << xpos << ypos << e->width << e->height;
|
||||
#endif
|
||||
|
||||
QRect newRect(xpos, ypos, e->width, e->height);
|
||||
QWindowSystemInterface::handleGeometryChange(widget(), newRect);
|
||||
QWindowSystemInterface::handleGeometryChange(window(), newRect);
|
||||
}
|
||||
|
||||
void QXlibWindow::mousePressEvent(XButtonEvent *e)
|
||||
|
|
@ -413,16 +409,15 @@ void QXlibWindow::setMWMHints(const QXlibMWMHints &mwmhints)
|
|||
}
|
||||
|
||||
// Returns true if we should set WM_TRANSIENT_FOR on \a w
|
||||
static inline bool isTransient(const QWidget *w)
|
||||
static inline bool isTransient(const QWindow *w)
|
||||
{
|
||||
return ((w->windowType() == Qt::Dialog
|
||||
return (w->windowType() == Qt::Dialog
|
||||
|| w->windowType() == Qt::Sheet
|
||||
|| w->windowType() == Qt::Tool
|
||||
|| w->windowType() == Qt::SplashScreen
|
||||
|| w->windowType() == Qt::ToolTip
|
||||
|| w->windowType() == Qt::Drawer
|
||||
|| w->windowType() == Qt::Popup)
|
||||
&& !w->testAttribute(Qt::WA_X11BypassTransientForHint));
|
||||
|| w->windowType() == Qt::Popup);
|
||||
}
|
||||
|
||||
QVector<Atom> QXlibWindow::getNetWmState() const
|
||||
|
|
@ -568,9 +563,9 @@ Qt::WindowFlags QXlibWindow::setWindowFlags(Qt::WindowFlags flags)
|
|||
mwmhints.decorations = 0;
|
||||
}
|
||||
|
||||
if (widget()->windowModality() == Qt::WindowModal) {
|
||||
if (window()->windowModality() == Qt::WindowModal) {
|
||||
mwmhints.input_mode = MWM_INPUT_PRIMARY_APPLICATION_MODAL;
|
||||
} else if (widget()->windowModality() == Qt::ApplicationModal) {
|
||||
} else if (window()->windowModality() == Qt::ApplicationModal) {
|
||||
mwmhints.input_mode = MWM_INPUT_FULL_APPLICATION_MODAL;
|
||||
}
|
||||
|
||||
|
|
@ -580,7 +575,7 @@ Qt::WindowFlags QXlibWindow::setWindowFlags(Qt::WindowFlags flags)
|
|||
|
||||
if (flags & Qt::WindowStaysOnTopHint) {
|
||||
if (flags & Qt::WindowStaysOnBottomHint)
|
||||
qWarning() << "QWidget: Incompatible window flags: the window can't be on top and on bottom at the same time";
|
||||
qWarning() << "QWindow: Incompatible window flags: the window can't be on top and on bottom at the same time";
|
||||
if (!netWmState.contains(QXlibStatic::atom(QXlibStatic::_NET_WM_STATE_ABOVE)))
|
||||
netWmState.append(QXlibStatic::atom(QXlibStatic::_NET_WM_STATE_ABOVE));
|
||||
if (!netWmState.contains(QXlibStatic::atom(QXlibStatic::_NET_WM_STATE_STAYS_ON_TOP)))
|
||||
|
|
@ -589,17 +584,17 @@ Qt::WindowFlags QXlibWindow::setWindowFlags(Qt::WindowFlags flags)
|
|||
if (!netWmState.contains(QXlibStatic::atom(QXlibStatic::_NET_WM_STATE_BELOW)))
|
||||
netWmState.append(QXlibStatic::atom(QXlibStatic::_NET_WM_STATE_BELOW));
|
||||
}
|
||||
if (widget()->isFullScreen()) {
|
||||
if (window()->windowState() & Qt::WindowFullScreen) {
|
||||
if (!netWmState.contains(QXlibStatic::atom(QXlibStatic::_NET_WM_STATE_FULLSCREEN)))
|
||||
netWmState.append(QXlibStatic::atom(QXlibStatic::_NET_WM_STATE_FULLSCREEN));
|
||||
}
|
||||
if (widget()->isMaximized()) {
|
||||
if (window()->windowState() & Qt::WindowMaximized) {
|
||||
if (!netWmState.contains(QXlibStatic::atom(QXlibStatic::_NET_WM_STATE_MAXIMIZED_HORZ)))
|
||||
netWmState.append(QXlibStatic::atom(QXlibStatic::_NET_WM_STATE_MAXIMIZED_HORZ));
|
||||
if (!netWmState.contains(QXlibStatic::atom(QXlibStatic::_NET_WM_STATE_MAXIMIZED_VERT)))
|
||||
netWmState.append(QXlibStatic::atom(QXlibStatic::_NET_WM_STATE_MAXIMIZED_VERT));
|
||||
}
|
||||
if (widget()->windowModality() != Qt::NonModal) {
|
||||
if (window()->windowModality() != Qt::NonModal) {
|
||||
if (!netWmState.contains(QXlibStatic::atom(QXlibStatic::_NET_WM_STATE_MODAL)))
|
||||
netWmState.append(QXlibStatic::atom(QXlibStatic::_NET_WM_STATE_MODAL));
|
||||
}
|
||||
|
|
@ -634,24 +629,29 @@ Qt::WindowFlags QXlibWindow::setWindowFlags(Qt::WindowFlags flags)
|
|||
return flags;
|
||||
}
|
||||
|
||||
Qt::WindowState QXlibWindow::setWindowState(Qt::WindowState state)
|
||||
{
|
||||
// ####
|
||||
return state;
|
||||
}
|
||||
|
||||
void QXlibWindow::setVisible(bool visible)
|
||||
{
|
||||
#ifdef MYX11_DEBUG
|
||||
qDebug() << "QTestLiteWindow::setVisible" << visible << hex << x_window;
|
||||
#endif
|
||||
if (isTransient(widget())) {
|
||||
if (isTransient(window())) {
|
||||
Window parentXWindow = x_window;
|
||||
if (widget()->parentWidget()) {
|
||||
QWidget *widgetParent = widget()->parentWidget()->window();
|
||||
if (widgetParent && widgetParent->platformWindow()) {
|
||||
QXlibWindow *parentWidnow = static_cast<QXlibWindow *>(widgetParent->platformWindow());
|
||||
parentXWindow = parentWidnow->x_window;
|
||||
}
|
||||
QWindow *parent = window()->parent();
|
||||
if (parent && parent->handle()) {
|
||||
QXlibWindow *xlibParent = static_cast<QXlibWindow *>(parent->handle());
|
||||
parentXWindow = xlibParent->x_window;
|
||||
}
|
||||
XSetTransientForHint(mScreen->display()->nativeDisplay(),x_window,parentXWindow);
|
||||
}
|
||||
|
||||
if (visible) {
|
||||
qDebug() << ">>> mapping";
|
||||
//ensure that the window is viewed in correct position.
|
||||
doSizeHints();
|
||||
XMapWindow(mScreen->display()->nativeDisplay(), x_window);
|
||||
|
|
@ -666,34 +666,12 @@ void QXlibWindow::setCursor(const Cursor &cursor)
|
|||
mScreen->display()->flush();
|
||||
}
|
||||
|
||||
QPlatformGLContext *QXlibWindow::glContext() const
|
||||
QSurfaceFormat QXlibWindow::format() const
|
||||
{
|
||||
if (!QApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL))
|
||||
return 0;
|
||||
if (!mGLContext) {
|
||||
QXlibWindow *that = const_cast<QXlibWindow *>(this);
|
||||
#if !defined(QT_NO_OPENGL)
|
||||
#if !defined(QT_OPENGL_ES_2)
|
||||
that->mGLContext = new QGLXContext(x_window, mScreen,widget()->platformWindowFormat());
|
||||
#else
|
||||
EGLDisplay display = mScreen->eglDisplay();
|
||||
|
||||
QPlatformWindowFormat windowFormat = correctColorBuffers(widget()->platformWindowFormat());
|
||||
|
||||
EGLConfig config = q_configFromQPlatformWindowFormat(display,windowFormat);
|
||||
QVector<EGLint> eglContextAttrs;
|
||||
eglContextAttrs.append(EGL_CONTEXT_CLIENT_VERSION);
|
||||
eglContextAttrs.append(2);
|
||||
eglContextAttrs.append(EGL_NONE);
|
||||
|
||||
EGLSurface eglSurface = eglCreateWindowSurface(display,config,(EGLNativeWindowType)x_window,0);
|
||||
that->mGLContext = new QEGLPlatformContext(display, config, eglContextAttrs.data(), eglSurface, EGL_OPENGL_ES_API);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
return mGLContext;
|
||||
return window()->format();
|
||||
}
|
||||
|
||||
|
||||
Window QXlibWindow::xWindow() const
|
||||
{
|
||||
return x_window;
|
||||
|
|
@ -706,7 +684,7 @@ GC QXlibWindow::graphicsContext() const
|
|||
|
||||
void QXlibWindow::doSizeHints()
|
||||
{
|
||||
Q_ASSERT(widget()->testAttribute(Qt::WA_WState_Created));
|
||||
// Q_ASSERT(window()->testAttribute(Qt::WA_WState_Created));
|
||||
XSizeHints s;
|
||||
s.flags = 0;
|
||||
QRect g = geometry();
|
||||
|
|
@ -723,27 +701,10 @@ void QXlibWindow::doSizeHints()
|
|||
XSetWMNormalHints(mScreen->display()->nativeDisplay(), x_window, &s);
|
||||
}
|
||||
|
||||
QPlatformWindowFormat QXlibWindow::correctColorBuffers(const QPlatformWindowFormat &platformWindowFormat) const
|
||||
|
||||
QXlibWindow *QXlibWindow::platformWindowForXWindow(Window window)
|
||||
{
|
||||
// I have only tested this setup on a dodgy intel setup, where I didn't use standard libs,
|
||||
// so this might be not what we want to do :)
|
||||
if ( !(platformWindowFormat.redBufferSize() == -1 &&
|
||||
platformWindowFormat.greenBufferSize() == -1 &&
|
||||
platformWindowFormat.blueBufferSize() == -1))
|
||||
return platformWindowFormat;
|
||||
|
||||
QPlatformWindowFormat windowFormat = platformWindowFormat;
|
||||
if (mScreen->depth() == 16) {
|
||||
windowFormat.setRedBufferSize(5);
|
||||
windowFormat.setGreenBufferSize(6);
|
||||
windowFormat.setBlueBufferSize(5);
|
||||
} else {
|
||||
windowFormat.setRedBufferSize(8);
|
||||
windowFormat.setGreenBufferSize(8);
|
||||
windowFormat.setBlueBufferSize(8);
|
||||
}
|
||||
|
||||
return windowFormat;
|
||||
return windowMap.value(window);
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@
|
|||
|
||||
#include <QObject>
|
||||
#include <QImage>
|
||||
#include <QHash>
|
||||
|
||||
struct QXlibMWMHints {
|
||||
ulong flags, functions, decorations;
|
||||
|
|
@ -86,7 +87,7 @@ enum {
|
|||
class QXlibWindow : public QPlatformWindow
|
||||
{
|
||||
public:
|
||||
QXlibWindow(QWidget *window);
|
||||
QXlibWindow(QWindow *window);
|
||||
~QXlibWindow();
|
||||
|
||||
|
||||
|
|
@ -100,7 +101,6 @@ public:
|
|||
void handleFocusOutEvent();
|
||||
|
||||
void resizeEvent(XConfigureEvent *configure_event);
|
||||
void paintEvent();
|
||||
|
||||
void requestActivateWindow();
|
||||
|
||||
|
|
@ -108,6 +108,8 @@ public:
|
|||
|
||||
Qt::WindowFlags setWindowFlags(Qt::WindowFlags type);
|
||||
Qt::WindowFlags windowFlags() const;
|
||||
Qt::WindowState setWindowState(Qt::WindowState state);
|
||||
|
||||
void setVisible(bool visible);
|
||||
WId winId() const;
|
||||
void setParent(const QPlatformWindow *window);
|
||||
|
|
@ -117,14 +119,14 @@ public:
|
|||
|
||||
void setCursor(const Cursor &cursor);
|
||||
|
||||
QPlatformGLContext *glContext() const;
|
||||
|
||||
Window xWindow() const;
|
||||
GC graphicsContext() const;
|
||||
|
||||
inline uint depth() const { return mDepth; }
|
||||
QImage::Format format() const { return mFormat; }
|
||||
QSurfaceFormat format() const;
|
||||
Visual* visual() const { return mVisual; }
|
||||
int depth() const { return mDepth; }
|
||||
|
||||
static QXlibWindow *platformWindowForXWindow(Window window);
|
||||
|
||||
protected:
|
||||
QVector<Atom> getNetWmState() const;
|
||||
|
|
@ -134,8 +136,6 @@ protected:
|
|||
void doSizeHints();
|
||||
|
||||
private:
|
||||
QPlatformWindowFormat correctColorBuffers(const QPlatformWindowFormat &windowFormat)const;
|
||||
|
||||
Window x_window;
|
||||
GC gc;
|
||||
|
||||
|
|
@ -148,6 +148,8 @@ private:
|
|||
QPlatformGLContext *mGLContext;
|
||||
QXlibScreen *mScreen;
|
||||
Qt::WindowFlags mWindowFlags;
|
||||
|
||||
static QHash<Window, QXlibWindow *> windowMap;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,14 +1,16 @@
|
|||
TARGET = qxlib
|
||||
|
||||
load(qpa/plugin)
|
||||
DESTDIR = $$QT.gui.plugins/platforms
|
||||
DEFINES += MYX11_DEBUG
|
||||
|
||||
QT += core-private gui-private opengl-private platformsupport-private
|
||||
load(qt_plugin)
|
||||
QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/platforms
|
||||
|
||||
QT += core-private gui-private platformsupport-private
|
||||
|
||||
SOURCES = \
|
||||
main.cpp \
|
||||
qxlibintegration.cpp \
|
||||
qxlibwindowsurface.cpp \
|
||||
qxlibbackingstore.cpp \
|
||||
qxlibwindow.cpp \
|
||||
qxlibcursor.cpp \
|
||||
qxlibscreen.cpp \
|
||||
|
|
@ -21,7 +23,7 @@ SOURCES = \
|
|||
|
||||
HEADERS = \
|
||||
qxlibintegration.h \
|
||||
qxlibwindowsurface.h \
|
||||
qxlibbackingstore.h \
|
||||
qxlibwindow.h \
|
||||
qxlibcursor.h \
|
||||
qxlibscreen.h \
|
||||
|
|
@ -38,18 +40,18 @@ mac {
|
|||
LIBS += -L/usr/X11/lib -lz -framework Carbon
|
||||
}
|
||||
|
||||
include (../fontdatabases/genericunix/genericunix.pri)
|
||||
CONFIG += qpa/genericunixfontdatabase
|
||||
|
||||
contains(QT_CONFIG, opengl) {
|
||||
QT += opengl
|
||||
!contains(QT_CONFIG, opengles2) {
|
||||
load(qpa/glx/convenience)
|
||||
# load(qpa/glx/convenience)
|
||||
HEADERS += qglxintegration.h
|
||||
SOURCES += qglxintegration.cpp
|
||||
} else { # There is no easy way to detect if we'r suppose to use glx or not
|
||||
load(qpa/egl/context)
|
||||
load(qpa/egl/convenience)
|
||||
load(qpa/egl/xlibintegration)
|
||||
# load(qpa/egl/context)
|
||||
# load(qpa/egl/convenience)
|
||||
# load(qpa/egl/xlibintegration)
|
||||
LIBS += -lEGL
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue