gntwm.h
Go to the documentation of this file.
1 
5 /*
6  * GNT - The GLib Ncurses Toolkit
7  *
8  * GNT is the legal property of its developers, whose names are too numerous
9  * to list here. Please refer to the COPYRIGHT file distributed with this
10  * source distribution.
11  *
12  * This library is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation; either version 2 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, write to the Free Software
24  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
25  */
26 
27 #ifndef GNTWM_H
28 #define GNTWM_H
29 
30 #include "gntwidget.h"
31 #include "gntmenu.h"
32 #include "gntws.h"
33 
34 #include <panel.h>
35 #include <time.h>
36 
37 #define GNT_TYPE_WM (gnt_wm_get_gtype())
38 #define GNT_WM(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GNT_TYPE_WM, GntWM))
39 #define GNT_WM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GNT_TYPE_WM, GntWMClass))
40 #define GNT_IS_WM(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GNT_TYPE_WM))
41 #define GNT_IS_WM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GNT_TYPE_WM))
42 #define GNT_WM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GNT_TYPE_WM, GntWMClass))
43 
44 typedef enum _GntKeyPressMode
45 {
46  GNT_KP_MODE_NORMAL,
47  GNT_KP_MODE_RESIZE,
48  GNT_KP_MODE_MOVE,
49  GNT_KP_MODE_WAIT_ON_CHILD
50 } GntKeyPressMode;
51 
52 typedef struct _GntNode
53 {
54  GntWidget *me;
55 
56  WINDOW *window;
57  int scroll;
58  PANEL *panel;
59  GntWS *ws;
60 } GntNode;
61 
62 typedef struct _GntWM GntWM;
63 
64 typedef struct _GntPosition
65 {
66  int x;
67  int y;
68 } GntPosition;
69 
73 typedef struct _GntAction
74 {
75  const char *label;
76  void (*callback)(void);
77 } GntAction;
78 
79 struct _GntWM
80 {
81  GntBindable inherit;
82 
83  GMainLoop *loop;
84 
85  GList *workspaces;
86  GList *tagged; /* tagged windows */
87  GntWS *cws;
88 
89  struct {
90  GntWidget *window;
91  GntWidget *tree;
92  } _list,
93  *windows, /* Window-list window */
94  *actions; /* Action-list window */
95 
96  GHashTable *nodes; /* GntWidget -> GntNode */
97  GHashTable *name_places; /* window name -> ws*/
98  GHashTable *title_places; /* window title -> ws */
99 
100  GList *acts; /* List of actions */
101 
108  GntMenu *menu; /* Currently active menu */
109 
115  gboolean event_stack;
116 
117  GntKeyPressMode mode;
118 
119  GHashTable *positions;
120 
121  void *res1;
122  void *res2;
123  void *res3;
124  void *res4;
125 };
126 
127 typedef struct _GntWMClass GntWMClass;
128 
130 {
131  GntBindableClass parent;
132 
133  /* This is called when a new window is shown */
134  void (*new_window)(GntWM *wm, GntWidget *win);
135 
136  void (*decorate_window)(GntWM *wm, GntWidget *win);
137  /* This is called when a window is being closed */
138  gboolean (*close_window)(GntWM *wm, GntWidget *win);
139 
140  /* The WM may want to confirm a size for a window first */
141  gboolean (*window_resize_confirm)(GntWM *wm, GntWidget *win, int *w, int *h);
142 
143  void (*window_resized)(GntWM *wm, GntNode *node);
144 
145  /* The WM may want to confirm the position of a window */
146  gboolean (*window_move_confirm)(GntWM *wm, GntWidget *win, int *x, int *y);
147 
148  void (*window_moved)(GntWM *wm, GntNode *node);
149 
150  /* This gets called when:
151  * - the title of the window changes
152  * - the 'urgency' of the window changes
153  */
154  void (*window_update)(GntWM *wm, GntNode *node);
155 
156  /* This should usually return NULL if the keys were processed by the WM.
157  * If not, the WM can simply return the original string, which will be
158  * processed by the default WM. The custom WM can also return a different
159  * static string for the default WM to process.
160  */
161  gboolean (*key_pressed)(GntWM *wm, const char *key);
162 
163  gboolean (*mouse_clicked)(GntWM *wm, GntMouseEvent event, int x, int y, GntWidget *widget);
164 
165  /* Whatever the WM wants to do when a window is given focus */
166  void (*give_focus)(GntWM *wm, GntWidget *widget);
167 
168  /* List of windows. Although the WM can keep a list of its own for the windows,
169  * it'd be better if there was a way to share between the 'core' and the WM.
170  */
171  /*GList *(*window_list)();*/
172 
173  /* This is invoked whenever the terminal window is resized, or the
174  * screen session is attached to a new terminal. (ie, from the
175  * SIGWINCH callback)
176  */
177  void (*terminal_refresh)(GntWM *wm);
178 
179  void (*res1)(void);
180  void (*res2)(void);
181  void (*res3)(void);
182 };
183 
184 G_BEGIN_DECLS
185 
189 GType gnt_wm_get_gtype(void);
190 
196 void gnt_wm_add_workspace(GntWM *wm, GntWS *ws);
197 
205 gboolean gnt_wm_switch_workspace(GntWM *wm, gint n);
206 
211 gboolean gnt_wm_switch_workspace_prev(GntWM *wm);
212 
217 gboolean gnt_wm_switch_workspace_next(GntWM *wm);
218 
225 void gnt_wm_widget_move_workspace(GntWM *wm, GntWS *neww, GntWidget *widget);
226 
232 void gnt_wm_set_workspaces(GntWM *wm, GList *workspaces);
233 
241 
248 void gnt_wm_new_window(GntWM *wm, GntWidget *widget);
249 
255 void gnt_wm_window_decorate(GntWM *wm, GntWidget *widget);
256 
262 void gnt_wm_window_close(GntWM *wm, GntWidget *widget);
263 
272 gboolean gnt_wm_process_input(GntWM *wm, const char *string);
273 
284 gboolean gnt_wm_process_click(GntWM *wm, GntMouseEvent event, int x, int y, GntWidget *widget);
285 
293 void gnt_wm_resize_window(GntWM *wm, GntWidget *widget, int width, int height);
294 
302 void gnt_wm_move_window(GntWM *wm, GntWidget *widget, int x, int y);
303 
309 void gnt_wm_update_window(GntWM *wm, GntWidget *widget);
310 
316 void gnt_wm_raise_window(GntWM *wm, GntWidget *widget);
317 
321 void gnt_wm_set_event_stack(GntWM *wm, gboolean set);
322 
326 void gnt_wm_copy_win(GntWidget *widget, GntNode *node);
327 
331 time_t gnt_wm_get_idle_time(void);
332 
333 G_END_DECLS
334 #endif
Definition: gntwm.h:79
void gnt_wm_add_workspace(GntWM *wm, GntWS *ws)
Add a workspace.
void gnt_wm_raise_window(GntWM *wm, GntWidget *widget)
Raise a window.
Widget API.
void gnt_wm_move_window(GntWM *wm, GntWidget *widget, int x, int y)
Move a window.
Workspace API.
Definition: gntws.h:42
gboolean gnt_wm_switch_workspace_prev(GntWM *wm)
Switch to the previous workspace from the current one.
GntWS * gnt_wm_widget_find_workspace(GntWM *wm, GntWidget *widget)
Find the workspace that contains a specific widget.
void gnt_wm_new_window(GntWM *wm, GntWidget *widget)
Process a new window.
time_t gnt_wm_get_idle_time(void)
GntMenu * menu
There can be at most one menu at a time on the screen.
Definition: gntwm.h:108
void gnt_wm_window_close(GntWM *wm, GntWidget *widget)
Close a window.
An application can register actions which will show up in a 'start-menu' like popup.
Definition: gntwm.h:73
gboolean gnt_wm_process_click(GntWM *wm, GntMouseEvent event, int x, int y, GntWidget *widget)
Process a click event.
Menu API.
Definition: gntwm.h:52
gboolean gnt_wm_process_input(GntWM *wm, const char *string)
Process input.
G_BEGIN_DECLS GType gnt_wm_get_gtype(void)
gboolean gnt_wm_switch_workspace(GntWM *wm, gint n)
Switch to a workspace.
void gnt_wm_widget_move_workspace(GntWM *wm, GntWS *neww, GntWidget *widget)
Move a window to a specific workspace.
void gnt_wm_set_workspaces(GntWM *wm, GList *workspaces)
Set the list of workspaces .
struct _GntAction GntAction
An application can register actions which will show up in a 'start-menu' like popup.
void gnt_wm_window_decorate(GntWM *wm, GntWidget *widget)
Decorate a window.
void gnt_wm_update_window(GntWM *wm, GntWidget *widget)
Update a window.
gboolean gnt_wm_switch_workspace_next(GntWM *wm)
Switch to the next workspace from the current one.
void gnt_wm_resize_window(GntWM *wm, GntWidget *widget, int width, int height)
Resize a window.
gboolean event_stack
'event_stack' will be set to TRUE when a user-event, ie.
Definition: gntwm.h:115