Qt 4.8
Public Types | Public Functions | Protected Functions | Protected Variables | Static Private Functions | List of all members
QWaylandWindow Class Referenceabstract

#include <qwaylandwindow.h>

Inheritance diagram for QWaylandWindow:
QPlatformWindow QWaylandEglWindow QWaylandShmWindow QWaylandXCompositeEGLWindow QWaylandXCompositeGLXWindow QWaylandReadbackEglWindow QWaylandReadbackGlxWindow

Public Types

enum  WindowType { Shm, Egl }
 

Public Functions

void attach (QWaylandBuffer *buffer)
 
void configure (uint32_t time, uint32_t edges, int32_t x, int32_t y, int32_t width, int32_t height)
 
void damage (const QRect &rect)
 
 QWaylandWindow (QWidget *window)
 
void setParent (const QPlatformWindow *parent)
 This function is called to enable native child widgets in QPA. More...
 
void setVisible (bool visible)
 Reimplemented in subclasses to show the surface if visible is true, and hide it if visible is false. More...
 
void waitForFrameSync ()
 
virtual WindowType windowType () const =0
 
WId winId () const
 Reimplement in subclasses to return a handle to the native window. More...
 
struct wl_surface * wl_surface () const
 
 ~QWaylandWindow ()
 
- Public Functions inherited from QPlatformWindow
virtual QRect geometry () const
 Returnes the current geometry of a window. More...
 
virtual QPlatformGLContextglContext () const
 Reimplement to return the glContext associated with the window. More...
 
virtual void lower ()
 Reimplement to be able to let Qt lower windows to the bottom of the desktop. More...
 
 QPlatformWindow (QWidget *tlw)
 Constructs a platform window with the given top level widget. More...
 
virtual void raise ()
 Reimplement to be able to let Qt rais windows to the top of the desktop. More...
 
virtual void requestActivateWindow ()
 Reimplement to let Qt be able to request activation/focus for a window. More...
 
virtual void setGeometry (const QRect &rect)
 This function is called by Qt whenever a window is moved or the window is resized. More...
 
virtual void setOpacity (qreal level)
 Reimplement to be able to let Qt set the opacity level of a window. More...
 
virtual Qt::WindowFlags setWindowFlags (Qt::WindowFlags flags)
 Requests setting the window flags of this surface to type. More...
 
virtual void setWindowTitle (const QString &title)
 Reimplement to set the window title to title. More...
 
QWidgetwidget () const
 Returnes the widget which belongs to the QPlatformWindow. More...
 
virtual Qt::WindowFlags windowFlags () const
 Returns the effective window flags for this surface. More...
 
virtual ~QPlatformWindow ()
 Virtual destructor does not delete its top level widget. More...
 

Protected Functions

virtual void newSurfaceCreated ()
 

Protected Variables

QWaylandBuffermBuffer
 
QWaylandDisplaymDisplay
 
QWaitCondition mFrameSyncWait
 
struct wl_surfacemSurface
 
bool mWaitingForFrameSync
 
WId mWindowId
 
- Protected Variables inherited from QPlatformWindow
QScopedPointer< QPlatformWindowPrivated_ptr
 

Static Private Functions

static void frameCallback (struct wl_surface *surface, void *data, uint32_t time)
 

Detailed Description

Definition at line 54 of file qwaylandwindow.h.

Enumerations

◆ WindowType

Enumerator
Shm 
Egl 

Definition at line 57 of file qwaylandwindow.h.

Constructors and Destructors

◆ QWaylandWindow()

QWaylandWindow::QWaylandWindow ( QWidget window)

Definition at line 59 of file qwaylandwindow.cpp.

