]> icculus.org git repositories - mikachu/openbox.git/blob - obrender/button.c
Move some more code around to make it shorter
[mikachu/openbox.git] / obrender / button.c
1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
2
3    button.c for the Openbox window manager
4    Copyright (c) 2012        Mikael Magnusson
5    Copyright (c) 2012        Dana Jansens
6
7    This program is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 2 of the License, or
10    (at your option) any later version.
11
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16
17    See the COPYING file for a copy of the GNU General Public License.
18 */
19
20 #include "render.h"
21 #include "instance.h"
22 #include "mask.h"
23
24 #include <X11/Xlib.h>
25 #include <X11/Xutil.h>
26 #include <string.h>
27
28 RrButton *RrButtonNew (const RrInstance *inst)
29 {
30     RrButton *out = NULL;
31
32     /* no need to alloc colors and masks, set them null (for freeing later) */
33     out = g_new0(RrButton, 1);
34     out->inst = inst;
35
36     /* allocate appearances */
37     out->a_focused_unpressed = RrAppearanceNew(inst, 1);
38     out->a_unfocused_unpressed = RrAppearanceNew(inst, 1);
39     out->a_focused_pressed = RrAppearanceNew(inst, 1);
40     out->a_unfocused_pressed = RrAppearanceNew(inst, 1);
41     out->a_focused_disabled = RrAppearanceNew(inst, 1);
42     out->a_unfocused_disabled = RrAppearanceNew(inst, 1);
43     out->a_focused_hover = RrAppearanceNew(inst, 1);
44     out->a_unfocused_hover = RrAppearanceNew(inst, 1);
45     out->a_focused_unpressed_toggled = RrAppearanceNew(inst, 1);
46     out->a_unfocused_unpressed_toggled = RrAppearanceNew(inst, 1);
47     out->a_focused_pressed_toggled = RrAppearanceNew(inst, 1);
48     out->a_unfocused_pressed_toggled = RrAppearanceNew(inst, 1);
49     out->a_focused_hover_toggled = RrAppearanceNew(inst, 1);
50     out->a_unfocused_hover_toggled = RrAppearanceNew(inst, 1);
51
52     return out;
53 }
54
55 void RrButtonFree(RrButton *b)
56 {
57     /* colors */
58     RrColorFree(b->focused_unpressed_color);
59     RrColorFree(b->unfocused_unpressed_color);
60     RrColorFree(b->focused_pressed_color);
61     RrColorFree(b->unfocused_pressed_color);
62     RrColorFree(b->focused_disabled_color);
63     RrColorFree(b->unfocused_disabled_color);
64     RrColorFree(b->focused_hover_color);
65     RrColorFree(b->unfocused_hover_color);
66     RrColorFree(b->focused_hover_toggled_color);
67     RrColorFree(b->unfocused_hover_toggled_color);
68     RrColorFree(b->focused_pressed_toggled_color);
69     RrColorFree(b->unfocused_pressed_toggled_color);
70     RrColorFree(b->focused_unpressed_toggled_color);
71     RrColorFree(b->unfocused_unpressed_toggled_color);
72
73     /* masks */
74     RrPixmapMaskFree(b->unpressed_mask);
75     RrPixmapMaskFree(b->pressed_mask);
76     RrPixmapMaskFree(b->disabled_mask);
77     RrPixmapMaskFree(b->hover_mask);
78     RrPixmapMaskFree(b->unpressed_toggled_mask);
79     RrPixmapMaskFree(b->hover_toggled_mask);
80     RrPixmapMaskFree(b->pressed_toggled_mask);
81
82     /* appearances */
83     RrAppearanceFree(b->a_focused_unpressed);
84     RrAppearanceFree(b->a_unfocused_unpressed);
85     RrAppearanceFree(b->a_focused_pressed);
86     RrAppearanceFree(b->a_unfocused_pressed);
87     RrAppearanceFree(b->a_focused_disabled);
88     RrAppearanceFree(b->a_unfocused_disabled);
89     RrAppearanceFree(b->a_focused_hover);
90     RrAppearanceFree(b->a_unfocused_hover);
91     RrAppearanceFree(b->a_focused_unpressed_toggled);
92     RrAppearanceFree(b->a_unfocused_unpressed_toggled);
93     RrAppearanceFree(b->a_focused_pressed_toggled);
94     RrAppearanceFree(b->a_unfocused_pressed_toggled);
95     RrAppearanceFree(b->a_focused_hover_toggled);
96     RrAppearanceFree(b->a_unfocused_hover_toggled);
97 }