mirror of https://gitlab.com/nakst/essence
process global keyboard shortcuts in desktop
This commit is contained in:
parent
482448ed40
commit
c5f2bf4ef2
|
@ -487,6 +487,23 @@ WindowTab *WindowTabMoveToNewContainer(WindowTab *tab, ContainerWindow *containe
|
|||
return newTab;
|
||||
}
|
||||
|
||||
int ProcessGlobalKeyboardShortcuts(EsElement *, EsMessage *message) {
|
||||
if (message->type == ES_MSG_KEY_DOWN) {
|
||||
bool ctrlOnly = message->keyboard.modifiers == ES_MODIFIER_CTRL;
|
||||
int scancode = message->keyboard.scancode;
|
||||
|
||||
if (ctrlOnly && scancode == ES_SCANCODE_N) {
|
||||
ApplicationInstanceCreate(APPLICATION_ID_DESKTOP_BLANK_TAB, nullptr, nullptr);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return ES_HANDLED;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ContainerWindowMessage(EsElement *element, EsMessage *message) {
|
||||
ContainerWindow *container = (ContainerWindow *) element->userData.p;
|
||||
|
||||
|
@ -518,8 +535,6 @@ int ContainerWindowMessage(EsElement *element, EsMessage *message) {
|
|||
ApplicationInstanceCreate(APPLICATION_ID_DESKTOP_BLANK_TAB, nullptr, container);
|
||||
} else if (ctrlOnly && scancode == ES_SCANCODE_W) {
|
||||
WindowTabClose(container->active);
|
||||
} else if (ctrlOnly && scancode == ES_SCANCODE_N) {
|
||||
ApplicationInstanceCreate(APPLICATION_ID_DESKTOP_BLANK_TAB, nullptr, nullptr);
|
||||
} else if (message->keyboard.modifiers == ES_MODIFIER_FLAG && scancode == ES_SCANCODE_UP_ARROW) {
|
||||
WindowSnap(container->window, false, false, SNAP_EDGE_MAXIMIZE);
|
||||
} else if (message->keyboard.modifiers == ES_MODIFIER_FLAG && scancode == ES_SCANCODE_DOWN_ARROW) {
|
||||
|
@ -541,11 +556,19 @@ int ContainerWindowMessage(EsElement *element, EsMessage *message) {
|
|||
WindowSnap(container->window, false, false, SNAP_EDGE_RIGHT);
|
||||
}
|
||||
} else {
|
||||
bool unhandled = true;
|
||||
|
||||
for (uintptr_t i = 0; i < 9; i++) {
|
||||
if (ctrlOnly && scancode == (int) (ES_SCANCODE_1 + i) && container->tabBand->items.Length() > i) {
|
||||
WindowTabActivate((WindowTab *) container->tabBand->items[i]);
|
||||
unhandled = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (unhandled) {
|
||||
ProcessGlobalKeyboardShortcuts(element, message);
|
||||
}
|
||||
}
|
||||
} else if (message->type == ES_MSG_WINDOW_RESIZED) {
|
||||
container->tabBand->preventNextTabSizeAnimation = true;
|
||||
|
@ -2034,6 +2057,7 @@ void DesktopSetup() {
|
|||
EsSyscall(ES_SYSCALL_WINDOW_SET_PROPERTY, desktop.wallpaperWindow->handle,
|
||||
ES_WINDOW_SOLID_TRUE | ES_WINDOW_SOLID_NO_BRING_TO_FRONT, 0, ES_WINDOW_PROPERTY_SOLID);
|
||||
desktop.wallpaperWindow->doNotPaint = true;
|
||||
desktop.wallpaperWindow->messageUser = ProcessGlobalKeyboardShortcuts;
|
||||
|
||||
if ((int32_t) desktop.wallpaperWindow->windowWidth != Width(screen) || (int32_t) desktop.wallpaperWindow->windowHeight != Height(screen)) {
|
||||
desktop.wallpaperWindow->windowWidth = Width(screen);
|
||||
|
@ -2527,6 +2551,8 @@ void DesktopMessage(EsMessage *message) {
|
|||
if (instance->destroy) {
|
||||
instance->destroy(instance);
|
||||
}
|
||||
} else if (message->type == ES_MSG_KEY_DOWN) {
|
||||
ProcessGlobalKeyboardShortcuts(nullptr, message);
|
||||
} else if (message->type == MSG_SETUP_DESKTOP_UI || message->type == ES_MSG_UI_SCALE_CHANGED) {
|
||||
DesktopSetup();
|
||||
}
|
||||
|
|
|
@ -329,9 +329,7 @@ void WindowManager::PressKey(unsigned scancode) {
|
|||
| ((shift | shift2) ? ES_MODIFIER_SHIFT : 0)
|
||||
| ((flag | flag2) ? ES_MODIFIER_FLAG : 0);
|
||||
|
||||
if (activeWindow) {
|
||||
Window *window = activeWindow;
|
||||
|
||||
{
|
||||
EsMessage message;
|
||||
EsMemoryZero(&message, sizeof(EsMessage));
|
||||
message.type = (scancode & K_SCANCODE_KEY_RELEASED) ? ES_MSG_KEY_UP : ES_MSG_KEY_DOWN;
|
||||
|
@ -355,7 +353,11 @@ void WindowManager::PressKey(unsigned scancode) {
|
|||
heldKeys[message.keyboard.scancode / 8] &= ~(1 << (message.keyboard.scancode % 8));
|
||||
}
|
||||
|
||||
SendMessageToWindow(window, &message);
|
||||
if (activeWindow) {
|
||||
SendMessageToWindow(activeWindow, &message);
|
||||
} else {
|
||||
desktopProcess->messageQueue.SendMessage(nullptr, &message);
|
||||
}
|
||||
}
|
||||
|
||||
done:;
|
||||
|
|
Loading…
Reference in New Issue