Remove useless tab_border option.
[awesome.git] / common / swindow.c
blob0ae2b1ae2ee89fee0b91cece48060a2789ad01cf
1 /*
2 * swindow.c - simple window handling functions
4 * Copyright © 2008 Julien Danjou <julien@danjou.info>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 #include "common/swindow.h"
24 #include "common/util.h"
26 /** Create a simple window
27 * \param disp Display ref
28 * \param phys_screen physical screen id
29 * \param x x coordinate
30 * \param y y coordinate
31 * \param w width
32 * \param h height
33 * \param border_width window's border width
34 * \return pointer to a SimpleWindow
36 SimpleWindow *
37 simplewindow_new(Display *disp, int phys_screen, int x, int y,
38 unsigned int w, unsigned int h,
39 unsigned int border_width)
41 XSetWindowAttributes wa;
42 SimpleWindow *sw;
44 sw = p_new(SimpleWindow, 1);
46 sw->geometry.x = x;
47 sw->geometry.y = y;
48 sw->geometry.width = w;
49 sw->geometry.height = h;
50 sw->display = disp;
52 wa.event_mask = SubstructureRedirectMask | SubstructureNotifyMask
53 | EnterWindowMask | LeaveWindowMask | StructureNotifyMask;
54 wa.override_redirect = 1;
55 wa.background_pixmap = ParentRelative;
56 wa.event_mask = ButtonPressMask | ExposureMask;
57 sw->window = XCreateWindow(disp,
58 RootWindow(disp, phys_screen),
59 x, y, w, h,
60 border_width,
61 DefaultDepth(disp, phys_screen),
62 CopyFromParent,
63 DefaultVisual(disp, phys_screen),
64 CWOverrideRedirect | CWBackPixmap | CWEventMask,
65 &wa);
67 sw->drawable = XCreatePixmap(disp,
68 RootWindow(disp, phys_screen),
69 w, h,
70 DefaultDepth(disp, phys_screen));
71 return sw;
74 /** Destroy a simple window and all its resources
75 * \param sw the SimpleWindow to delete
77 void
78 simplewindow_delete(SimpleWindow *sw)
80 XDestroyWindow(sw->display, sw->window);
81 XFreePixmap(sw->display, sw->drawable);
82 p_delete(&sw);
85 /** Move a simple window
86 * \param sw the SimpleWindow to move
87 * \param x x coordinate
88 * \param y y coordinate
89 * \return status
91 int
92 simplewindow_move(SimpleWindow *sw, int x, int y)
94 sw->geometry.x = x;
95 sw->geometry.y = y;
96 return XMoveWindow(sw->display, sw->window, x, y);
99 /** Refresh the window content
100 * \param sw the SimpleWindow to refresh
101 * \param phys_screen physical screen id
102 * \return status
105 simplewindow_refresh_drawable(SimpleWindow *sw, int phys_screen)
107 return XCopyArea(sw->display, sw->drawable,
108 sw->window,
109 DefaultGC(sw->display, phys_screen), 0, 0,
110 sw->geometry.width,
111 sw->geometry.height,
112 0, 0);
115 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80