mirror of
https://github.com/gryf/wmaker.git
synced 2026-03-11 12:05:48 +01:00
Enabling moving window in cycles.
WindowMaker have a Maximus feature expanded by ability to resize windows to half screen (horizontally and vertically). Although, there was no way to move windows between different heads (while screen is spanned between different monitors - heads - if there was no xinerama used). This patch enables possibility for moving windows between states. Assuming we have a window on first head, maximize left would make the window occupy left half of the screen. Assuming we have another head right of the first head, following scenario will be possible: - maximize right will make window occupy entire free space (just like ordinary maximizing will do) - another maximize right will make window be maximized half right of the first screen - another maximize right will make window be maximized half left on second screen - another maximize right will make window be maximized on second screen - another maximize right will make window be maximized half right on second screen - another maximize right will make no effect So it will cycle between half screen/fullscreen making window to travel from left to right. Same goes for opposite direction.
This commit is contained in:
@@ -354,7 +354,7 @@ void update_saved_geometry(WWindow *wwin)
|
|||||||
save_old_geometry(wwin, SAVE_GEOMETRY_X);
|
save_old_geometry(wwin, SAVE_GEOMETRY_X);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wMaximizeWindow(WWindow *wwin, int directions)
|
void wMaximizeWindow(WWindow *wwin, int directions, int head)
|
||||||
{
|
{
|
||||||
unsigned int new_width, new_height, half_scr_width, half_scr_height;
|
unsigned int new_width, new_height, half_scr_width, half_scr_height;
|
||||||
int new_x = 0;
|
int new_x = 0;
|
||||||
@@ -388,20 +388,7 @@ void wMaximizeWindow(WWindow *wwin, int directions)
|
|||||||
totalArea.y2 = scr->scr_height;
|
totalArea.y2 = scr->scr_height;
|
||||||
totalArea.x1 = 0;
|
totalArea.x1 = 0;
|
||||||
totalArea.y1 = 0;
|
totalArea.y1 = 0;
|
||||||
usableArea = totalArea;
|
|
||||||
|
|
||||||
if (!(directions & MAX_IGNORE_XINERAMA)) {
|
|
||||||
WScreen *scr = wwin->screen_ptr;
|
|
||||||
int head;
|
|
||||||
|
|
||||||
if (directions & MAX_KEYBOARD)
|
|
||||||
head = wGetHeadForWindow(wwin);
|
|
||||||
else
|
|
||||||
head = wGetHeadForPointerLocation(scr);
|
|
||||||
|
|
||||||
usableArea = wGetUsableAreaForHead(scr, head, &totalArea, True);
|
usableArea = wGetUsableAreaForHead(scr, head, &totalArea, True);
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Only save directions, not kbd or xinerama hints */
|
/* Only save directions, not kbd or xinerama hints */
|
||||||
directions &= (MAX_HORIZONTAL | MAX_VERTICAL | MAX_LEFTHALF | MAX_RIGHTHALF | MAX_TOPHALF | MAX_BOTTOMHALF | MAX_MAXIMUS);
|
directions &= (MAX_HORIZONTAL | MAX_VERTICAL | MAX_LEFTHALF | MAX_RIGHTHALF | MAX_TOPHALF | MAX_BOTTOMHALF | MAX_MAXIMUS);
|
||||||
@@ -497,20 +484,51 @@ void handleMaximize(WWindow *wwin, int directions)
|
|||||||
int requested = directions & (MAX_HORIZONTAL | MAX_VERTICAL | MAX_LEFTHALF | MAX_RIGHTHALF | MAX_TOPHALF | MAX_BOTTOMHALF | MAX_MAXIMUS);
|
int requested = directions & (MAX_HORIZONTAL | MAX_VERTICAL | MAX_LEFTHALF | MAX_RIGHTHALF | MAX_TOPHALF | MAX_BOTTOMHALF | MAX_MAXIMUS);
|
||||||
int effective = requested ^ current;
|
int effective = requested ^ current;
|
||||||
int flags = directions & ~requested;
|
int flags = directions & ~requested;
|
||||||
|
int head = wGetHeadForWindow(wwin);
|
||||||
|
WMPoint p;
|
||||||
|
|
||||||
if (!effective) {
|
if (!effective) {
|
||||||
/* allow wMaximizeWindow to restore the Maximusized size */
|
/* allow wMaximizeWindow to restore the Maximusized size */
|
||||||
if ((wwin->flags.old_maximized & MAX_MAXIMUS) &&
|
if ((wwin->flags.old_maximized & MAX_MAXIMUS) &&
|
||||||
!(requested & MAX_MAXIMUS))
|
!(requested & MAX_MAXIMUS))
|
||||||
wMaximizeWindow(wwin, MAX_MAXIMUS | flags);
|
wMaximizeWindow(wwin, MAX_MAXIMUS | flags, head);
|
||||||
else
|
else {
|
||||||
wUnmaximizeWindow(wwin);
|
if (requested & MAX_LEFTHALF && current & MAX_LEFTHALF) {
|
||||||
|
p.x = wwin->frame_x - 100;
|
||||||
|
p.y = 0;
|
||||||
|
|
||||||
|
if (p.x > 0) {
|
||||||
|
head = wGetHeadForPoint(wwin->screen_ptr, p);
|
||||||
|
if (head != wGetHeadForWindow(wwin)) {
|
||||||
|
effective |= MAX_RIGHTHALF;
|
||||||
|
effective |= MAX_VERTICAL;
|
||||||
|
effective &= ~(MAX_HORIZONTAL | MAX_LEFTHALF);
|
||||||
|
wMaximizeWindow(wwin, effective | flags, head);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (requested & MAX_RIGHTHALF && current & MAX_RIGHTHALF) {
|
||||||
|
p.x = wwin->frame_x + wwin->frame->core->width + 100;
|
||||||
|
p.y = 0;
|
||||||
|
head = wGetHeadForPoint(wwin->screen_ptr, p);
|
||||||
|
if (head != wGetHeadForWindow(wwin)) {
|
||||||
|
effective |= MAX_LEFTHALF;
|
||||||
|
effective |= MAX_VERTICAL;
|
||||||
|
effective &= ~(MAX_HORIZONTAL | MAX_RIGHTHALF);
|
||||||
|
wMaximizeWindow(wwin, effective | flags, head);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
/* these alone mean vertical|horizontal toggle */
|
/* these alone mean vertical|horizontal toggle */
|
||||||
} else if ((effective == MAX_LEFTHALF) ||
|
} else if ((effective == MAX_LEFTHALF) ||
|
||||||
(effective == MAX_RIGHTHALF) ||
|
(effective == MAX_RIGHTHALF) ||
|
||||||
(effective == MAX_TOPHALF) ||
|
(effective == MAX_TOPHALF) ||
|
||||||
(effective == MAX_BOTTOMHALF))
|
(effective == MAX_BOTTOMHALF))
|
||||||
wUnmaximizeWindow(wwin);
|
wUnmaximizeWindow(wwin);
|
||||||
|
else if (requested & MAX_LEFTHALF && current & MAX_RIGHTHALF)
|
||||||
|
wMaximizeWindow(wwin, (MAX_HORIZONTAL|MAX_VERTICAL), head);
|
||||||
|
else if (requested & MAX_RIGHTHALF && current & MAX_LEFTHALF)
|
||||||
|
wMaximizeWindow(wwin, (MAX_HORIZONTAL|MAX_VERTICAL), head);
|
||||||
else {
|
else {
|
||||||
if ((requested == (MAX_HORIZONTAL | MAX_VERTICAL)) ||
|
if ((requested == (MAX_HORIZONTAL | MAX_VERTICAL)) ||
|
||||||
(requested == MAX_MAXIMUS))
|
(requested == MAX_MAXIMUS))
|
||||||
@@ -552,7 +570,7 @@ void handleMaximize(WWindow *wwin, int directions)
|
|||||||
effective &= ~(MAX_TOPHALF | MAX_BOTTOMHALF);
|
effective &= ~(MAX_TOPHALF | MAX_BOTTOMHALF);
|
||||||
effective &= ~MAX_MAXIMUS;
|
effective &= ~MAX_MAXIMUS;
|
||||||
}
|
}
|
||||||
wMaximizeWindow(wwin, effective | flags);
|
wMaximizeWindow(wwin, effective | flags, head);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ void wSelectWindows(WScreen *scr, XEvent *ev);
|
|||||||
void wSelectWindow(WWindow *wwin, Bool flag);
|
void wSelectWindow(WWindow *wwin, Bool flag);
|
||||||
void wUnselectWindows(WScreen *scr);
|
void wUnselectWindows(WScreen *scr);
|
||||||
|
|
||||||
void wMaximizeWindow(WWindow *wwin, int directions);
|
void wMaximizeWindow(WWindow *wwin, int directions, int head);
|
||||||
void wUnmaximizeWindow(WWindow *wwin);
|
void wUnmaximizeWindow(WWindow *wwin);
|
||||||
void handleMaximize(WWindow *wwin, int directions);
|
void handleMaximize(WWindow *wwin, int directions);
|
||||||
|
|
||||||
|
|||||||
@@ -632,7 +632,8 @@ static void handleMapRequest(XEvent * ev)
|
|||||||
if (wwin) {
|
if (wwin) {
|
||||||
wClientSetState(wwin, NormalState, None);
|
wClientSetState(wwin, NormalState, None);
|
||||||
if (wwin->flags.maximized) {
|
if (wwin->flags.maximized) {
|
||||||
wMaximizeWindow(wwin, wwin->flags.maximized);
|
wMaximizeWindow(wwin, wwin->flags.maximized,
|
||||||
|
wGetHeadForWindow(wwin));
|
||||||
}
|
}
|
||||||
if (wwin->flags.shaded) {
|
if (wwin->flags.shaded) {
|
||||||
wwin->flags.shaded = 0;
|
wwin->flags.shaded = 0;
|
||||||
|
|||||||
@@ -2855,7 +2855,7 @@ static void titlebarDblClick(WCoreWindow *sender, void *data, XEvent *event)
|
|||||||
int ndir = dir ^ wwin->flags.maximized;
|
int ndir = dir ^ wwin->flags.maximized;
|
||||||
|
|
||||||
if (ndir != 0)
|
if (ndir != 0)
|
||||||
wMaximizeWindow(wwin, ndir);
|
wMaximizeWindow(wwin, ndir, wGetHeadForWindow(wwin));
|
||||||
else
|
else
|
||||||
wUnmaximizeWindow(wwin);
|
wUnmaximizeWindow(wwin);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -277,7 +277,8 @@ static void execMenuCommand(WMenu * menu, WMenuEntry * entry)
|
|||||||
if (wwin->flags.maximized)
|
if (wwin->flags.maximized)
|
||||||
wUnmaximizeWindow(wwin);
|
wUnmaximizeWindow(wwin);
|
||||||
else
|
else
|
||||||
wMaximizeWindow(wwin, MAX_VERTICAL | MAX_HORIZONTAL);
|
wMaximizeWindow(wwin, MAX_VERTICAL | MAX_HORIZONTAL,
|
||||||
|
wGetHeadForWindow(wwin));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MC_SHADE:
|
case MC_SHADE:
|
||||||
|
|||||||
15
src/wmspec.c
15
src/wmspec.c
@@ -1120,9 +1120,11 @@ static void doStateAtom(WWindow *wwin, Atom state, int set, Bool init)
|
|||||||
wwin->flags.maximized |= (set ? MAX_VERTICAL : 0);
|
wwin->flags.maximized |= (set ? MAX_VERTICAL : 0);
|
||||||
} else {
|
} else {
|
||||||
if (set)
|
if (set)
|
||||||
wMaximizeWindow(wwin, wwin->flags.maximized | MAX_VERTICAL);
|
wMaximizeWindow(wwin, wwin->flags.maximized | MAX_VERTICAL,
|
||||||
|
wGetHeadForWindow(wwin));
|
||||||
else
|
else
|
||||||
wMaximizeWindow(wwin, wwin->flags.maximized & ~MAX_VERTICAL);
|
wMaximizeWindow(wwin, wwin->flags.maximized & ~MAX_VERTICAL,
|
||||||
|
wGetHeadForWindow(wwin));
|
||||||
}
|
}
|
||||||
} else if (state == net_wm_state_maximized_horz) {
|
} else if (state == net_wm_state_maximized_horz) {
|
||||||
if (set == _NET_WM_STATE_TOGGLE)
|
if (set == _NET_WM_STATE_TOGGLE)
|
||||||
@@ -1132,9 +1134,11 @@ static void doStateAtom(WWindow *wwin, Atom state, int set, Bool init)
|
|||||||
wwin->flags.maximized |= (set ? MAX_HORIZONTAL : 0);
|
wwin->flags.maximized |= (set ? MAX_HORIZONTAL : 0);
|
||||||
} else {
|
} else {
|
||||||
if (set)
|
if (set)
|
||||||
wMaximizeWindow(wwin, wwin->flags.maximized | MAX_HORIZONTAL);
|
wMaximizeWindow(wwin, wwin->flags.maximized | MAX_HORIZONTAL,
|
||||||
|
wGetHeadForWindow(wwin));
|
||||||
else
|
else
|
||||||
wMaximizeWindow(wwin, wwin->flags.maximized & ~MAX_HORIZONTAL);
|
wMaximizeWindow(wwin, wwin->flags.maximized & ~MAX_HORIZONTAL,
|
||||||
|
wGetHeadForWindow(wwin));
|
||||||
}
|
}
|
||||||
} else if (state == net_wm_state_hidden) {
|
} else if (state == net_wm_state_hidden) {
|
||||||
if (set == _NET_WM_STATE_TOGGLE)
|
if (set == _NET_WM_STATE_TOGGLE)
|
||||||
@@ -1623,7 +1627,8 @@ Bool wNETWMProcessClientMessage(XClientMessageEvent *event)
|
|||||||
wwin->flags.maximized = maximized;
|
wwin->flags.maximized = maximized;
|
||||||
wUnmaximizeWindow(wwin);
|
wUnmaximizeWindow(wwin);
|
||||||
} else {
|
} else {
|
||||||
wMaximizeWindow(wwin, wwin->flags.maximized);
|
wMaximizeWindow(wwin, wwin->flags.maximized,
|
||||||
|
wGetHeadForWindow(wwin));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
updateStateHint(wwin, False, False);
|
updateStateHint(wwin, False, False);
|
||||||
|
|||||||
Reference in New Issue
Block a user