aboutsummaryrefslogtreecommitdiffstats
path: root/matchbox2/core/mb-wm-decor.h
blob: 6adeadff7d761b3bc3938631409d2ea581ceb47b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
/*
 *  Matchbox Window Manager II - A lightweight window manager not for the
 *                               desktop.
 *
 *  Authored By Matthew Allum <mallum@o-hand.com>
 *
 *  Copyright (c) 2005 OpenedHand Ltd - http://o-hand.com
 *
 *  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.
 *
 *  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.
 *
 */

#ifndef _HAVE_MB_WM_DECOR_H
#define _HAVE_MB_WM_DECOR_H

#define MB_WM_DECOR(c) ((MBWMDecor*)(c))
#define MB_WM_DECOR_CLASS(c) ((MBWMDecorClass*)(c))
#define MB_WM_TYPE_DECOR (mb_wm_decor_class_type ())


#define MB_WM_DECOR_BUTTON(c) ((MBWMDecorButton*)(c))
#define MB_WM_DECOR_BUTTON_CLASS(c) ((MBWMDecorButtonClass*)(c))
#define MB_WM_TYPE_DECOR_BUTTON (mb_wm_decor_button_class_type ())

typedef void (*MBWMDecorButtonPressedFunc) (MBWindowManager   *wm,
					    MBWMDecorButton   *button,
					    void              *userdata);

typedef void (*MBWMDecorButtonReleasedFunc) (MBWindowManager   *wm,
					     MBWMDecorButton   *button,
					     void              *userdata);


typedef void (*MBWMDecorDestroyUserData)       (MBWMDecor *, void *);
typedef void (*MBWMDecorButtonDestroyUserData) (MBWMDecorButton *, void *);

typedef enum MBWMDecorDirtyState
{
  MBWMDecorDirtyNot   = 0,
  MBWMDecorDirtyTitle = (1<<0),
  MBWMDecorDirtyPaint = (1<<1),

  MBWMDecorDirtyFull  = 0xffffffff,
} MBWMDecorDirtyState;

struct MBWMDecor
{
  MBWMObject                parent;
  MBWMDecorType             type;
  Window                    xwin;
  MBWindowManagerClient    *parent_client;
  MBGeometry                geom;
  MBWMDecorDirtyState       dirty;
  Bool                      absolute_packing;
  MBWMList                 *buttons;
  int                       pack_start_x;
  int                       pack_end_x;

  unsigned long             press_cb_id;
  unsigned long             release_cb_id;

  void                     *themedata;
  MBWMDecorDestroyUserData  destroy_themedata;
};

struct MBWMDecorClass
{
  MBWMObjectClass        parent;
};


MBWMDecor*
mb_wm_decor_new (MBWindowManager     *wm,
		 MBWMDecorType        type);

void
mb_wm_decor_handle_repaint (MBWMDecor *decor);

void
mb_wm_decor_handle_resize (MBWMDecor *decor);

Window
mb_wm_decor_get_x_window (MBWMDecor *decor);

MBWMDecorType
mb_wm_decor_get_type (MBWMDecor *decor);

int
mb_wm_decor_get_pack_start_x (MBWMDecor *decor);

int
mb_wm_decor_get_pack_end_x (MBWMDecor *decor);

const MBGeometry*
mb_wm_decor_get_geometry (MBWMDecor *decor);

MBWindowManagerClient*
mb_wm_decor_get_parent (MBWMDecor *decor);

void
mb_wm_decor_mark_dirty (MBWMDecor *decor);

void
mb_wm_decor_mark_title_dirty (MBWMDecor *decor);

MBWMDecorDirtyState
mb_wm_decor_get_dirty_state (MBWMDecor *decor);

void
mb_wm_decor_attach (MBWMDecor             *decor,
		    MBWindowManagerClient *client);

void
mb_wm_decor_detach (MBWMDecor *decor);

void
mb_wm_decor_set_theme_data (MBWMDecor * decor, void *userdata,
			    MBWMDecorDestroyUserData destroy);

void *
mb_wm_decor_get_theme_data (MBWMDecor* decor);

typedef enum MBWMDecorButtonState
{
  MBWMDecorButtonStateInactive = 0,
  MBWMDecorButtonStatePressed

} MBWMDecorButtonState ;

typedef enum MBWMDecorButtonType
{
  MBWMDecorButtonCustom     = 0,
  MBWMDecorButtonClose      = 1,
  MBWMDecorButtonMenu       = 2,
  MBWMDecorButtonMinimize   = 3,
  MBWMDecorButtonFullscreen = 4,
  MBWMDecorButtonAccept     = 5,
  MBWMDecorButtonHelp       = 6,
} MBWMDecorButtonType;

typedef enum MBWMDecorButtonPack
  {
    MBWMDecorButtonPackStart = 0,
    MBWMDecorButtonPackEnd   = 1,
  }
MBWMDecorButtonPack;

struct MBWMDecorButton
{
  MBWMObject                  parent;
  MBWMDecorButtonType         type;
  MBWMDecorButtonPack         pack;
  MBWMDecor                  *decor;

  MBGeometry                  geom;

  /* in priv ? */
  Bool                        visible;
  Bool                        needs_sync;
  Bool                        realized;
  Bool                        press_activated;
  MBWMDecorButtonState        state;

  MBWMDecorButtonPressedFunc  press;
  MBWMDecorButtonReleasedFunc release;

  unsigned long               press_cb_id;

  /* Data for any custom button callbacks */
  void                       *userdata;
  MBWMDecorButtonDestroyUserData destroy_userdata;

  /* Data utilized by the theme engine */
  void                       *themedata;
  MBWMDecorButtonDestroyUserData destroy_themedata;

};

struct MBWMDecorButtonClass
{
  MBWMObjectClass   parent;

  /*
     show;
     hide;
     realize; ??
  */
};

void
mb_wm_decor_button_show (MBWMDecorButton *button);

void
mb_wm_decor_button_hide (MBWMDecorButton *button);

void
mb_wm_decor_button_move_to (MBWMDecorButton *button, int x, int y);

void
mb_wm_decor_button_handle_repaint (MBWMDecorButton *button);

MBWMDecorButton*
mb_wm_decor_button_new (MBWindowManager               *wm,
			MBWMDecorButtonType            type,
			MBWMDecorButtonPack            pack,
			MBWMDecor                     *decor,
			MBWMDecorButtonPressedFunc     press,
			MBWMDecorButtonReleasedFunc    release,
			MBWMDecorButtonFlags           flags);


MBWMDecorButton*
mb_wm_decor_button_stock_new (MBWindowManager            *wm,
			      MBWMDecorButtonType         type,
			      MBWMDecorButtonPack         pack,
			      MBWMDecor                  *decor,
			      MBWMDecorButtonFlags        flags);

void
mb_wm_decor_button_set_user_data (MBWMDecorButton * button, void *userdata,
				  MBWMDecorButtonDestroyUserData destroy);

void *
mb_wm_decor_button_get_user_data (MBWMDecorButton * button);

void
mb_wm_decor_button_set_theme_data (MBWMDecorButton * button, void *themedata,
				   MBWMDecorButtonDestroyUserData destroy);

void *
mb_wm_decor_button_get_theme_data (MBWMDecorButton* button);

#endif