Skip to content

Commit

Permalink
Window: Add clientFrame(), to get the eventually set CSD extents
Browse files Browse the repository at this point in the history
This only supports GTK+ at the moment, but it might be adapted to
other toolkits.
  • Loading branch information
3v1n0 authored and XRevan86 committed Mar 18, 2016
1 parent 92cb144 commit be31466
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
4 changes: 4 additions & 0 deletions include/compiz-core.h
Original file line number Diff line number Diff line change
Expand Up @@ -2639,6 +2639,7 @@ struct _CompWindow {

CompWindowExtents input;
CompWindowExtents output;
CompWindowExtents clientFrame;

CompStruts *struts;

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

void
updateClientFrame (CompWindow *w);

Window
getClientLeader (CompWindow *w);

Expand Down
6 changes: 6 additions & 0 deletions src/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -1544,6 +1544,12 @@ handleEvent (CompDisplay *d,
if (w)
updateIconGeometry (w);
}
else if (event->xproperty.atom == d->frameGtkExtentsAtom)
{
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
37 changes: 37 additions & 0 deletions src/window.c
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,42 @@ updateIconGeometry (CompWindow *w)
}
}

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

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

if (result == Success && actual == XA_CARDINAL && data)
{
if (n == 4)
{
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);
}
else
{
w->clientFrame.left = 0;
w->clientFrame.right = 0;
w->clientFrame.top = 0;
w->clientFrame.bottom = 0;
}
}

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

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

if (w->shaded)
resizeWindow (w,
Expand Down

0 comments on commit be31466

Please sign in to comment.