From 8eb0c79c542553d114da557c7153b0649aa5501e Mon Sep 17 00:00:00 2001 From: id Date: Sat, 18 Dec 1999 11:52:49 +0000 Subject: [PATCH] Virtual desktop code (very experiment!!!!!) --- src/WindowMaker.h | 8 ++++ src/defaults.c | 17 ++++++++ src/event.c | 24 ++++++++++++ src/menu.c | 17 ++++++++ src/screen.c | 7 ++++ src/screen.h | 7 ++++ src/stacking.c | 3 ++ src/workspace.c | 99 +++++++++++++++++++++++++++++++++++++++++++++++ src/workspace.h | 10 +++++ 9 files changed, 192 insertions(+) diff --git a/src/WindowMaker.h b/src/WindowMaker.h index c780e99a..3bbcb740 100644 --- a/src/WindowMaker.h +++ b/src/WindowMaker.h @@ -360,6 +360,14 @@ typedef struct WPreferences { char ws_advance; /* Create new workspace and advance */ +#ifdef VIRTUAL_DESKTOP + unsigned int vedge_thickness; + unsigned int vedge_hscrollspeed; + unsigned int vedge_vscrollspeed; + unsigned int vedge_height; /* could be change to workspace specific one day */ + unsigned int vedge_width; +#endif + char ws_cycle; /* Cycle existing workspaces */ char save_session_on_exit; /* automatically save session on exit */ diff --git a/src/defaults.c b/src/defaults.c index 4d0051c1..b0c14d74 100644 --- a/src/defaults.c +++ b/src/defaults.c @@ -410,6 +410,23 @@ WDefaultEntry optionList[] = { {"WorkspaceNameDisplayPosition", "center", seDisplayPositions, &wPreferences.workspace_name_display_position, getEnum, NULL }, +#ifdef VIRTUAL_DESKTOP + {"VirtualEdgeThickness", "1", NULL, + &wPreferences.vedge_thickness, getInt, NULL + }, + {"VirtualEdgeHorizonScrollSpeed", "1", NULL, + &wPreferences.vedge_hscrollspeed, getInt, NULL + }, + {"VirtualEdgeVerticalScrollSpeed", "1", NULL, + &wPreferences.vedge_vscrollspeed, getInt, NULL + }, + {"VirtualEdgeWidth", "2000", NULL, + &wPreferences.vedge_width, getInt, NULL + }, + {"VirtualEdgeHeight", "2000", NULL, + &wPreferences.vedge_height, getInt, NULL + }, +#endif {"StickyIcons", "NO", NULL, &wPreferences.sticky_icons, getBool, setStickyIcons }, diff --git a/src/event.c b/src/event.c index d3902689..5aa5eaee 100644 --- a/src/event.c +++ b/src/event.c @@ -968,6 +968,30 @@ handleEnterNotify(XEvent *event) #ifdef DEBUG L("got enter notify"); #endif + +#ifdef VIRTUAL_DESKTOP + if (wPreferences.vedge_thickness) { + int x,y; + if (event->xcrossing.window == scr->virtual_edge_r) { + XWarpPointer(dpy, None, scr->root_win, 0,0,0,0, scr->scr_width - wPreferences.vedge_thickness - 1, event->xcrossing.y_root); + wWorkspaceGetViewPosition(scr, scr->current_workspace, &x, &y); + wWorkspaceSetViewPort(scr, scr->current_workspace, x+30, y); + } else if (event->xcrossing.window == scr->virtual_edge_l) { + XWarpPointer(dpy, None, scr->root_win, 0,0,0,0, wPreferences.vedge_thickness + 1, event->xcrossing.y_root); + wWorkspaceGetViewPosition(scr, scr->current_workspace, &x, &y); + wWorkspaceSetViewPort(scr, scr->current_workspace, x-30, y); + } else if (event->xcrossing.window == scr->virtual_edge_u) { + XWarpPointer(dpy, None, scr->root_win, 0,0,0,0, event->xcrossing.x_root, wPreferences.vedge_thickness + 1); + wWorkspaceGetViewPosition(scr, scr->current_workspace, &x, &y); + wWorkspaceSetViewPort(scr, scr->current_workspace, x, y-30); + } else if (event->xcrossing.window == scr->virtual_edge_d) { + XWarpPointer(dpy, None, scr->root_win, 0,0,0,0, event->xcrossing.x_root, scr->scr_height - wPreferences.vedge_thickness - 1); + wWorkspaceGetViewPosition(scr, scr->current_workspace, &x, &y); + wWorkspaceSetViewPort(scr, scr->current_workspace, x, y+30); + } + } +#endif + if (XCheckTypedWindowEvent(dpy, event->xcrossing.window, LeaveNotify, &ev)) { /* already left the window... */ diff --git a/src/menu.c b/src/menu.c index 451f6c98..d0f8d342 100644 --- a/src/menu.c +++ b/src/menu.c @@ -1612,6 +1612,23 @@ getScrollAmount(WMenu *menu, int *hamount, int *vamount) getPointerPosition(scr, &xroot, &yroot); +#ifdef VIRTUAL_DESKTOP + if (wPreferences.vedge_thickness) { + if (xroot <= wPreferences.vedge_thickness + 1 && menuX1 < wPreferences.vedge_thickness) { + /* scroll to the right */ + *hamount = MIN(MENU_SCROLL_STEP, abs(menuX1)); + + } else if (xroot >= screenW-2-wPreferences.vedge_thickness && menuX2 > screenW-1-wPreferences.vedge_thickness) { + /* scroll to the left */ + *hamount = MIN(MENU_SCROLL_STEP, abs(menuX2-screenW-1)); + + if (*hamount==0) + *hamount = 1; + + *hamount = -*hamount; + } + } else +#endif if (xroot <= 1 && menuX1 < 0) { /* scroll to the right */ diff --git a/src/screen.c b/src/screen.c index d83e273d..6c42109a 100644 --- a/src/screen.c +++ b/src/screen.c @@ -1035,6 +1035,13 @@ wScreenRestoreState(WScreen *scr) wWorkspaceRestoreState(scr); +#ifdef VIRTUAL_DESKTOP + /* + * * create inputonly windows at the border of screen + * */ + wWorkspaceManageEdge(scr); +#endif + if (!wPreferences.flags.nodock) { state = PLGetDictionaryEntry(scr->session_state, dDock); scr->dock = wDockRestoreState(scr, state, WM_DOCK); diff --git a/src/screen.h b/src/screen.h index 5654f073..fc81aa5d 100644 --- a/src/screen.h +++ b/src/screen.h @@ -69,6 +69,13 @@ typedef struct _WScreen { int scr_width; /* size of the screen */ int scr_height; +#ifdef VIRTUAL_DESKTOP + Window virtual_edge_u; + Window virtual_edge_d; + Window virtual_edge_l; + Window virtual_edge_r; +#endif + Window root_win; /* root window of screen */ int depth; /* depth of the default visual */ Colormap colormap; /* root colormap */ diff --git a/src/stacking.c b/src/stacking.c index 3f9e706f..e7c90cad 100644 --- a/src/stacking.c +++ b/src/stacking.c @@ -307,6 +307,9 @@ wRaiseFrame(WCoreWindow *frame) wKWMSendEventMessage(wwin, WKWMRaiseWindow); } #endif +#ifdef VIRTUAL_DESKTOP + wWorkspaceRaiseEdge(frame->screen_ptr); +#endif } diff --git a/src/workspace.c b/src/workspace.c index 486aa41f..a8637fcf 100644 --- a/src/workspace.c +++ b/src/workspace.c @@ -63,6 +63,9 @@ extern XContext wWinContext; static proplist_t dWorkspaces=NULL; static proplist_t dClip, dName; +#ifdef VIRTUAL_DESKTOP +static BOOL initVDesk=False; +#endif static void make_keys() @@ -631,6 +634,102 @@ wWorkspaceForceChange(WScreen *scr, int workspace) /* XSync(dpy, False); */ } +#ifdef VIRTUAL_DESKTOP + +void wWorkspaceManageEdge(WScreen *scr) { + int i; + int vmask; + XSetWindowAttributes attribs; + + puts("ok"); + if (wPreferences.vedge_thickness) { + initVDesk=True; + for (i = 0;i < scr->workspace_count; i++) { + puts("reset workspace"); + scr->workspaces[i]->x = scr->workspaces[i]->y = 0; + wWorkspaceResizeViewPort(scr, i, wPreferences.vedge_width, wPreferences.vedge_height); + } + + vmask = CWEventMask|CWOverrideRedirect; + attribs.event_mask = (EnterWindowMask | LeaveWindowMask | VisibilityChangeMask); + attribs.override_redirect = True; + scr->virtual_edge_u = + XCreateWindow(dpy, scr->root_win, 0, 0, + scr->scr_width, wPreferences.vedge_thickness, 0, + CopyFromParent, InputOnly, CopyFromParent, vmask, &attribs); + scr->virtual_edge_d = + XCreateWindow(dpy, scr->root_win, 0, scr->scr_height-wPreferences.vedge_thickness, + scr->scr_width, wPreferences.vedge_thickness, 0, + CopyFromParent, InputOnly, CopyFromParent, vmask, &attribs); + scr->virtual_edge_l = + XCreateWindow(dpy, scr->root_win, 0, 0, + wPreferences.vedge_thickness, scr->scr_height, 0, + CopyFromParent, InputOnly, CopyFromParent, vmask, &attribs); + scr->virtual_edge_r = + XCreateWindow(dpy, scr->root_win, scr->scr_width-wPreferences.vedge_thickness, 0, + wPreferences.vedge_thickness, scr->scr_height, 0, + CopyFromParent, InputOnly, CopyFromParent, vmask, &attribs); + XMapWindow(dpy, scr->virtual_edge_u); + XMapWindow(dpy, scr->virtual_edge_d); + XMapWindow(dpy, scr->virtual_edge_l); + XMapWindow(dpy, scr->virtual_edge_r); + wWorkspaceRaiseEdge(scr); + } +} + +void wWorkspaceRaiseEdge(WScreen *scr) { + if (wPreferences.vedge_thickness && initVDesk) { + XRaiseWindow(dpy, scr->virtual_edge_u); + XRaiseWindow(dpy, scr->virtual_edge_d); + XRaiseWindow(dpy, scr->virtual_edge_l); + XRaiseWindow(dpy, scr->virtual_edge_r); + } +} + +void wWorkspaceResizeViewPort(WScreen *scr, int workspace, int width, int height) +{ + if (width < scr->scr_width) return; + if (height < scr->scr_height) return; + + scr->workspaces[workspace]->width = WMAX(width,scr->scr_width); + scr->workspaces[workspace]->height = WMAX(height,scr->scr_height); + +} + +void wWorkspaceSetViewPort(WScreen *scr, int workspace, int x, int y) +{ + int diff_x, diff_y; + WWindow *wwin; + + if (x < 0) return; + if (y < 0) return; + if (x + scr->scr_width > scr->workspaces[workspace]->width) return; + if (y + scr->scr_height > scr->workspaces[workspace]->height) return; + + diff_x = scr->workspaces[workspace]->x - x; + diff_y = scr->workspaces[workspace]->y - y; + + scr->workspaces[workspace]->x = WMIN(x, scr->workspaces[workspace]->width - scr->scr_width); + scr->workspaces[workspace]->y = WMIN(y, scr->workspaces[workspace]->height - scr->scr_height); + + printf("set view %d %d, %d\n",workspace, scr->workspaces[workspace]->x, scr->workspaces[workspace]->y); + + wwin = scr->focused_window; + while (wwin) { + if (wwin->frame->workspace == workspace) { + wWindowMove(wwin, wwin->frame_x + diff_x, wwin->frame_y + diff_y); + wWindowSynthConfigureNotify(wwin); + } + wwin = wwin->prev; + } +} + +void wWorkspaceGetViewPosition(WScreen *scr, int workspace, int *x, int *y) { + *x = scr->workspaces[workspace]->x; + *y = scr->workspaces[workspace]->y; +} + +#endif static void switchWSCommand(WMenu *menu, WMenuEntry *entry) diff --git a/src/workspace.h b/src/workspace.h index e5793fde..63d65572 100644 --- a/src/workspace.h +++ b/src/workspace.h @@ -27,6 +27,9 @@ typedef struct WWorkspace { char *name; +#ifdef VIRTUAL_DESKTOP + int x ,y, width, height; +#endif struct WDock *clip; } WWorkspace; @@ -35,6 +38,13 @@ int wWorkspaceNew(WScreen *scr); Bool wWorkspaceDelete(WScreen *scr, int workspace); void wWorkspaceChange(WScreen *scr, int workspace); void wWorkspaceForceChange(WScreen *scr, int workspace); +#ifdef VIRTUAL_DESKTOP +void wWorkspaceManageEdge(WScreen *scr); +void wWorkspaceRaiseEdge(WScreen *scr); +void wWorkspaceResizeViewPort(WScreen *scr, int workspace, int width, int height); +void wWorkspaceSetViewPort(WScreen *scr, int workspace, int x, int y); +void wWorkspaceGetViewPosition(WScreen *scr, int workspace, int *x, int *y); +#endif WMenu *wWorkspaceMenuMake(WScreen *scr, Bool titled);