Sunteți pe pagina 1din 8

commit 481f9fffae402f4c5fe85d4b14965ba9d2e0bad8

Author: Luis Gustavo S. Barreto <gustavosbarreto@gmail.com>


Date: Fri Mar 18 21:52:35 2011 -0300
merda
diff --git a/desktopenvironment/main.cpp b/desktopenvironment/main.cpp
index 5c9ad41..ffca53b 100644
--- a/desktopenvironment/main.cpp
+++ b/desktopenvironment/main.cpp
@@ -1,5 +1,6 @@
#include <qapplication.h>
#include <QGraphicsView>
+#include <QDebug>
#include "windowsystem/windowsystem.h"
@@ -13,6 +14,8 @@ int main(int argc, char *argv[])
QGraphicsView *view = new QGraphicsView(scene);
view->show();
+ view->setOptimizationFlags(QGraphicsView::DontAdjustForAntialiasing);
+
new WindowSystem(scene);
return app.exec();
diff --git a/desktopenvironment/windowsystem/window.cpp b/desktopenvironment/win
dowsystem/window.cpp
index 10e23ee..bf3bab6 100644
--- a/desktopenvironment/windowsystem/window.cpp
+++ b/desktopenvironment/windowsystem/window.cpp
@@ -15,9 +15,9 @@ Window::Window(WindowSystem *server, Window *parent, WindowTyp
e type)
: QGraphicsItem(parent), m_type(type), m_server(server)
{
//setFlag(QGraphicsItem::ItemIsMovable); // ### for testing
- setFlag(QGraphicsItem::ItemClipsToShape);
- setFlag(QGraphicsItem::ItemClipsChildrenToShape);
- setFlag(QGraphicsItem::ItemIsFocusable);
+ //setFlag(QGraphicsItem::ItemClipsToShape);
+ //setFlag(QGraphicsItem::ItemClipsChildrenToShape);
+ //setFlag(QGraphicsItem::ItemIsFocusable);
}
quint32 Window::id() const
@@ -57,7 +57,7 @@ void Window::paint(QPainter *painter, const QStyleOptionGraphi
csItem *option, QW
if (!m_surface.lock())
qDebug() << m_surface.errorString();
const uchar *data = static_cast<const uchar *>(m_surface.constData());
- QImage image(data, width, height, QImage::Format_ARGB32); // ### server
should hold the pixel format
+ QImage image(data, width, height, QImage::Format_RGB32); // ### server
should hold the pixel format
painter->drawImage(0, 0, image);
m_surface.unlock();
m_surface.detach();
diff --git a/desktopenvironment/windowsystem/windowsystem.cpp b/desktopenvironme
nt/windowsystem/windowsystem.cpp
index aee2f83..cf8ad98 100644
--- a/desktopenvironment/windowsystem/windowsystem.cpp
+++ b/desktopenvironment/windowsystem/windowsystem.cpp
@@ -147,7 +147,7 @@ void WindowSystem::lowerWindow(quint32 id)
void WindowSystem::updateWindow(quint32 id, const QRectF &rect)
{
- qDebug() << "SERVER: update window";
+ qDebug() << "SERVER: update window" << id;
if (Window *window = m_windows.value(id))
window->update(rect);
}
diff --git a/platformplugin/ambienteintegration.cpp b/platformplugin/ambienteint
egration.cpp
index 2390ea0..573bfb4 100644
--- a/platformplugin/ambienteintegration.cpp
+++ b/platformplugin/ambienteintegration.cpp
@@ -12,13 +12,12 @@
AmbienteIntegration::AmbienteIntegration()
{
- m_server = new WindowSystemServer(this);
+ m_server = WindowSystemServer::instance();

if (!m_server->tryConnect())
qFatal("Failed to connect to server");
- AmbienteScreen *screen = new AmbienteScreen();
- m_screens.append(screen);
+ m_screen = new AmbienteScreen();
}
bool AmbienteIntegration::hasCapability(QPlatformIntegration::Capability cap) c
onst
@@ -37,19 +36,27 @@ QPixmapData *AmbienteIntegration::createPixmapData(QPixmapDa
ta::PixelType type)
QPlatformWindow *AmbienteIntegration::createPlatformWindow(QWidget *widget, WId
winId) const
{
Q_UNUSED(winId);
+
AmbienteWindow *window = new AmbienteWindow(widget);
+ m_screen->addWindow(window);
return window;
}

QWindowSurface *AmbienteIntegration::createWindowSurface(QWidget *widget, WId w


inId) const
{
Q_UNUSED(winId);
+
AmbienteWindowSurface *surface = new AmbienteWindowSurface(widget, (Ambient
eIntegration *)this);
m_surfaces.insert(surface->id(), surface);
m_ids.insert(widget, surface->id());
return surface;
}
+QList<QPlatformScreen *> AmbienteIntegration::screens() const
+{
+ return (QList<QPlatformScreen *>() << m_screen);
+}
+
quint32 AmbienteIntegration::parentWindowId(QWidget *widget) const
{
return m_ids.value(widget->parentWidget());
diff --git a/platformplugin/ambienteintegration.h b/platformplugin/ambienteinteg
ration.h
index 7ecd726..e358d35 100644
--- a/platformplugin/ambienteintegration.h
+++ b/platformplugin/ambienteintegration.h
@@ -7,6 +7,7 @@
class QPlatformScreen;
class AmbienteWindowSurface;
+class AmbienteScreen;
class WindowSystemServer;
class AmbienteIntegration: public QPlatformIntegration
@@ -20,7 +21,7 @@ public:
QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId) const;
QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const;

- inline QList<QPlatformScreen *> screens() const { return m_screens; }


+ QList<QPlatformScreen *> screens() const;
WindowSystemServer *server() const { return m_server; }
@@ -28,10 +29,10 @@ public:
AmbienteWindowSurface *surface(quint32 id) const;
private:
+ AmbienteScreen *m_screen;
WindowSystemServer *m_server;
mutable QHash<quint32, AmbienteWindowSurface *> m_surfaces;
mutable QHash<QWidget *, quint32> m_ids;
- QList<QPlatformScreen *> m_screens;
};
#endif
diff --git a/platformplugin/ambientescreen.cpp b/platformplugin/ambientescreen.c
pp
index 308f3ae..62a8311 100644
--- a/platformplugin/ambientescreen.cpp
+++ b/platformplugin/ambientescreen.cpp
@@ -1,5 +1,6 @@
// Self
#include "ambientescreen.h"
+#include "ambientewindow.h"
AmbienteScreen::AmbienteScreen():
QPlatformScreen()
@@ -18,5 +19,11 @@ int AmbienteScreen::depth() const
QImage::Format AmbienteScreen::format() const
{
- return QImage::Format_ARGB32;
+ return QImage::Format_RGB32;
+}
+
+void AmbienteScreen::addWindow(AmbienteWindow *window)
+{
+// m_windows.insert(window);
+ window->setScreen(this);
}
diff --git a/platformplugin/ambientescreen.h b/platformplugin/ambientescreen.h
index c62d818..f323f13 100644
--- a/platformplugin/ambientescreen.h
+++ b/platformplugin/ambientescreen.h
@@ -2,6 +2,9 @@
#define _AMBIENTESCREEN_H
#include <QPlatformScreen>
+#include <QHash>
+
+class AmbienteWindow;
class AmbienteScreen: public QPlatformScreen
{
@@ -11,6 +14,11 @@ public:
virtual QRect geometry() const;
virtual int depth() const;
virtual QImage::Format format() const;
+
+ void addWindow(AmbienteWindow *window);
+
+private:
+ QHash<quint32, AmbienteWindow *> m_windows;
};
#endif
diff --git a/platformplugin/ambientewindow.cpp b/platformplugin/ambientewindow.c
pp
index edade48..65f86a8 100644
--- a/platformplugin/ambientewindow.cpp
+++ b/platformplugin/ambientewindow.cpp
@@ -1,7 +1,42 @@
// Self
#include "ambientewindow.h"
+// Own
+#include "windowsystemserver.h"
+
AmbienteWindow::AmbienteWindow(QWidget *window):
QPlatformWindow(window)
{
}
+
+void AmbienteWindow::setVisible(bool visible)
+{
+ QPlatformWindow::setVisible(visible);
+
+ if (visible)
+ {
+ Request request(Request::ShowWindowRequest, 0);
+ WindowSystemServer::instance()->sendRequest(request);
+ }
+ else
+ {
+ Request request(Request::HideWindowRequest, 0);
+ WindowSystemServer::instance()->sendRequest(request);
+ }
+}
+
+void AmbienteWindow::setGeometry(const QRect &rect)
+{
+ QPlatformWindow::setGeometry(rect);
+ Request request(Request::SetWindowGeometryRequest, 0/*id*/, 0, rect);
+ WindowSystemServer::instance()->sendRequest(request);
+}
+
+void AmbienteWindow::setScreen(AmbienteScreen *screen)
+{
+ m_screen = screen;
+}
+
+void AmbienteWindow::repaint(const QRegion &region)
+{
+}
diff --git a/platformplugin/ambientewindow.h b/platformplugin/ambientewindow.h
index 80cd52e..1bdb8a8 100644
--- a/platformplugin/ambientewindow.h
+++ b/platformplugin/ambientewindow.h
@@ -5,10 +5,22 @@
class QWidget;
+class AmbienteScreen;
+
class AmbienteWindow: public QPlatformWindow
{
public:
AmbienteWindow(QWidget *window);
+
+ virtual void setVisible(bool visible);
+ virtual void setGeometry(const QRect &rect);
+
+ void setScreen(AmbienteScreen *screen);
+
+ void repaint(const QRegion &region);
+
+private:
+ AmbienteScreen *m_screen;
};

