diff --git a/pl/ostype/Linux.pl b/pl/ostype/Linux.pl index 42b6397..f695e4f 100644 --- a/pl/ostype/Linux.pl +++ b/pl/ostype/Linux.pl @@ -1,8 +1,3 @@ -if (system("wayland-scanner -v >/dev/null 2>&1") == 0) { - use_backend("wayland", "x11"); -} -else { - use_backend("x11"); -} +use_backend("x11"); 1; diff --git a/src/backend/wayland.c b/src/backend/wayland.c index ea00809..2354e59 100644 --- a/src/backend/wayland.c +++ b/src/backend/wayland.c @@ -15,6 +15,7 @@ #include #else #include +#include #endif /* @@ -104,11 +105,31 @@ struct wl_pointer_listener pointer_listener = { .axis = pointer_axis, }; +static void recursive_key(MwLL handle, void* ud) { + int i; + if(handle->wayland.subwidgets != NULL) { + for(i = 0; i < arrlen(handle->wayland.subwidgets); i++) { + MwLLDispatch(handle->wayland.subwidgets[i], key, ud); + recursive_key(handle->wayland.subwidgets[i], ud); + } + } +} + +static void recursive_key_released(MwLL handle, void* ud) { + int i; + if(handle->wayland.subwidgets != NULL) { + for(i = 0; i < arrlen(handle->wayland.subwidgets); i++) { + MwLLDispatch(handle->wayland.subwidgets[i], key_released, ud); + recursive_key(handle->wayland.subwidgets[i], ud); + } + } +} + static void keyboard_keymap(void* data, struct wl_keyboard* wl_keyboard, - uint32_t format, + MwU32 format, int32_t fd, - uint32_t size) { + MwU32 size) { MwLL self = data; if(self->wayland.type == MWLL_WAYLAND_TOPLEVEL) { struct _MwLLWaylandTopLevel* wayland = self->wayland.toplevel; @@ -133,7 +154,7 @@ static void keyboard_keymap(void* data, }; static void keyboard_enter(void* data, struct wl_keyboard* wl_keyboard, - uint32_t serial, + MwU32 serial, struct wl_surface* surface, struct wl_array* keys) { MwLL self = data; @@ -141,17 +162,17 @@ static void keyboard_enter(void* data, }; static void keyboard_leave(void* data, struct wl_keyboard* wl_keyboard, - uint32_t serial, + MwU32 serial, struct wl_surface* surface) { MwLL self = data; MwLLDispatch(self, focus_out, NULL); }; static void keyboard_key(void* data, struct wl_keyboard* wl_keyboard, - uint32_t serial, - uint32_t time, - uint32_t key, - uint32_t state) { + MwU32 serial, + MwU32 time, + MwU32 key, + MwU32 state) { MwLL self = data; if(self->wayland.type == MWLL_WAYLAND_TOPLEVEL) { struct _MwLLWaylandTopLevel* wayland = self->wayland.toplevel; @@ -176,21 +197,63 @@ static void keyboard_key(void* data, for(i = 0; i < syms_num; i++) { int sym = syms_out[i]; + int key; + switch(sym) { + case XKB_KEY_BackSpace: + key = MwLLKeyBackSpace; + break; + case XKB_KEY_Left: + key = MwLLKeyLeft; + break; + case XKB_KEY_Right: + key = MwLLKeyRight; + break; + case XKB_KEY_Up: + key = MwLLKeyUp; + break; + case XKB_KEY_Down: + key = MwLLKeyDown; + break; + case XKB_KEY_Return: + key = MwLLKeyEnter; + break; + case XKB_KEY_Escape: + key = MwLLKeyEscape; + break; + case XKB_KEY_Shift_L: + key = MwLLKeyLeftShift; + break; + case XKB_KEY_Shift_R: + key = MwLLKeyRightShift; + break; + case XKB_KEY_Alt_L: + case XKB_KEY_Alt_R: + key = MwLLKeyAlt; + break; + case XKB_KEY_Control_L: + case XKB_KEY_Control_R: + key = MwLLKeyControl; + break; + default: + key = sym; + } if(state == WL_KEYBOARD_KEY_STATE_PRESSED) { - MwLLDispatch(self, key, &sym); + MwLLDispatch(self, key, &key); + recursive_key(self, &key); } else { - MwLLDispatch(self, key_released, &sym); + MwLLDispatch(self, key_released, &key); + recursive_key_released(self, &key); } } } }; static void keyboard_modifiers(void* data, struct wl_keyboard* wl_keyboard, - uint32_t serial, - uint32_t mods_depressed, - uint32_t mods_latched, - uint32_t mods_locked, - uint32_t group) {}; + MwU32 serial, + MwU32 mods_depressed, + MwU32 mods_latched, + MwU32 mods_locked, + MwU32 group) {}; struct wl_keyboard_listener keyboard_listener = { .keymap = keyboard_keymap, @@ -370,6 +433,7 @@ static MwBool egl_setup(MwLL self, int x, int y, int width, int height) { glEnable(GL_TEXTURE_2D); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); + glEnable(GL_SCISSOR_TEST); return MwTRUE; } @@ -386,6 +450,7 @@ static void egl_resetup(MwLL handle) { } glViewport(handle->wayland.x, handle->wayland.y, w, h); + glScissor(handle->wayland.x, handle->wayland.y, w, h); } static void recursive_draw(MwLL handle) { @@ -849,8 +914,6 @@ static void MwLLBeginDrawImpl(MwLL handle) { return; } } - // glClear(GL_COLOR_BUFFER_BIT); - // glClearColor(1.0, 0, 0, 1); } static void MwLLEndDrawImpl(MwLL handle) {