mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-19 04:20:27 +01:00
Virtual desktop code (very experiment!!!!!)
This commit is contained in:
@@ -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 */
|
||||
|
||||
@@ -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
|
||||
},
|
||||
|
||||
24
src/event.c
24
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... */
|
||||
|
||||
17
src/menu.c
17
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 */
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -307,6 +307,9 @@ wRaiseFrame(WCoreWindow *frame)
|
||||
wKWMSendEventMessage(wwin, WKWMRaiseWindow);
|
||||
}
|
||||
#endif
|
||||
#ifdef VIRTUAL_DESKTOP
|
||||
wWorkspaceRaiseEdge(frame->screen_ptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user