#endif
diff --git a/platformplugin/ambientewindowsurface.cpp b/platformplugin/ambientew
indowsurface.cpp
index 10879d8..6744a21 100644
--- a/platformplugin/ambientewindowsurface.cpp
+++ b/platformplugin/ambientewindowsurface.cpp
@@ -3,6 +3,7 @@
// Own
#include "ambienteintegration.h"
+#include "ambientewindow.h"
#include "windowsystemserver.h"
#include "protocol.h"
@@ -14,6 +15,8 @@ AmbienteWindowSurface::AmbienteWindowSurface(QWidget *window,
AmbienteIntegratio
: QWindowSurface(window)
, m_integrator(integrator)
{
+ m_platformWindow = static_cast<AmbienteWindow *>(window->platformWindow());
+
WindowSystemServer *server = integrator->server();
Request request(Request::CreateWindowRequest, integrator->parentWindowId(wi
ndow));
@@ -40,6 +43,8 @@ void AmbienteWindowSurface::flush(QWidget *widget, const QRegi
on &region, const
Q_UNUSED(region);
Q_UNUSED(offset);
+ m_platformWindow->repaint(region);
+
Request request(Request::UpdateWindowRequest, m_id);
m_integrator->server()->sendRequest(request);
}
@@ -70,6 +75,9 @@ void AmbienteWindowSurface::resize(const QSize &size)
void AmbienteWindowSurface::beginPaint(const QRegion &region)
{
Q_UNUSED(region);
+
+ QWindowSurface::beginPaint(region);
+
if (m_shared.lock() && m_shared.data())
m_image = QImage((uchar*)m_shared.data(), geometry().width(), geometry(
).height(), m_integrator->screens().first()->format());
}
@@ -77,6 +85,9 @@ void AmbienteWindowSurface::beginPaint(const QRegion &region)
void AmbienteWindowSurface::endPaint(const QRegion &region)
{
Q_UNUSED(region);
+
+ QWindowSurface::endPaint(region);
+
if (m_shared.unlock())
m_image = QImage();
}
diff --git a/platformplugin/ambientewindowsurface.h b/platformplugin/ambientewin
dowsurface.h
index 3d7a80e..1727426 100644
--- a/platformplugin/ambientewindowsurface.h
+++ b/platformplugin/ambientewindowsurface.h
@@ -7,6 +7,7 @@
#include <QtGui/private/qwindowsurface_p.h>
class AmbienteIntegration;
+class AmbienteWindow;
class AmbienteWindowSurface: public QWindowSurface
{
@@ -24,6 +25,8 @@ public:
inline quint32 id() const { return m_id; }
private:
+ AmbienteWindow *m_platformWindow;
+
quint32 m_id;
AmbienteIntegration *m_integrator;
QSharedMemory m_shared;
diff --git a/platformplugin/windowsystemserver.cpp b/platformplugin/windowsystem
server.cpp
index d2d5287..cb8b10a 100644
--- a/platformplugin/windowsystemserver.cpp
+++ b/platformplugin/windowsystemserver.cpp
@@ -10,10 +10,13 @@
#include <QApplication>
#include <QDataStream>
#include <QWindowSystemInterface>
+#include <QtGui/private/qapplication_p.h>
-WindowSystemServer::WindowSystemServer(AmbienteIntegration *integrator)
- : QObject()
- , m_integrator(integrator)
+static WindowSystemServer *self = NULL;
+
+WindowSystemServer::WindowSystemServer():
+ QObject(),
+ m_integrator(NULL)
{
}
@@ -32,6 +35,9 @@ bool WindowSystemServer::tryConnect()
bool WindowSystemServer::sendRequest(const Request &request)
{
+ if (!m_integrator)
+ m_integrator = static_cast<AmbienteIntegration *>(QApplicationPrivate::
platformIntegration());
+
QDataStream s(&m_socket);
s << (*static_cast<const Message *>(&request));
return m_socket.isValid();
@@ -54,6 +60,13 @@ bool WindowSystemServer::waitForResponse(Response &response)
return false;
}
+WindowSystemServer *WindowSystemServer::instance()
+{
+ if (!self)
+ self = new WindowSystemServer;
+ return self;
+}
+
void WindowSystemServer::eventDispatcher()
{
while (m_socket.bytesAvailable())
diff --git a/platformplugin/windowsystemserver.h b/platformplugin/windowsystemse
rver.h
index 7469c98..805d3b1 100644
--- a/platformplugin/windowsystemserver.h
+++ b/platformplugin/windowsystemserver.h
@@ -12,13 +12,16 @@ class WindowSystemServer: public QObject
{
Q_OBJECT
-public:
- WindowSystemServer(AmbienteIntegration *integrator);
+private:
+ WindowSystemServer();
+public:
bool tryConnect();
bool sendRequest(const Request &request);
bool waitForResponse(Response &response);
+ static WindowSystemServer *instance();
+
private slots:
void eventDispatcher();

S-ar putea să vă placă și