Wayland cOMPositor written in C++ using Louvre.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

[feat] 0.4.2 handle WKeyboard with LScene

Sunglas b7ea4ecb 928853e6

+5 -53
+4 -52
src/WKeyboard.cpp
··· 9 9 * ======================================================================== */ 10 10 #include "WKeyboard.hpp" 11 11 #include "prelude.hpp" 12 + #include "global.hpp" 13 + #include <LScene.h> 12 14 #include <LClient.h> 13 15 #include <LCompositor.h> 14 16 #include <LCursor.h> ··· 24 26 25 27 void WKeyboard::keyEvent(U32 keyCode, KeyState keyState) noexcept 26 28 { 27 - sendKeyEvent(keyCode, keyState); 28 - 29 - /* === TODO: refactor this monstrosity === */ 30 - let L_CTRL = isKeyCodePressed(KEY_LEFTCTRL); 31 - let L_SHIFT = isKeyCodePressed(KEY_LEFTSHIFT); 32 - let mods = isKeyCodePressed(KEY_LEFTALT) && L_CTRL; 33 - let sym = keySymbol(keyCode); 34 - 35 - if (keyState == Released) { 36 - if (keyCode == KEY_F1 and not mods) { 37 - // launches weston-terminal 38 - LLauncher::launch("weston-terminal"); 39 - } else if (L_CTRL and (sym == XKB_KEY_q or sym == XKB_KEY_Q)) { 40 - // terminates client connection 41 - if (focus()) 42 - focus()->client()->destroy(); 43 - } else if (L_CTRL and (sym == XKB_KEY_m or sym == XKB_KEY_M)) { 44 - // minimizes currently focused surface 45 - if (focus() != nullptr and 46 - focus()->toplevel() != nullptr and 47 - not focus()->toplevel()->fullscreen()) 48 - focus()->setMinimized(true); 49 - } else if (L_CTRL and L_SHIFT and keyCode == KEY_3) { 50 - if (cursor()->output()->bufferTexture(0) != nullptr) 51 - cursor()->output()->bufferTexture(0)->save( 52 - "/tmp/image.png"); 53 - } else if (keyCode == KEY_ESC and L_CTRL and L_SHIFT) { 54 - compositor()->finish(); 55 - return; 56 - } else if (L_CTRL and not L_SHIFT) { 57 - seat()->dndManager()->setPreferredAction( 58 - LDNDManager::Copy); 59 - } else if (not L_CTRL and L_SHIFT) { 60 - seat()->dndManager()->setPreferredAction( 61 - LDNDManager::Move); 62 - } else if (not L_CTRL and not L_SHIFT) { 63 - seat()->dndManager()->setPreferredAction( 64 - LDNDManager::NoAction); 65 - } else { // keypress 66 - // ctrl sets copy as the preferred action in a drag & 67 - // drop session 68 - if (L_CTRL) { 69 - seat()->dndManager()->setPreferredAction( 70 - LDNDManager::Copy); 71 - } else if (L_SHIFT) { // shift sets the preferred action 72 - // in a drag & drop session 73 - seat()->dndManager()->setPreferredAction( 74 - LDNDManager::Move); 75 - } 76 - } 77 - } 29 + G::scene()->handleKeyEvent(keyCode, keyState); 78 30 } 79 31 80 32 void WKeyboard::keyModifiersEvent(U32 depressed, U32 latched, U32 locked, 81 33 U32 group) noexcept 82 34 { 83 - sendModifiersEvent(depressed, latched, locked, group); 35 + G::scene()->handleKeyModifiersEvent(depressed, latched, locked, group); 84 36 }
+1 -1
src/main.cpp
··· 5 5 * GitHub Repo: https://github.com/diego-est/womp 6 6 * Author: Diego A. Estrada Rivera 7 7 * License: GPL-3.0 8 - * Version: 0.4.1 8 + * Version: 0.4.2 9 9 * 10 10 * ======================================================================== */ 11 11 #include "WCompositor.hpp"