15818
|
1
|
|
2 #include "gntwidget.h"
|
|
3 #include "gntmenu.h"
|
|
4
|
|
5 #include <panel.h>
|
|
6
|
|
7 #define GNT_TYPE_WM (gnt_wm_get_gtype())
|
|
8 #define GNT_WM(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GNT_TYPE_WM, GntWM))
|
|
9 #define GNT_WM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GNT_TYPE_WM, GntWMClass))
|
|
10 #define GNT_IS_WM(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GNT_TYPE_WM))
|
|
11 #define GNT_IS_WM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GNT_TYPE_WM))
|
|
12 #define GNT_WM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GNT_TYPE_WM, GntWMClass))
|
|
13
|
|
14 typedef enum
|
|
15 {
|
|
16 GNT_KP_MODE_NORMAL,
|
|
17 GNT_KP_MODE_RESIZE,
|
|
18 GNT_KP_MODE_MOVE,
|
|
19 } GntKeyPressMode;
|
|
20
|
|
21 typedef struct
|
|
22 {
|
|
23 GntWidget *me;
|
|
24
|
|
25 WINDOW *window;
|
|
26 int scroll;
|
|
27 PANEL *panel;
|
|
28 } GntNode;
|
|
29
|
|
30 typedef struct _GntWM GntWM;
|
|
31
|
|
32 typedef struct _GnPosition
|
|
33 {
|
|
34 int x;
|
|
35 int y;
|
|
36 } GntPosition;
|
|
37
|
|
38 /**
|
|
39 * An application can register actions which will show up in a 'start-menu' like popup
|
|
40 */
|
|
41 typedef struct _GnAction
|
|
42 {
|
|
43 const char *label;
|
|
44 void (*callback)();
|
|
45 } GntAction;
|
|
46
|
|
47 struct _GntWM
|
|
48 {
|
|
49 GntBindable inherit;
|
|
50
|
|
51 GMainLoop *loop;
|
|
52
|
|
53 GList *list; /* List of windows ordered on their creation time */
|
|
54 GList *ordered; /* List of windows ordered on their focus */
|
|
55
|
|
56 struct {
|
|
57 GntWidget *window;
|
|
58 GntWidget *tree;
|
|
59 } _list,
|
|
60 *windows, /* Window-list window */
|
|
61 *actions; /* Action-list window */
|
|
62
|
|
63 GHashTable *nodes; /* GntWidget -> GntNode */
|
|
64
|
|
65 GList *acts; /* List of actions */
|
|
66
|
|
67 /**
|
|
68 * There can be at most one menu at a time on the screen.
|
|
69 * If there is a menu being displayed, then all the keystrokes will be sent to
|
|
70 * the menu until it is closed, either when the user activates a menuitem, or
|
|
71 * presses Escape to cancel the menu.
|
|
72 */
|
|
73 GntMenu *menu; /* Currently active menu */
|
|
74
|
|
75 /**
|
|
76 * 'event_stack' will be set to TRUE when a user-event, ie. a mouse-click
|
|
77 * or a key-press is being processed. This variable will be used to determine
|
|
78 * whether to give focus to a new window.
|
|
79 */
|
|
80 gboolean event_stack;
|
|
81
|
|
82 GntKeyPressMode mode;
|
|
83
|
|
84 GHashTable *positions;
|
|
85
|
|
86 void *res1;
|
|
87 void *res2;
|
|
88 void *res3;
|
|
89 void *res4;
|
|
90 };
|
|
91
|
|
92 typedef struct _GnWMClass GntWMClass;
|
|
93
|
|
94 struct _GnWMClass
|
|
95 {
|
|
96 GntBindableClass parent;
|
|
97
|
|
98 /* This is called when a new window is shown */
|
|
99 void (*new_window)(GntWM *wm, GntWidget *win);
|
|
100
|
|
101 void (*decorate_window)(GntWM *wm, GntWidget *win);
|
|
102 /* This is called when a window is being closed */
|
|
103 gboolean (*close_window)(GntWM *wm, GntWidget *win);
|
|
104
|
|
105 /* The WM may want to confirm a size for a window first */
|
|
106 gboolean (*window_resize_confirm)(GntWM *wm, GntWidget *win, int *w, int *h);
|
|
107
|
|
108 void (*window_resized)(GntWM *wm, GntNode *node);
|
|
109
|
|
110 /* The WM may want to confirm the position of a window */
|
|
111 gboolean (*window_move_confirm)(GntWM *wm, GntWidget *win, int *x, int *y);
|
|
112
|
|
113 void (*window_moved)(GntWM *wm, GntNode *node);
|
|
114
|
|
115 /* This gets called when:
|
|
116 * - the title of the window changes
|
|
117 * - the 'urgency' of the window changes
|
|
118 */
|
|
119 void (*window_update)(GntWM *wm, GntNode *node);
|
|
120
|
|
121 /* This should usually return NULL if the keys were processed by the WM.
|
|
122 * If not, the WM can simply return the original string, which will be
|
|
123 * processed by the default WM. The custom WM can also return a different
|
|
124 * static string for the default WM to process.
|
|
125 */
|
|
126 gboolean (*key_pressed)(GntWM *wm, const char *key);
|
|
127
|
|
128 gboolean (*mouse_clicked)(GntWM *wm, GntMouseEvent event, int x, int y, GntWidget *widget);
|
|
129
|
|
130 /* Whatever the WM wants to do when a window is given focus */
|
|
131 void (*give_focus)(GntWM *wm, GntWidget *widget);
|
|
132
|
|
133 /* List of windows. Although the WM can keep a list of its own for the windows,
|
|
134 * it'd be better if there was a way to share between the 'core' and the WM.
|
|
135 */
|
|
136 /*const GList *(*window_list)();*/
|
|
137
|
|
138 void (*res1)(void);
|
|
139 void (*res2)(void);
|
|
140 void (*res3)(void);
|
|
141 void (*res4)(void);
|
|
142 };
|
|
143
|
|
144 G_BEGIN_DECLS
|
|
145
|
|
146 GType gnt_wm_get_gtype(void);
|
|
147
|
|
148 void gnt_wm_new_window(GntWM *wm, GntWidget *widget);
|
|
149
|
|
150 void gnt_wm_window_decorate(GntWM *wm, GntWidget *widget);
|
|
151
|
|
152 void gnt_wm_window_close(GntWM *wm, GntWidget *widget);
|
|
153
|
|
154 gboolean gnt_wm_process_input(GntWM *wm, const char *string);
|
|
155
|
|
156 gboolean gnt_wm_process_click(GntWM *wm, GntMouseEvent event, int x, int y, GntWidget *widget);
|
|
157
|
|
158 void gnt_wm_resize_window(GntWM *wm, GntWidget *widget, int width, int height);
|
|
159
|
|
160 void gnt_wm_move_window(GntWM *wm, GntWidget *widget, int x, int y);
|
|
161
|
|
162 void gnt_wm_update_window(GntWM *wm, GntWidget *widget);
|
|
163
|
|
164 void gnt_wm_raise_window(GntWM *wm, GntWidget *widget);
|
|
165
|
|
166 time_t gnt_wm_get_idle_time(void);
|
|
167
|
|
168 G_END_DECLS
|