Set up stacked widget.
This commit is contained in:
parent
4e85edacc8
commit
ee51f3ee09
51 changed files with 808 additions and 195 deletions
|
@ -149,6 +149,7 @@ void XcbInterface::ShowWindow(mt::Window* window)
|
|||
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_POINTER_MOTION;
|
||||
}
|
||||
|
||||
|
@ -226,6 +227,21 @@ void XcbInterface::OnButtonPress(xcb_button_press_event_t* event, DesktopManager
|
|||
desktopManager->OnUiEvent(std::move(ui_event));
|
||||
}
|
||||
|
||||
void XcbInterface::OnButtonRelease(xcb_button_release_event_t* event, DesktopManager* desktopManager)
|
||||
{
|
||||
auto ui_event = MouseEvent::Create();
|
||||
auto x = static_cast<unsigned>(event->event_x);
|
||||
auto y = static_cast<unsigned>(event->event_y);
|
||||
ui_event->SetClientLocation(DiscretePoint(x, y));
|
||||
|
||||
auto screen_x = static_cast<unsigned>(event->root_x);
|
||||
auto screen_y = static_cast<unsigned>(event->root_y);
|
||||
ui_event->SetScreenLocation(DiscretePoint(x, y));
|
||||
|
||||
ui_event->SetAction(MouseEvent::Action::Released);
|
||||
desktopManager->OnUiEvent(std::move(ui_event));
|
||||
}
|
||||
|
||||
void XcbInterface::LoopOpenGl(DesktopManager* desktopManager)
|
||||
{
|
||||
int running = 1;
|
||||
|
@ -311,7 +327,6 @@ void XcbInterface::Loop(DesktopManager* desktopManager)
|
|||
OnKeyPress(kr, desktopManager);
|
||||
break;
|
||||
}
|
||||
|
||||
case XCB_KEY_RELEASE: {
|
||||
auto kr = reinterpret_cast<xcb_key_release_event_t*>(event);
|
||||
OnKeyRelease(kr, desktopManager);
|
||||
|
@ -322,6 +337,11 @@ void XcbInterface::Loop(DesktopManager* desktopManager)
|
|||
OnButtonPress(press, desktopManager);
|
||||
break;
|
||||
}
|
||||
case XCB_BUTTON_RELEASE: {
|
||||
auto release = reinterpret_cast<xcb_button_release_event_t*>(event);
|
||||
OnButtonRelease(release, desktopManager);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
/* Unknown event type, ignore it */
|
||||
break;
|
||||
|
|
|
@ -76,6 +76,8 @@ private:
|
|||
|
||||
void OnButtonPress(xcb_button_press_event_t* event, DesktopManager*);
|
||||
|
||||
void OnButtonRelease(xcb_button_press_event_t* event, DesktopManager*);
|
||||
|
||||
void MapWindow(mt::Window* window);
|
||||
|
||||
void CreateGraphicsContext();
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
#include "XcbTextInterface.h"
|
||||
#include "XcbLayerInterface.h"
|
||||
#include <string.h>
|
||||
|
||||
xcb_gcontext_t XcbTextInterface::GetFontGC(xcb_connection_t *connection,
|
||||
xcb_screen_t *screen, xcb_window_t window, const char*font_name)
|
||||
xcb_screen_t *screen, xcb_window_t window, const char*font_name,
|
||||
const TextElement* textElement)
|
||||
{
|
||||
/* get font */
|
||||
xcb_font_t font = xcb_generate_id(connection);
|
||||
|
@ -11,7 +13,8 @@ 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;
|
||||
uint32_t value_list[3] = {screen->black_pixel, screen->white_pixel, font };
|
||||
auto fillColor = XcbLayerInterface::GetColor(textElement->GetFillColor());
|
||||
uint32_t value_list[3] = {screen->black_pixel, fillColor, font };
|
||||
|
||||
xcb_create_gc(connection, gc, window, mask, value_list);
|
||||
|
||||
|
@ -26,7 +29,7 @@ void XcbTextInterface::AddTextElement(xcb_connection_t* connection,
|
|||
{
|
||||
/* get graphics context */
|
||||
xcb_gcontext_t gc = XcbTextInterface::GetFontGC(connection, screen, window,
|
||||
textElement->GetFontLabel().c_str());
|
||||
textElement->GetFontLabel().c_str(), textElement);
|
||||
|
||||
/* draw the text */
|
||||
std::string content = textElement->GetContent();
|
||||
|
|
|
@ -6,7 +6,8 @@ class XcbTextInterface
|
|||
{
|
||||
public:
|
||||
static xcb_gcontext_t GetFontGC(xcb_connection_t* connection,
|
||||
xcb_screen_t*screen, xcb_window_t window, const char*font_name);
|
||||
xcb_screen_t*screen, xcb_window_t window, const char*font_name,
|
||||
const TextElement* textElement);
|
||||
|
||||
static void AddTextElement(xcb_connection_t* connection,
|
||||
xcb_screen_t* screen, xcb_window_t window,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue