Starting resize support.
This commit is contained in:
parent
cea3d2c39f
commit
9ade0e2d4b
26 changed files with 197 additions and 44 deletions
|
@ -9,11 +9,13 @@ XcbGlInterface::XcbGlInterface(Display* display, int default_screen)
|
|||
mContext(),
|
||||
mConfig()
|
||||
{
|
||||
MLOG_INFO("Creating XcbGlInterface");
|
||||
setupContext(default_screen);
|
||||
}
|
||||
|
||||
XcbGlInterface::~XcbGlInterface()
|
||||
{
|
||||
MLOG_INFO("Destroying XcbGlInterface");
|
||||
destroyContext();
|
||||
}
|
||||
|
||||
|
|
|
@ -7,17 +7,20 @@
|
|||
#include <xcb/xcb.h>
|
||||
|
||||
#include "PaintEvent.h"
|
||||
#include "ResizeEvent.h"
|
||||
#include "Screen.h"
|
||||
#include "XcbScreen.h"
|
||||
#include "Color.h"
|
||||
#include "UiEvent.h"
|
||||
#include "VisualLayer.h"
|
||||
#include "XcbKeyboard.h"
|
||||
#include "XcbWindow.h"
|
||||
#include "XcbLayerInterface.h"
|
||||
#include "XcbEventInterface.h"
|
||||
#include "XcbGlInterface.h"
|
||||
#include "FileLogger.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
|
||||
XcbInterface::XcbInterface(DesktopManager* desktopManager, bool useHardware)
|
||||
: AbstractUIInterface(desktopManager, useHardware),
|
||||
|
@ -120,7 +123,8 @@ void XcbInterface::createGraphicsContext()
|
|||
auto gc = xcb_generate_id(mConnection);
|
||||
xcb_drawable_t window = xcb_screen->GetNativeScreen()->root;
|
||||
uint32_t mask = XCB_GC_FOREGROUND | XCB_GC_GRAPHICS_EXPOSURES;
|
||||
uint32_t values[2] = {XcbLayerInterface::getColor(240, 240, 240), 0};
|
||||
auto color = Color(240, 240, 240);
|
||||
uint32_t values[2] = {color.getAsUInt32(), 0};
|
||||
xcb_create_gc(mConnection, gc, window, mask, values);
|
||||
xcb_screen->SetGraphicsContext(gc);
|
||||
}
|
||||
|
@ -140,7 +144,8 @@ uint32_t XcbInterface::getEventMask()
|
|||
return XCB_EVENT_MASK_KEY_RELEASE |
|
||||
XCB_EVENT_MASK_BUTTON_PRESS |
|
||||
XCB_EVENT_MASK_BUTTON_RELEASE |
|
||||
XCB_EVENT_MASK_EXPOSURE;
|
||||
XCB_EVENT_MASK_EXPOSURE |
|
||||
XCB_EVENT_MASK_RESIZE_REDIRECT;
|
||||
}
|
||||
|
||||
void XcbInterface::addWindow(mt::Window* window)
|
||||
|
@ -205,6 +210,23 @@ void XcbInterface::loop()
|
|||
mDesktopManager->onUiEvent(std::move(ui_event));
|
||||
break;
|
||||
}
|
||||
case XCB_RESIZE_REQUEST:
|
||||
{
|
||||
auto resize = (xcb_resize_request_event_t*) event;
|
||||
int width = 1;
|
||||
int height = 1;
|
||||
if (resize->width > 0)
|
||||
{
|
||||
width = resize->width;
|
||||
}
|
||||
if (resize->height > 0)
|
||||
{
|
||||
height = resize->height;
|
||||
}
|
||||
auto ui_event = std::make_unique<ResizeEvent>(width, height);
|
||||
mDesktopManager->onUiEvent(std::move(ui_event));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
/* Unknown event type, ignore it */
|
||||
break;
|
||||
|
|
|
@ -6,20 +6,10 @@
|
|||
|
||||
#include <memory>
|
||||
|
||||
uint32_t XcbLayerInterface::getColor(const Color* color)
|
||||
{
|
||||
return XcbLayerInterface::getColor(color->GetR(), color->GetG(), color->GetB());
|
||||
}
|
||||
|
||||
uint32_t XcbLayerInterface::getColor(int r, int g, int b)
|
||||
{
|
||||
return b + (g<<8) + (r<<16);
|
||||
}
|
||||
|
||||
void XcbLayerInterface::modifyGcColor(xcb_connection_t* connection, xcb_gcontext_t gc, const Color* color)
|
||||
void XcbLayerInterface::modifyGcColor(xcb_connection_t* connection, xcb_gcontext_t gc, const Color& color)
|
||||
{
|
||||
uint32_t mask = XCB_GC_FOREGROUND | XCB_GC_GRAPHICS_EXPOSURES;
|
||||
uint32_t values[2] = {XcbLayerInterface::getColor(color), 0};
|
||||
uint32_t values[2] = {color.getAsUInt32(), 0};
|
||||
|
||||
xcb_change_gc(connection, gc, mask, values);
|
||||
}
|
||||
|
|
|
@ -8,11 +8,7 @@ class VisualLayer;
|
|||
class XcbLayerInterface
|
||||
{
|
||||
public:
|
||||
static uint32_t getColor(const Color* color);
|
||||
|
||||
static uint32_t getColor(int r, int g, int b);
|
||||
|
||||
static void modifyGcColor(xcb_connection_t* connection, xcb_gcontext_t gc, const Color* color);
|
||||
static void modifyGcColor(xcb_connection_t* connection, xcb_gcontext_t gc, const Color& color);
|
||||
|
||||
static void addLayer(xcb_connection_t* connection, xcb_screen_t* screen, xcb_window_t window, xcb_gcontext_t gc, VisualLayer* layer);
|
||||
};
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#include "XcbTextInterface.h"
|
||||
|
||||
#include "XcbLayerInterface.h"
|
||||
#include "VisualLayer.h"
|
||||
#include "Color.h"
|
||||
|
||||
|
@ -16,7 +15,7 @@ xcb_gcontext_t XcbTextInterface::GetFontGC(xcb_connection_t *connection,
|
|||
/* create graphics context */
|
||||
xcb_gcontext_t gc = xcb_generate_id(connection);
|
||||
uint32_t mask = XCB_GC_FOREGROUND | XCB_GC_BACKGROUND | XCB_GC_FONT;
|
||||
auto fillColor = XcbLayerInterface::getColor(&textElement->getFillColor());
|
||||
auto fillColor = textElement->getFillColor().getAsUInt32();
|
||||
uint32_t value_list[3] = {screen->black_pixel, fillColor, font };
|
||||
|
||||
xcb_create_gc(connection, gc, window, mask, value_list);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue