}
private slots:
- void surfaceMapped(const QRect &rect) {
+ void surfaceMapped(const QSize &size) {
WaylandSurface *surface = qobject_cast<WaylandSurface *>(sender());
- surface->setGeometry(rect);
+ surface->setGeometry(QRect(surface->geometry().topLeft(),size));
if (m_windowMap.contains(surface)) {
WaylandSurfaceItem *item = m_windowMap.value(surface);
- item->setWidth(rect.width());
- item->setHeight(rect.height());
+ item->setWidth(size.width());
+ item->setHeight(size.height());
emit windowResized(QVariant::fromValue(static_cast<QSGItem *>(item)));
} else {
WaylandSurfaceItem *item = new WaylandSurfaceItem(surface, rootObject());
protected:
void surfaceCreated(WaylandSurface *surface) {
- connect(surface, SIGNAL(mapped(const QRect &)), this, SLOT(surfaceMapped(const QRect &)));
+ connect(surface, SIGNAL(mapped(const QSize &)), this, SLOT(surfaceMapped(const QSize &)));
}
void paintEvent(QPaintEvent *event) {
update();
}
- void surfaceMapped(const QRect &rect) {
+ void surfaceMapped(const QSize &size) {
WaylandSurface *surface = qobject_cast<WaylandSurface *>(sender());
QPoint pos;
if (!m_surfaces.contains(surface)) {
- uint px = 1 + (qrand() % (width() - rect.width() - 2));
- uint py = 1 + (qrand() % (height() - rect.height() - 2));
+ uint px = 1 + (qrand() % (width() - size.width() - 2));
+ uint py = 1 + (qrand() % (height() - size.height() - 2));
pos = QPoint(px, py);
- surface->setGeometry(QRect(pos, rect.size()));
+ surface->setGeometry(QRect(pos, size));
m_surfaces.append(surface);
} else {
- surface->setGeometry(rect);
+ surface->setGeometry(QRect(geometry().topLeft(),size));
}
setInputFocus(surface);
update();
void surfaceCreated(WaylandSurface *surface) {
connect(surface, SIGNAL(destroyed(QObject *)), this, SLOT(surfaceDestroyed(QObject *)));
- connect(surface, SIGNAL(mapped(const QRect &)), this, SLOT(surfaceMapped(const QRect &)));
+ connect(surface, SIGNAL(mapped(const QSize &)), this, SLOT(surfaceMapped(const QSize &)));
connect(surface, SIGNAL(damaged(const QRect &)), this, SLOT(surfaceDamaged(const QRect &)));
update();
}
namespace Wayland {
class Surface;
+class SurfacePrivate;
}
class WaylandSurface : public QObject
qint64 processId() const;
signals:
- void mapped(const QRect &rect);
+ void mapped(const QSize &size);
void damaged(const QRect &rect);
friend class Wayland::Surface;
+ friend class Wayland::SurfacePrivate;
};
#endif // WAYLANDSURFACE_H
setSmooth(true);
setFlag(ItemHasContents);
setAcceptedMouseButtons(Qt::LeftButton | Qt::RightButton);
- connect(surface, SIGNAL(mapped(const QRect &)), this, SLOT(surfaceMapped(const QRect &)));
+ connect(surface, SIGNAL(mapped(const QSize &)), this, SLOT(surfaceMapped(const QSize &)));
connect(surface, SIGNAL(destroyed(QObject *)), this, SLOT(surfaceDestroyed(QObject *)));
connect(this, SIGNAL(textureChanged()), this, SLOT(update()));
connect(surface, SIGNAL(damaged(const QRect &)), this, SLOT(surfaceDamaged(const QRect &)));
return pos.toPoint();
}
-void WaylandSurfaceItem::surfaceMapped(const QRect &rect)
+void WaylandSurfaceItem::surfaceMapped(const QSize &size)
{
- setWidth(rect.width());
- setHeight(rect.height());
+ setWidth(size.width());
+ setHeight(size.height());
}
void WaylandSurfaceItem::surfaceDestroyed(QObject *)
void setPaintEnabled(bool paintEnabled);
private slots:
- void surfaceMapped(const QRect &rect);
+ void surfaceMapped(const QSize &size);
void surfaceDestroyed(QObject *object);
void surfaceDamaged(const QRect &);
: mWindow(window)
, mInvertedY(false)
{
- base()->compositor = compositor->base();
base()->height = size.height();
base()->width = size.width();
base()->visual = visual;
Selection::instance()->create(client, id);
}
+void set_toplevel(struct wl_client *client,
+ struct wl_shell *wl_shell,
+ struct wl_surface *surface)
+{
+
+}
+
+void set_transient(struct wl_client *client,
+ struct wl_shell *wl_shell,
+ struct wl_surface *surface,
+ struct wl_surface *parent,
+ int x,
+ int y,
+ uint32_t flags)
+{
+}
+void set_fullscreen(struct wl_client *client,
+ struct wl_shell *wl_shell,
+ struct wl_surface *surface)
+{
+}
+
const static struct wl_shell_interface shell_interface = {
shell_move,
shell_resize,
shell_drag,
- shell_selection
+ shell_selection,
+ set_toplevel,
+ set_transient,
+ set_fullscreen
};
static Compositor *compositor;
Output *output = wayland_cast<Output *>(global);
wl_client_post_event(client, global, WL_OUTPUT_GEOMETRY, 0, 0,
- output->size().width(), output->size().height());
+ output->size().width(), output->size().height(),0,"","");
+
+ wl_client_post_event(client,global,WL_OUTPUT_MODE, 0,output->size().width(),output->size().height());
}
#include "wlshmbuffer.h"
#include "wldisplay.h"
+#include "wlcompositor.h"
#include <QtCore/QDebug>
: m_buffer(buffer)
{
m_buffer->user_data = this;
- m_buffer->compositor = NULL;
m_data = wl_shm_buffer_get_data(m_buffer);
m_stride = wl_shm_buffer_get_stride(m_buffer);
{
QImage::Format imageFormat = QImage::Format_Invalid;
- //jl: need to do depth check as well.
-
- if (!m_buffer->compositor)
- return ;
-
- if (m_buffer->visual == &m_buffer->compositor->premultiplied_argb_visual) {
+ wl_compositor *compositor = Wayland::Compositor::instance()->base();
+ if (m_buffer->visual == &compositor->premultiplied_argb_visual) {
imageFormat = QImage::Format_ARGB32_Premultiplied;
- } else if (m_buffer->visual == &m_buffer->compositor->rgb_visual) {
+ } else if (m_buffer->visual == &compositor->rgb_visual) {
imageFormat = QImage::Format_RGB32;
- } else if (m_buffer->visual == &m_buffer->compositor->argb_visual) {
+ } else if (m_buffer->visual == &compositor->argb_visual) {
imageFormat = QImage::Format_ARGB32;
} else {
+ qWarning("Failed to match ShmBuffer visual");
imageFormat = QImage::Format_ARGB32_Premultiplied;
}
m_image = QImage(static_cast<uchar *>(m_data),m_buffer->width, m_buffer->height,m_stride,imageFormat);
+
}
ShmHandler::ShmHandler(Display *display)
Q_UNUSED(y);
Q_UNUSED(width);
Q_UNUSED(height);
+ //damage has the responsibillity to update the QImage
+ //for now we just recrate the entire QImage as we need a new
+ //hash key for texture uploads
+ static_cast<ShmBuffer *>(buffer->user_data)->damage();
}
void ShmHandler::buffer_destroyed_callback(struct wl_buffer *buffer)
SurfacePrivate(struct wl_client *client, Compositor *compositor)
: client(client)
, compositor(compositor)
- , needsMap(false)
, textureCreatedForBuffer(false)
, directRenderBuffer(0)
, processId(0)
}
void attach(struct wl_buffer *buffer) {
- this->surfaceBuffer = buffer;
+ bool emitMap = !surfaceBuffer;
+ surfaceBuffer = buffer;
surfaceType = WaylandSurface::Invalid;
textureCreatedForBuffer = false;
- buffer->compositor = compositor->base();
+ if (emitMap) {
+ qtSurface->mapped(QSize(surfaceBuffer->width,surfaceBuffer->height));
+ }
}
inline struct wl_buffer *buffer() const { return surfaceBuffer; }
#ifdef QT_COMPOSITOR_WAYLAND_GL
GLuint texture_id;
#endif
- bool needsMap;
bool textureCreatedForBuffer;
wl_buffer *directRenderBuffer;
qint64 processId;
wayland_cast<Surface *>(surface)->attach(buffer);
}
-void surface_map_toplevel(struct wl_client *client,
- struct wl_surface *surface)
-{
- Q_UNUSED(client);
- printf("surface_map_toplevel: %p, %p\n", client, surface);
-
- wayland_cast<Surface *>(surface)->mapTopLevel();
-}
-
-void surface_map_transient(struct wl_client *client,
- struct wl_surface *surface,
- struct wl_surface *parent,
- int x,
- int y,
- uint32_t flags)
-{
- Q_UNUSED(client);
- Q_UNUSED(surface);
- Q_UNUSED(parent);
- Q_UNUSED(x);
- Q_UNUSED(y);
- Q_UNUSED(flags);
- printf("surface_map_transient: %p, %p\n", client, surface);
-}
-
-void surface_map_fullscreen(struct wl_client *client,
- struct wl_surface *surface)
-{
- Q_UNUSED(client);
- Q_UNUSED(surface);
- printf("surface_map_fullscreen: %p, %p\n", client, surface);
-}
-
void surface_damage(struct wl_client *client, struct wl_surface *surface,
int32_t x, int32_t y, int32_t width, int32_t height)
{
}
#endif
- if (d->needsMap) {
- QRect rect(0,0,d->buffer()->width,d->buffer()->height);
- emit d->qtSurface->mapped(rect);
- d->needsMap = false;
- }
-
d->compositor->markSurfaceAsDirty(this);
- if (d->type() == WaylandSurface::Shm) {
- static_cast<ShmBuffer *>(d->buffer()->user_data)->damage();
- }
-
emit d->qtSurface->damaged(rect);
}
d->attach(buffer);
}
-
-void Surface::mapTopLevel()
-{
- Q_D(Surface);
- if (!d->buffer())
- d->needsMap = true;
- else
- emit d->qtSurface->mapped(QRect(0,0,d->buffer()->width, d->buffer()->height));
-}
-
WaylandSurface * Surface::handle() const
{
Q_D(const Surface);
uint id() const { return base()->resource.object.id; }
void attach(struct wl_buffer *buffer);
- void mapTopLevel();
-
void damage(const QRect &rect);
QImage image() const;
void surface_destroy(struct wl_client *client, struct wl_surface *_surface);
void surface_attach(struct wl_client *client, struct wl_surface *surface,
struct wl_buffer *buffer, int x, int y);
-void surface_map_toplevel(struct wl_client *client,
- struct wl_surface *surface);
-void surface_map_transient(struct wl_client *client,
- struct wl_surface *surface,
- struct wl_surface *parent,
- int x,
- int y,
- uint32_t flags);
-void surface_map_fullscreen(struct wl_client *client,
- struct wl_surface *surface);
void surface_damage(struct wl_client *client, struct wl_surface *_surface,
int32_t x, int32_t y, int32_t width, int32_t height);
const static struct wl_surface_interface surface_interface = {
surface_destroy,
surface_attach,
- surface_map_toplevel,
- surface_map_transient,
- surface_map_fullscreen,
surface_damage
};
}
This version of Qt-Compositor is checked against the following sha1 from the
Wayland repository:
-2d27f3b6e9001d4fae4a4de7a19db76b5174f9d7
+b6fdded54bc86260f2b6126d34648c85f4f2d7b1