Newer
Older
Olivier Fourdan
committed
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
Olivier Fourdan
committed
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Olivier Fourdan
committed
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA.
#endif
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <glib.h>
#include <stdlib.h>
#include <stdio.h>
#include <glib.h>
#include <libxfce4util/libxfce4util.h>
static void
xfwmWindowSetVisual (xfwmWindow * win, Visual *visual, gint depth)
{
if (visual)
{
win->visual = visual;
}
else
{
if (depth)
{
win->depth = depth;
}
else
{
win->window = None;
win->map = FALSE;
win->x = 0;
win->y = 0;
#ifdef HAVE_RENDER
win->pict_format = NULL;
#endif
xfwmWindowCreate (ScreenInfo * screen_info, Visual *visual, gint depth, Window parent,
xfwmWindow * win, long eventmask, Cursor cursor)
XSetWindowAttributes attributes;
unsigned long valuemask;
attributes.event_mask = eventmask;
valuemask = 0L;
if (eventmask != NoEventMask)
{
valuemask |= CWEventMask;
}
win->window = XCreateWindow (myScreenGetXDisplay (screen_info),
parent, 0, 0, 1, 1, 0, 0,
InputOutput, CopyFromParent,
valuemask, &attributes);
TRACE ("Created XID 0x%lx", win->window);
if (cursor != None)
XDefineCursor (myScreenGetXDisplay (screen_info),
xfwmWindowSetVisual (win, visual, depth);
#ifdef HAVE_RENDER
win->pict_format = XRenderFindVisualFormat (myScreenGetXDisplay (screen_info), win->visual);
#endif
if (win->window != None)
XDestroyWindow (myScreenGetXDisplay (win->screen_info),
Olivier Fourdan
committed
win->window = None;
xfwmWindowShow (xfwmWindow * win, int x, int y, int width, int height,
if (!(win->window))
Olivier Fourdan
committed
return;
if ((width < 1) || (height < 1))
Olivier Fourdan
committed
return;
if (!(win->map))
XMapWindow (myScreenGetXDisplay (win->screen_info),
Olivier Fourdan
committed
win->map = TRUE;
TRACE ("Showing XID 0x%lx", win->window);
if (((x != win->x) || (y != win->y)) && ((width != win->width)
|| (height != win->height)))
XMoveResizeWindow (myScreenGetXDisplay (win->screen_info),
win->window, x, y,
Olivier Fourdan
committed
win->x = x;
win->y = y;
win->width = width;
win->height = height;
else if ((x != win->x) || (y != win->y))
XMoveWindow (myScreenGetXDisplay (win->screen_info),
win->window,
Olivier Fourdan
committed
if (refresh)
{
XClearWindow (myScreenGetXDisplay (win->screen_info),
Olivier Fourdan
committed
}
win->x = x;
win->y = y;
else if ((width != win->width) || (height != win->height))
XResizeWindow (myScreenGetXDisplay (win->screen_info),
win->window,
win->width = width;
win->height = height;
else if (refresh)
XClearWindow (myScreenGetXDisplay (win->screen_info),
XUnmapWindow (myScreenGetXDisplay (win->screen_info), win->window);
Olivier Fourdan
committed
win->map = FALSE;
gboolean
{
g_return_val_if_fail (win, FALSE);
return win->map;
gboolean
{
g_return_val_if_fail (win, TRUE);
void
xfwmWindowTemp (ScreenInfo *screen_info, Visual *visual,
xfwmWindow * win,
int x, int y, int width, int height,
Olivier Fourdan
committed
long eventmask,
gboolean bottom)
{
XSetWindowAttributes attributes;
attributes.event_mask = eventmask;
attributes.override_redirect = TRUE;
win->window = XCreateWindow (myScreenGetXDisplay (screen_info),
parent, x, y, width, height, 0, 0,
CWEventMask | CWOverrideRedirect,
Olivier Fourdan
committed
if (bottom)
{
XLowerWindow (myScreenGetXDisplay (screen_info), win->window);
}
else
{
XRaiseWindow (myScreenGetXDisplay (screen_info), win->window);
}
XMapWindow (myScreenGetXDisplay (screen_info), win->window);
win->map = TRUE;
win->x = x;
win->y = y;
win->width = width;
win->height = height;
xfwmWindowSetVisual (win, visual, depth);
static gboolean
xfwmWindowCopyComposite (xfwmWindow * win, xfwmPixmap * pix)
#ifdef HAVE_RENDER
if (myDisplayHaveRender (win->screen_info->display_info))
Picture pict;
TRACE ("xfwmWindowCopyComposite: Pixmap picture does not exist");
return FALSE;
}
if (!win->pict_format)
TRACE ("xfwmWindowCopyComposite: Window picture format is unknown");
return FALSE;
temp = XCreatePixmap (myScreenGetXDisplay (win->screen_info),
win->window,
if (!temp)
{
return FALSE;
}
pict = XRenderCreatePicture (myScreenGetXDisplay (win->screen_info),
temp, win->pict_format, 0, NULL);
if (!pict)
{
XFreePixmap (myScreenGetXDisplay (win->screen_info), temp);
return FALSE;
}
XRenderComposite (myScreenGetXDisplay (win->screen_info), PictOpSrc, pix->pict, None, pict, 0, 0, 0, 0, 0, 0, pix->width, pix->height);
XRenderFreePicture (myScreenGetXDisplay (win->screen_info), pict);
XSetWindowBackgroundPixmap (myScreenGetXDisplay (win->screen_info), win->window, temp);
XFreePixmap (myScreenGetXDisplay (win->screen_info), temp);
return TRUE;
}
return FALSE;
}
void
xfwmWindowSetBG (xfwmWindow * win, xfwmPixmap * pix)
{
if ((win->width < 1) || (win->height < 1) || (pix->width < 1) || (pix->height < 1))
{
return;
}
#ifdef HAVE_RENDER
if ((win->visual != win->screen_info->visual) ||
(win->depth != win->screen_info->depth))
{
done = xfwmWindowCopyComposite (win, pix);
if (!done)
{
/* Use the good old way */
XSetWindowBackgroundPixmap (myScreenGetXDisplay (win->screen_info), win->window, pix->pixmap);
}