60  : QPlatformWindow(window)
61  , mSurface(0)
63  , mBuffer(0)
64  , mWaitingForFrameSync(false)
65 {
66  static WId id = 1;
67  mWindowId = id++;
68 
69 #ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT
70  mDisplay->windowManagerIntegration()->mapClientToProcess(qApp->applicationPid());
71  mDisplay->windowManagerIntegration()->authenticateWithToken();
72 #endif
73 }
unsigned long WId
Definition: qwindowdefs.h:119
struct wl_surface * mSurface
QPlatformWindow(QWidget *tlw)
Constructs a platform window with the given top level widget.
Q_GUI_EXPORT EGLDisplay display()
Definition: qegl.cpp:589
#define qApp
bool mWaitingForFrameSync
QWaylandDisplay * mDisplay
QWaylandBuffer * mBuffer
static QWaylandScreen * waylandScreenFromWidget(QWidget *widget)

◆ ~QWaylandWindow()

QWaylandWindow::~QWaylandWindow ( )

Definition at line 75 of file qwaylandwindow.cpp.

76 {
77  if (mSurface)
78  wl_surface_destroy(mSurface);
79 
81  for (int i = 0; i < inputDevices.size(); ++i)
82  inputDevices.at(i)->handleWindowDestroyed(this);
83 }
struct wl_surface * mSurface
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
void handleWindowDestroyed(QWaylandWindow *window)
QWaylandDisplay * mDisplay
QList< QWaylandInputDevice * > inputDevices() const
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

Functions

◆ attach()

void QWaylandWindow::attach ( QWaylandBuffer buffer)

Definition at line 122 of file qwaylandwindow.cpp.

Referenced by QWaylandReadbackEglContext::geometryChanged(), QWaylandReadbackGlxContext::geometryChanged(), QWaylandXCompositeEGLContext::geometryChanged(), QWaylandXCompositeGLXContext::geometryChanged(), and QWaylandShmWindowSurface::resize().

123 {
124  mBuffer = buffer;
125  if (mSurface) {
126  wl_surface_attach(mSurface, buffer->buffer(),0,0);
127  }
128 }
struct wl_surface * mSurface
wl_buffer * buffer()
QWaylandBuffer * mBuffer

◆ configure()

void QWaylandWindow::configure ( uint32_t  time,
uint32_t  edges,
int32_t  x,
int32_t  y,
int32_t  width,
int32_t  height 
)

Definition at line 109 of file qwaylandwindow.cpp.

Referenced by QWaylandDisplay::shellHandleConfigure().

112 {
113  Q_UNUSED(time);
114  Q_UNUSED(edges);
115  QRect geometry = QRect(x, y, width, height);
116 
117  setGeometry(geometry);
118 
120 }
virtual void setGeometry(const QRect &rect)
This function is called by Qt whenever a window is moved or the window is resized.
virtual QRect geometry() const
Returnes the current geometry of a window.
static void handleGeometryChange(QWidget *w, const QRect &newRect)
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
QWidget * widget() const
Returnes the widget which belongs to the QPlatformWindow.

◆ damage()

void QWaylandWindow::damage ( const QRect rect)

Definition at line 130 of file qwaylandwindow.cpp.

Referenced by QWaylandShmWindowSurface::flush(), QWaylandReadbackGlxContext::swapBuffers(), QWaylandReadbackEglContext::swapBuffers(), QWaylandXCompositeEGLContext::swapBuffers(), and QWaylandXCompositeGLXContext::swapBuffers().

131 {
132  //We have to do sync stuff before calling damage, or we might
133  //get a frame callback before we get the timestamp
134  if (!mWaitingForFrameSync) {
136  mWaitingForFrameSync = true;
137  }
138 
139  wl_surface_damage(mSurface,
140  rect.x(), rect.y(), rect.width(), rect.height());
141 }
struct wl_surface * mSurface
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
void frameCallback(wl_display_frame_func_t func, struct wl_surface *surface, void *data)
bool mWaitingForFrameSync
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
static void frameCallback(struct wl_surface *surface, void *data, uint32_t time)
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
QWaylandDisplay * mDisplay

◆ frameCallback()

void QWaylandWindow::frameCallback ( struct wl_surface surface,
void *  data,
uint32_t  time 
)
staticprivate

Definition at line 152 of file qwaylandwindow.cpp.

