23 int screen = DefaultScreen(
_display);
24 ::Window parent = RootWindow(
_display, screen);
29 _window = XCreateSimpleWindow(
_display, parent, 0, 0, initInfo.width, initInfo.height, 90, 2, blackColor);
210 case XK_bracketright:
255 case XK_dead_circumflex:
293 case XK_KP_Page_Down:
344 return (event->type == ClientMessage ||
345 event->type == DestroyNotify ||
346 event->type == KeyPress ||
347 event->type == KeyRelease ||
348 event->type == ButtonPress ||
349 event->type == ButtonRelease ||
350 event->type == MotionNotify ||
351 event->type == ConfigureNotify ||
352 event->type == LeaveNotify ||
353 event->type == EnterNotify);
368 if (xEvent.type != KeyRelease) {
382 if (nextEvent.type != KeyPress) {
387 if ((nextEvent.xkey.keycode == xEvent.xkey.keycode) &&
388 (nextEvent.xkey.time - xEvent.xkey.time < 2)) {
412 switch (xEvent.type) {
428 event.key.code =
keysymToLugKey(XLookupKeysym((&xEvent.xkey), 0));
429 event.key.ctrl = (xEvent.xkey.state & ControlMask) != 0;
430 event.key.alt = (xEvent.xkey.state & Mod1Mask) != 0;
431 event.key.shift = (xEvent.xkey.state & ShiftMask) != 0;
432 event.key.system = (xEvent.xkey.state & Mod4Mask) != 0;
437 event.key.code =
keysymToLugKey(XLookupKeysym((&xEvent.xkey), 0));
438 event.key.ctrl = (xEvent.xkey.state & ControlMask) != 0;
439 event.key.alt = (xEvent.xkey.state & Mod1Mask) != 0;
440 event.key.shift = (xEvent.xkey.state & ShiftMask) != 0;
441 event.key.system = (xEvent.xkey.state & Mod4Mask) != 0;
444 case ConfigureNotify:
456 switch (xEvent.xbutton.button) {
459 event.mouse.scrollOffset.xOffset = 0;
460 event.mouse.scrollOffset.yOffset = 1;
464 event.mouse.scrollOffset.xOffset = 0;
465 event.mouse.scrollOffset.yOffset = -1;
469 event.mouse.scrollOffset.xOffset = 1;
470 event.mouse.scrollOffset.yOffset = 0;
474 event.mouse.scrollOffset.xOffset = -1;
475 event.mouse.scrollOffset.yOffset = 0;
481 event.mouse.coord.x = xEvent.xbutton.x;
482 event.mouse.coord.y = xEvent.xbutton.y;
483 event.mouse.ctrl = (xEvent.xbutton.state & ControlMask) != 0;
484 event.mouse.shift = (xEvent.xbutton.state & ShiftMask) != 0;
488 if (xEvent.xbutton.button != Button4 && xEvent.xbutton.button != Button5 &&
489 xEvent.xbutton.button != 6 && xEvent.xbutton.button != 7) {
492 event.mouse.coord.x = xEvent.xbutton.x;
493 event.mouse.coord.y = xEvent.xbutton.y;
501 event.mouse.coord.x = xEvent.xbutton.x;
502 event.mouse.coord.y = xEvent.xbutton.y;
507 event.mouse.coord.x = xEvent.xbutton.x;
508 event.mouse.coord.y = xEvent.xbutton.y;
513 event.mouse.coord.x = xEvent.xbutton.x;
514 event.mouse.coord.y = xEvent.xbutton.y;
538 Pixmap cursorPixmap = XCreatePixmap(display, window, 1, 1, 1);
539 GC graphicsContext = XCreateGC(display, cursorPixmap, 0, NULL);
540 XDrawPoint(display, cursorPixmap, graphicsContext, 0, 0);
541 XFreeGC(display, graphicsContext);
545 color.flags = DoRed | DoGreen | DoBlue;
546 color.red = color.blue = color.green = 0;
547 Cursor cursor = XCreatePixmapCursor(display, cursorPixmap, cursorPixmap, &color, &color, 0, 0);
550 XFreePixmap(display, cursorPixmap);
572 std::memset(&hints, 0,
sizeof(hints));
597 reinterpret_cast<const unsigned char*>(&hints),
constexpr uint8_t MWMHintsDecorations
Display * getDisplay() const
static Cursor createHiddenCursor(::Display *display, ::Window window)
constexpr uint8_t MWMDecorTitle
constexpr uint8_t MWMDecorResizeh
constexpr uint8_t MWMFuncMove
unsigned long decorations
bool init(const Window::InitInfo &initInfo)
bool shouldIgnoreRepeated(XEvent &xEvent)
This functions filters event depending on the value of _keyRepeat.
constexpr uint8_t MWMDecorMinimize
Key
Abstraction of keyboard keys.
Button
Abstraction of Mouse buttons.
void setMousePos(const Math::Vec2i &mousePosition)
constexpr uint8_t MWMDecorMaximize
void setWindowDecorations(Style style)
void setMouseCursorVisible(bool visible)
constexpr uint8_t MWMFuncClose
constexpr uint8_t MWMDecorBorder
Mouse entered window event.
ANativeWindow * getWindow()
bool pollEvent(lug::Window::Event &event)
static Keyboard::Key keysymToLugKey(KeySym key)
void setKeyRepeat(bool state)
static Bool selectEvents(Display *, XEvent *event, XPointer)
constexpr uint8_t MWMFuncResize
constexpr uint8_t MWMHintsFunctions
constexpr uint8_t MWMFuncMaximize
constexpr uint8_t MWMFuncMinimize
Cursor _hiddenCursor
Invisible cursor used to hide the pointer.
constexpr uint8_t MWMDecorMenu
static Mouse::Button buttonCodeToLugButton(unsigned int buttonCode)