Skip to content

Commit

Permalink
Support _GTK_FRAME_EXTENTS (#125)
Browse files Browse the repository at this point in the history
* Advertise support for _GTK_FRAME_EXTENTS

Apply #8

* Window: Add clientFrame(), to get the eventually set CSD extents

Re-apply 8f8e6ec
"Window: Add clientFrame(), to get the eventually set CSD extents"

and 8f8e6ec
"Restore ABI compatibility broken by the previous commit"

This is necessary to allow plugins such as "move" and "grid" to accomodate CDS extents and shadow areas

* Move: account for GtkFrameExtents on CSD windows

Based on
https://bazaar.launchpad.net/~muktupavels/compiz/gtk-frame-extents/revision/4109
Note that moving CSD windows to the very top is still a little touchy about grab position
but now they can be moved to the top of the screen

* Resize: take GtkFrameExtents into account

* Resize: clean up and simplify GtkFrameExtent support

Also works better this way

* resize: Fix intermittant failures to properly maximize windows

Do not save the added GtkFrameExtent values to the stored workArea

* Window-adjust for GtkFrameExtents when maximized one direction only

Fixes issues with grid plugin generating gaps if vertical and horizontal maximization are used to permit storing previous geometry
  • Loading branch information
lukefromdc authored and soreau committed Jun 16, 2018
1 parent 80d30b6 commit b0ad06b
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 9 deletions.
5 changes: 5 additions & 0 deletions include/compiz-core.h
Original file line number Diff line number Diff line change
Expand Up @@ -979,6 +979,7 @@ struct _CompDisplay {
Atom clientListStackingAtom;

Atom frameExtentsAtom;
Atom gtkFrameExtentsAtom;
Atom frameWindowAtom;

Atom wmStateAtom;
Expand Down Expand Up @@ -2689,6 +2690,7 @@ struct _CompWindow {
DrawWindowGeometryProc drawWindowGeometry;

/* placed here to preserve ABI compat */
CompWindowExtents clientFrame;
CompWindowExtents frameInput;
};

Expand Down Expand Up @@ -2817,6 +2819,9 @@ updateTransientHint (CompWindow *w);
void
updateIconGeometry (CompWindow *w);

void
updateClientFrame (CompWindow *w);

Window
getClientLeader (CompWindow *w);

Expand Down
4 changes: 2 additions & 2 deletions plugins/move.c
Original file line number Diff line number Diff line change
Expand Up @@ -545,8 +545,8 @@ moveHandleMotionEvent (CompScreen *s,
int x, y, width, height;
int status;

x = wX + dx - w->input.left;
y = wY + dy - w->input.top;
x = (wX + dx - w->input.left) + w->clientFrame.left;
y = (wY + dy - w->input.top) + w->clientFrame.top;
width = wWidth + w->input.left + w->input.right;
height = w->input.top ? w->input.top : 1;

Expand Down
32 changes: 25 additions & 7 deletions plugins/resize.c
Original file line number Diff line number Diff line change
Expand Up @@ -323,18 +323,36 @@ resizeFinishResizing (CompDisplay *d)
}

static Region
resizeGetConstraintRegion (CompScreen *s)
resizeGetConstraintRegion (CompWindow *w, CompScreen *s)
{
Region region;
int i;
int i , TempX, TempY, TempWidth, TempHeight;

region = XCreateRegion ();
if (!region)
return NULL;

for (i = 0; i < s->nOutputDev; i++)
XUnionRectWithRegion (&s->outputDev[i].workArea, region, region);

for (i = 0; i < s->nOutputDev; i++){
/*Save the original values here*/
TempX = s->outputDev[i].workArea.x;
TempY = s->outputDev[i].workArea.y;
TempWidth = s->outputDev[i].workArea.width;
TempHeight = s->outputDev[i].workArea.height;
/*Allow for GtkFrameExtents*/
s->outputDev[i].workArea.x = s->outputDev[i].workArea.x - w->clientFrame.left;
s->outputDev[i].workArea.width = s->outputDev[i].workArea.width
+ (w->clientFrame.left + w->clientFrame.right);
s->outputDev[i].workArea.y = s->outputDev[i].workArea.y - w->clientFrame.top;
s->outputDev[i].workArea.height = s->outputDev[i].workArea.height
+ (w->clientFrame.top + w->clientFrame.bottom);

XUnionRectWithRegion (&s->outputDev[i].workArea, region, region);

/*Reset original workarea values*/
s->outputDev[i].workArea.x = TempX;
s->outputDev[i].workArea.y = TempY;
s->outputDev[i].workArea.width = TempWidth;
s->outputDev[i].workArea.height = TempHeight;
}
return region;
}

Expand Down Expand Up @@ -533,7 +551,7 @@ resizeInitiate (CompDisplay *d,
rd->lastGoodHotSpotY = -1;
rd->lastGoodWidth = w->serverWidth;
rd->lastGoodHeight = w->serverHeight;
rd->constraintRegion = resizeGetConstraintRegion (w->screen);
rd->constraintRegion = resizeGetConstraintRegion (w, w->screen);
}
else
{
Expand Down
1 change: 1 addition & 0 deletions src/display.c
Original file line number Diff line number Diff line change
Expand Up @@ -2136,6 +2136,7 @@ addDisplay (const char *name)
XInternAtom (dpy, "_NET_CLIENT_LIST_STACKING", 0);

d->frameExtentsAtom = XInternAtom (dpy, "_NET_FRAME_EXTENTS", 0);
d->gtkFrameExtentsAtom = XInternAtom (dpy, "_GTK_FRAME_EXTENTS", 0);
d->frameWindowAtom = XInternAtom (dpy, "_NET_FRAME_WINDOW", 0);

d->wmStateAtom = XInternAtom (dpy, "WM_STATE", 0);
Expand Down
7 changes: 7 additions & 0 deletions src/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -1539,6 +1539,13 @@ handleEvent (CompDisplay *d,
if (w)
updateIconGeometry (w);
}
else if (event->xproperty.atom == d->gtkFrameExtentsAtom)
{
w = findWindowAtDisplay (d, event->xproperty.window);
if (w)
updateClientFrame (w);
}

else if (event->xproperty.atom == d->winOpacityAtom)
{
w = findWindowAtDisplay (d, event->xproperty.window);
Expand Down
1 change: 1 addition & 0 deletions src/screen.c
Original file line number Diff line number Diff line change
Expand Up @@ -1246,6 +1246,7 @@ addSupportedAtoms (CompScreen *s,

atoms[count++] = d->wmUserTimeAtom;
atoms[count++] = d->frameExtentsAtom;
atoms[count++] = d->gtkFrameExtentsAtom;
atoms[count++] = d->frameWindowAtom;

atoms[count++] = d->winStateAtom;
Expand Down
59 changes: 59 additions & 0 deletions src/window.c
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,40 @@ updateIconGeometry (CompWindow *w)
}
}

void
updateClientFrame (CompWindow *w)
{
Atom actual;
int result, format;
unsigned long n, left;
unsigned char *data;

w->clientFrame.left = 0;
w->clientFrame.right = 0;
w->clientFrame.top = 0;
w->clientFrame.bottom = 0;

result = XGetWindowProperty (w->screen->display->display, w->id,
w->screen->display->gtkFrameExtentsAtom,
0L, 65536, False, XA_CARDINAL,
&actual, &format, &n, &left, &data);

if (result == Success && data)
{
if (n == 4 && actual == XA_CARDINAL)
{
unsigned long *extents = *(unsigned long **) &data;

w->clientFrame.left = extents[0];
w->clientFrame.right = extents[1];
w->clientFrame.top = extents[2];
w->clientFrame.bottom = extents[3];
}

XFree (data);
}
}

static Window
getClientLeaderOfAncestor (CompWindow *w)
{
Expand Down Expand Up @@ -2392,6 +2426,7 @@ addWindow (CompScreen *screen,

recalcWindowActions (w);
updateIconGeometry (w);
updateClientFrame (w);

if (w->shaded)
resizeWindow (w,
Expand Down Expand Up @@ -3815,6 +3850,30 @@ addWindowSizeChanges (CompWindow *w,
oldBorderWidth);
getWorkareaForOutput (w->screen, output, &workArea);

/*Adjust for GtkFrameExtents when maximized one direction only
* ****
*FIXME: if a theme author sets different shadow dimensions for
*the .tiled style class this will break and left/right tiled
*windows end up oversize. That is not normal theming practice
*but is a potential source of a bug. Fixing this right may require
*supporting _GTK_EDGE_CONSTRAINTS as in Mutter
*/
if (!(w->state & CompWindowStateMaximizedVertMask) &&
(w->state & CompWindowStateMaximizedHorzMask)){
workArea.x = workArea.x - w ->clientFrame.left;
workArea.width = workArea.width +
w ->clientFrame.left + w ->clientFrame.right;

}

if ((w->state & CompWindowStateMaximizedVertMask) &&
!(w->state & CompWindowStateMaximizedHorzMask)){
workArea.y = workArea.y - w ->clientFrame.top;
workArea.height = workArea.height +
w ->clientFrame.top + w ->clientFrame.bottom;

}

if (w->type & CompWindowTypeFullscreenMask)
{
saveWindowGeometryFF (w);
Expand Down

0 comments on commit b0ad06b

Please sign in to comment.