1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-22 05:48:01 +01:00

Added 'head' parameter to wMaximizeWindow

Additional 'head' parameter will help to select head (display) where
window should be maximized.
This commit is contained in:
2017-02-07 21:05:14 +01:00
committed by Carlos R. Mafra
parent 002d415d02
commit e2f8525728
6 changed files with 22 additions and 27 deletions

View File

@@ -359,7 +359,7 @@ void update_saved_geometry(WWindow *wwin)
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;
int new_x = 0;
@@ -393,20 +393,7 @@ void wMaximizeWindow(WWindow *wwin, int directions)
totalArea.y2 = scr->scr_height;
totalArea.x1 = 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);
}
/* Only save directions, not kbd or xinerama hints */
directions &= (MAX_HORIZONTAL | MAX_VERTICAL | MAX_LEFTHALF | MAX_RIGHTHALF | MAX_TOPHALF | MAX_BOTTOMHALF | MAX_MAXIMUS);
@@ -502,12 +489,13 @@ void handleMaximize(WWindow *wwin, int directions)
int requested = directions & (MAX_HORIZONTAL | MAX_VERTICAL | MAX_LEFTHALF | MAX_RIGHTHALF | MAX_TOPHALF | MAX_BOTTOMHALF | MAX_MAXIMUS);
int effective = requested ^ current;
int flags = directions & ~requested;
int head = wGetHeadForWindow(wwin);
if (!effective) {
/* allow wMaximizeWindow to restore the Maximusized size */
if ((wwin->flags.old_maximized & MAX_MAXIMUS) &&
!(requested & MAX_MAXIMUS))
wMaximizeWindow(wwin, MAX_MAXIMUS | flags);
wMaximizeWindow(wwin, MAX_MAXIMUS | flags, head);
else
wUnmaximizeWindow(wwin);
/* these alone mean vertical|horizontal toggle */
@@ -557,7 +545,7 @@ void handleMaximize(WWindow *wwin, int directions)
effective &= ~(MAX_TOPHALF | MAX_BOTTOMHALF);
effective &= ~MAX_MAXIMUS;
}
wMaximizeWindow(wwin, effective | flags);
wMaximizeWindow(wwin, effective | flags, head);
}
}

View File

@@ -57,7 +57,7 @@ void wSelectWindows(WScreen *scr, XEvent *ev);
void wSelectWindow(WWindow *wwin, Bool flag);
void wUnselectWindows(WScreen *scr);
void wMaximizeWindow(WWindow *wwin, int directions);
void wMaximizeWindow(WWindow *wwin, int directions, int head);
void wUnmaximizeWindow(WWindow *wwin);
void handleMaximize(WWindow *wwin, int directions);

View File

@@ -632,7 +632,8 @@ static void handleMapRequest(XEvent * ev)
if (wwin) {
wClientSetState(wwin, NormalState, None);
if (wwin->flags.maximized) {
wMaximizeWindow(wwin, wwin->flags.maximized);
wMaximizeWindow(wwin, wwin->flags.maximized,
wGetHeadForWindow(wwin));
}
if (wwin->flags.shaded) {
wwin->flags.shaded = 0;

View File

@@ -2853,7 +2853,7 @@ static void titlebarDblClick(WCoreWindow *sender, void *data, XEvent *event)
int ndir = dir ^ wwin->flags.maximized;
if (ndir != 0)
wMaximizeWindow(wwin, ndir);
wMaximizeWindow(wwin, ndir, wGetHeadForWindow(wwin));
else
wUnmaximizeWindow(wwin);
}

View File

@@ -277,7 +277,8 @@ static void execMenuCommand(WMenu * menu, WMenuEntry * entry)
if (wwin->flags.maximized)
wUnmaximizeWindow(wwin);
else
wMaximizeWindow(wwin, MAX_VERTICAL | MAX_HORIZONTAL);
wMaximizeWindow(wwin, MAX_VERTICAL | MAX_HORIZONTAL,
wGetHeadForWindow(wwin));
break;
case MC_SHADE:

View File

@@ -1120,9 +1120,11 @@ static void doStateAtom(WWindow *wwin, Atom state, int set, Bool init)
wwin->flags.maximized |= (set ? MAX_VERTICAL : 0);
} else {
if (set)
wMaximizeWindow(wwin, wwin->flags.maximized | MAX_VERTICAL);
wMaximizeWindow(wwin, wwin->flags.maximized | MAX_VERTICAL,
wGetHeadForWindow(wwin));
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) {
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);
} else {
if (set)
wMaximizeWindow(wwin, wwin->flags.maximized | MAX_HORIZONTAL);
wMaximizeWindow(wwin, wwin->flags.maximized | MAX_HORIZONTAL,
wGetHeadForWindow(wwin));
else
wMaximizeWindow(wwin, wwin->flags.maximized & ~MAX_HORIZONTAL);
wMaximizeWindow(wwin, wwin->flags.maximized & ~MAX_HORIZONTAL,
wGetHeadForWindow(wwin));
}
} else if (state == net_wm_state_hidden) {
if (set == _NET_WM_STATE_TOGGLE)
@@ -1623,7 +1627,8 @@ Bool wNETWMProcessClientMessage(XClientMessageEvent *event)
wwin->flags.maximized = maximized;
wUnmaximizeWindow(wwin);
} else {
wMaximizeWindow(wwin, wwin->flags.maximized);
wMaximizeWindow(wwin, wwin->flags.maximized,
wGetHeadForWindow(wwin));
}
}
updateStateHint(wwin, False, False);