Referenced by damage().

153 {
154  Q_UNUSED(time);
155  Q_UNUSED(surface);
156  QWaylandWindow *self = static_cast<QWaylandWindow*>(data);
157  self->mWaitingForFrameSync = false;
158 }
static const char * data(const QByteArray &arr)
bool mWaitingForFrameSync
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ newSurfaceCreated()

void QWaylandWindow::newSurfaceCreated ( )
protectedvirtual

Reimplemented in QWaylandEglWindow.

Definition at line 143 of file qwaylandwindow.cpp.

Referenced by QWaylandShmWindow::QWaylandShmWindow(), and setVisible().

144 {
145  if (mBuffer) {
146  wl_surface_attach(mSurface,mBuffer->buffer(),0,0);
147  wl_surface_damage(mSurface,
148  0,0,mBuffer->size().width(),mBuffer->size().height());
149  }
150 }
struct wl_surface * mSurface
int width() const
Returns the width.
Definition: qsize.h:126
wl_buffer * buffer()
int height() const
Returns the height.
Definition: qsize.h:129
virtual QSize size() const =0
QWaylandBuffer * mBuffer

◆ setParent()

void QWaylandWindow::setParent ( const QPlatformWindow parent)
virtual

This function is called to enable native child widgets in QPA.

It is common not to support this feature in Window systems, but can be faked. When this function is called all geometry of this platform window will be relative to the parent.

Reimplemented from QPlatformWindow.

Definition at line 90 of file qwaylandwindow.cpp.

91 {
92  Q_UNUSED(parent);
93  qWarning("Sub window is not supported");
94 }
Q_CORE_EXPORT void qWarning(const char *,...)
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ setVisible()

void QWaylandWindow::setVisible ( bool  visible)
virtual

Reimplemented in subclasses to show the surface if visible is true, and hide it if visible is false.

Reimplemented from QPlatformWindow.

Definition at line 96 of file qwaylandwindow.cpp.

97 {
98  if (!mSurface && visible) {
101  }
102 
103  if (!visible) {
104  wl_surface_destroy(mSurface);
105  mSurface = NULL;
106  }
107 }
struct wl_surface * mSurface
struct wl_surface * createSurface(void *handle)
QWaylandDisplay * mDisplay
virtual void newSurfaceCreated()

◆ waitForFrameSync()

void QWaylandWindow::waitForFrameSync ( )

◆ windowType()

virtual WindowType QWaylandWindow::windowType ( ) const
pure virtual

◆ winId()

WId QWaylandWindow::winId ( ) const
virtual

Reimplement in subclasses to return a handle to the native window.

Reimplemented from QPlatformWindow.

Definition at line 85 of file qwaylandwindow.cpp.

86 {
87  return mWindowId;
88 }

◆ wl_surface()

struct wl_surface* QWaylandWindow::wl_surface ( ) const
inline

Definition at line 78 of file qwaylandwindow.h.

78 { return mSurface; }
struct wl_surface * mSurface

Properties

◆ mBuffer

QWaylandBuffer* QWaylandWindow::mBuffer
protected

Definition at line 84 of file qwaylandwindow.h.

Referenced by attach(), and newSurfaceCreated().

◆ mDisplay

QWaylandDisplay* QWaylandWindow::mDisplay
protected

◆ mFrameSyncWait

QWaitCondition QWaylandWindow::mFrameSyncWait
protected

Definition at line 87 of file qwaylandwindow.h.

◆ mSurface

struct wl_surface* QWaylandWindow::mSurface
protected

◆ mWaitingForFrameSync

bool QWaylandWindow::mWaitingForFrameSync
protected

Definition at line 86 of file qwaylandwindow.h.

Referenced by damage(), frameCallback(), and waitForFrameSync().

◆ mWindowId

WId QWaylandWindow::mWindowId
protected

Definition at line 85 of file qwaylandwindow.h.

Referenced by QWaylandWindow(), and winId().


The documentation for this class was generated from the following files: