move tab to left/right of screen

This commit is contained in:
nakst 2021-10-04 14:35:17 +01:00
parent 291ba3f373
commit c6a611fd42
3 changed files with 29 additions and 8 deletions

View File

@ -821,16 +821,35 @@ int WindowTabMessage(EsElement *element, EsMessage *message) {
EsElementSetDisabled(band->GetChild(0), false); EsElementSetDisabled(band->GetChild(0), false);
} else if (message->type == ES_MSG_MOUSE_RIGHT_CLICK) { } else if (message->type == ES_MSG_MOUSE_RIGHT_CLICK) {
EsMenu *menu = EsMenuCreate(tab, ES_FLAGS_DEFAULT); EsMenu *menu = EsMenuCreate(tab, ES_FLAGS_DEFAULT);
uint64_t disableIfOnlyTab = tab->container->tabBand->items.Length() == 1 ? ES_ELEMENT_DISABLED : ES_FLAGS_DEFAULT;
EsMenuAddItem(menu, ES_FLAGS_DEFAULT, INTERFACE_STRING(DesktopCloseTab), [] (EsMenu *, EsGeneric context) { EsMenuAddItem(menu, ES_FLAGS_DEFAULT, INTERFACE_STRING(DesktopCloseTab), [] (EsMenu *, EsGeneric context) {
WindowTabClose((WindowTab *) context.p); WindowTabClose((WindowTab *) context.p);
}, tab); }, tab);
if (tab->container->tabBand->items.Length() > 1) { EsMenuAddItem(menu, disableIfOnlyTab, INTERFACE_STRING(DesktopMoveTabToNewWindow), [] (EsMenu *, EsGeneric context) {
EsMenuAddItem(menu, ES_FLAGS_DEFAULT, INTERFACE_STRING(DesktopMoveTabToNewWindow), [] (EsMenu *, EsGeneric context) {
WindowTabMoveToNewContainer((WindowTab *) context.p, nullptr, 0, 0); WindowTabMoveToNewContainer((WindowTab *) context.p, nullptr, 0, 0);
}, tab); }, tab);
}
EsMenuAddItem(menu, disableIfOnlyTab, INTERFACE_STRING(DesktopMoveTabToNewWindowSplitLeft), [] (EsMenu *, EsGeneric context) {
WindowTab *oldTab = (WindowTab *) context.p;
EsWindow *oldWindow = oldTab->window;
WindowTab *newTab = WindowTabMoveToNewContainer(oldTab, nullptr, 0, 0);
if (!newTab) return;
if (oldWindow->isMaximised) WindowRestore(oldWindow, false);
WindowSnap(oldWindow, false, false, SNAP_EDGE_RIGHT);
WindowSnap(newTab->window, false, false, SNAP_EDGE_LEFT);
}, tab);
EsMenuAddItem(menu, disableIfOnlyTab, INTERFACE_STRING(DesktopMoveTabToNewWindowSplitRight), [] (EsMenu *, EsGeneric context) {
WindowTab *oldTab = (WindowTab *) context.p;
EsWindow *oldWindow = oldTab->window;
WindowTab *newTab = WindowTabMoveToNewContainer(oldTab, nullptr, 0, 0);
if (!newTab) return;
if (oldWindow->isMaximised) WindowRestore(oldWindow, false /* we immediately move the window after this */);
WindowSnap(oldWindow, false, false, SNAP_EDGE_LEFT);
WindowSnap(newTab->window, false, false, SNAP_EDGE_RIGHT);
}, tab);
if (EsKeyboardIsShiftHeld()) { if (EsKeyboardIsShiftHeld()) {
EsMenuAddSeparator(menu); EsMenuAddSeparator(menu);

View File

@ -554,14 +554,14 @@ void WindowSnap(EsWindow *window, bool restored, bool dragging, uint8_t edge) {
} }
} }
void WindowRestore(EsWindow *window) { void WindowRestore(EsWindow *window, bool dynamic = true) {
if (!window->restoreOnNextMove) { if (!window->restoreOnNextMove) {
return; return;
} }
window->isMaximised = false; window->isMaximised = false;
window->restoreOnNextMove = false; window->restoreOnNextMove = false;
EsSyscall(ES_SYSCALL_WINDOW_MOVE, window->handle, (uintptr_t) &window->beforeMaximiseBounds, 0, ES_WINDOW_MOVE_DYNAMIC); EsSyscall(ES_SYSCALL_WINDOW_MOVE, window->handle, (uintptr_t) &window->beforeMaximiseBounds, 0, dynamic ? ES_WINDOW_MOVE_DYNAMIC : ES_FLAGS_DEFAULT);
} }
void WindowChangeBounds(int direction, int newX, int newY, int *originalX, int *originalY, EsWindow *window, void WindowChangeBounds(int direction, int newX, int newY, int *originalX, int *originalY, EsWindow *window,

View File

@ -97,7 +97,9 @@ DEFINE_INTERFACE_STRING(DesktopNotResponding, "The application is not responding
DEFINE_INTERFACE_STRING(DesktopConfirmShutdown, "Are you sure you want to turn off your computer? All applications will be closed."); DEFINE_INTERFACE_STRING(DesktopConfirmShutdown, "Are you sure you want to turn off your computer? All applications will be closed.");
DEFINE_INTERFACE_STRING(DesktopCloseTab, "Close tab"); DEFINE_INTERFACE_STRING(DesktopCloseTab, "Close tab");
DEFINE_INTERFACE_STRING(DesktopMoveTabToNewWindow, "Move to new window"); DEFINE_INTERFACE_STRING(DesktopMoveTabToNewWindow, "Move tab to new window");
DEFINE_INTERFACE_STRING(DesktopMoveTabToNewWindowSplitLeft, "Move tab to left of screen");
DEFINE_INTERFACE_STRING(DesktopMoveTabToNewWindowSplitRight, "Move tab to right of screen");
DEFINE_INTERFACE_STRING(DesktopInspectUI, "Inspect UI"); DEFINE_INTERFACE_STRING(DesktopInspectUI, "Inspect UI");
DEFINE_INTERFACE_STRING(DesktopCloseWindow, "Close window"); DEFINE_INTERFACE_STRING(DesktopCloseWindow, "Close window");
DEFINE_INTERFACE_STRING(DesktopCloseAllTabs, "Close all tabs"); DEFINE_INTERFACE_STRING(DesktopCloseAllTabs, "Close all tabs");