Sun, 05 Apr 2009 08:22:22 +0000
Update hardware cursor correctly.
| 16520 | 1 | #include <gmodule.h> |
| 2 | ||
| 3 | #include "gntbox.h" | |
|
16779
006f50afb7a6
Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents:
16523
diff
changeset
|
4 | #include "gntwidget.h" |
|
006f50afb7a6
Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents:
16523
diff
changeset
|
5 | #include "gntwindow.h" |
| 16520 | 6 | #include "gntwm.h" |
|
16779
006f50afb7a6
Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents:
16523
diff
changeset
|
7 | #include "gntws.h" |
| 16520 | 8 | |
| 9 | static void | |
| 10 | widget_hide(gpointer data, gpointer nodes) | |
| 11 | { | |
| 12 | GntWidget *widget = GNT_WIDGET(data); | |
| 13 | GntNode *node = g_hash_table_lookup(nodes, widget); | |
|
16779
006f50afb7a6
Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents:
16523
diff
changeset
|
14 | if (GNT_IS_WINDOW(widget)) |
|
006f50afb7a6
Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents:
16523
diff
changeset
|
15 | gnt_window_workspace_hiding(GNT_WINDOW(widget)); |
|
22907
8186478f9ec3
Fix a possible crash when creating a new workspace.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21240
diff
changeset
|
16 | if (node) |
|
8186478f9ec3
Fix a possible crash when creating a new workspace.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21240
diff
changeset
|
17 | hide_panel(node->panel); |
| 16520 | 18 | } |
| 19 | ||
| 20 | static void | |
| 21 | widget_show(gpointer data, gpointer nodes) | |
| 22 | { | |
| 23 | GntNode *node = g_hash_table_lookup(nodes, data); | |
| 24 | GNT_WIDGET_UNSET_FLAGS(GNT_WIDGET(data), GNT_WIDGET_INVISIBLE); | |
| 25 | if (node) { | |
| 26 | show_panel(node->panel); | |
| 27 | gnt_wm_copy_win(GNT_WIDGET(data), node); | |
| 28 | } | |
| 29 | } | |
| 30 | ||
| 31 | void | |
| 32 | gnt_ws_draw_taskbar(GntWS *ws, gboolean reposition) | |
| 33 | { | |
| 34 | static WINDOW *taskbar = NULL; | |
| 35 | GList *iter; | |
| 36 | int n, width = 0; | |
| 37 | int i; | |
| 38 | ||
|
18599
7e31405a2cbb
Allow executing another application (eg. PAGER) that will use the same
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18567
diff
changeset
|
39 | if (gnt_is_refugee()) |
|
7e31405a2cbb
Allow executing another application (eg. PAGER) that will use the same
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18567
diff
changeset
|
40 | return; |
|
7e31405a2cbb
Allow executing another application (eg. PAGER) that will use the same
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18567
diff
changeset
|
41 | |
| 16520 | 42 | if (taskbar == NULL) { |
| 43 | taskbar = newwin(1, getmaxx(stdscr), getmaxy(stdscr) - 1, 0); | |
| 44 | } else if (reposition) { | |
| 45 | int Y_MAX = getmaxy(stdscr) - 1; | |
| 46 | mvwin(taskbar, Y_MAX, 0); | |
| 47 | } | |
| 48 | ||
|
21240
b78eaddaae02
Add gnt_color_pair, which will replace color codes with 'appropriate' text
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18599
diff
changeset
|
49 | wbkgdset(taskbar, '\0' | gnt_color_pair(GNT_COLOR_NORMAL)); |
| 16520 | 50 | werase(taskbar); |
| 51 | ||
| 52 | n = g_list_length(ws->list); | |
| 53 | if (n) | |
| 54 | width = getmaxx(stdscr) / n; | |
| 55 | ||
| 56 | for (i = 0, iter = ws->list; iter; iter = iter->next, i++) { | |
| 57 | GntWidget *w = iter->data; | |
| 58 | int color; | |
| 59 | const char *title; | |
| 60 | ||
| 61 | if (w == ws->ordered->data) { | |
| 62 | /* This is the current window in focus */ | |
| 63 | color = GNT_COLOR_TITLE; | |
| 64 | } else if (GNT_WIDGET_IS_FLAG_SET(w, GNT_WIDGET_URGENT)) { | |
| 65 | /* This is a window with the URGENT hint set */ | |
| 66 | color = GNT_COLOR_URGENT; | |
| 67 | } else { | |
| 68 | color = GNT_COLOR_NORMAL; | |
| 69 | } | |
|
21240
b78eaddaae02
Add gnt_color_pair, which will replace color codes with 'appropriate' text
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18599
diff
changeset
|
70 | wbkgdset(taskbar, '\0' | gnt_color_pair(color)); |
| 16520 | 71 | if (iter->next) |
|
21240
b78eaddaae02
Add gnt_color_pair, which will replace color codes with 'appropriate' text
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18599
diff
changeset
|
72 | mvwhline(taskbar, 0, width * i, ' ' | gnt_color_pair(color), width); |
| 16520 | 73 | else |
|
21240
b78eaddaae02
Add gnt_color_pair, which will replace color codes with 'appropriate' text
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18599
diff
changeset
|
74 | mvwhline(taskbar, 0, width * i, ' ' | gnt_color_pair(color), getmaxx(stdscr) - width * i); |
| 16520 | 75 | title = GNT_BOX(w)->title; |
| 76 | mvwprintw(taskbar, 0, width * i, "%s", title ? title : "<gnt>"); | |
| 77 | if (i) | |
|
21240
b78eaddaae02
Add gnt_color_pair, which will replace color codes with 'appropriate' text
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18599
diff
changeset
|
78 | mvwaddch(taskbar, 0, width *i - 1, ACS_VLINE | A_STANDOUT | gnt_color_pair(GNT_COLOR_NORMAL)); |
| 16520 | 79 | } |
| 80 | wrefresh(taskbar); | |
| 81 | } | |
| 82 | ||
| 83 | static void | |
| 84 | gnt_ws_init(GTypeInstance *instance, gpointer class) | |
| 85 | { | |
| 86 | GntWS *ws = GNT_WS(instance); | |
| 87 | ws->list = NULL; | |
| 88 | ws->ordered = NULL; | |
| 89 | ws->name = NULL; | |
| 90 | } | |
| 91 | ||
| 92 | void gnt_ws_add_widget(GntWS *ws, GntWidget* wid) | |
| 93 | { | |
|
18302
44267a021f2d
Notify a window when it loses focus because another window was moved to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18137
diff
changeset
|
94 | GntWidget *oldfocus; |
|
44267a021f2d
Notify a window when it loses focus because another window was moved to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18137
diff
changeset
|
95 | oldfocus = ws->ordered ? ws->ordered->data : NULL; |
| 16520 | 96 | ws->list = g_list_append(ws->list, wid); |
| 97 | ws->ordered = g_list_prepend(ws->ordered, wid); | |
|
18302
44267a021f2d
Notify a window when it loses focus because another window was moved to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18137
diff
changeset
|
98 | if (oldfocus) |
|
44267a021f2d
Notify a window when it loses focus because another window was moved to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18137
diff
changeset
|
99 | gnt_widget_set_focus(oldfocus, FALSE); |
| 16520 | 100 | } |
| 101 | ||
| 102 | void gnt_ws_remove_widget(GntWS *ws, GntWidget* wid) | |
| 103 | { | |
| 104 | ws->list = g_list_remove(ws->list, wid); | |
| 105 | ws->ordered = g_list_remove(ws->ordered, wid); | |
| 106 | } | |
| 107 | ||
| 108 | void | |
| 109 | gnt_ws_set_name(GntWS *ws, const gchar *name) | |
| 110 | { | |
| 111 | g_free(ws->name); | |
| 112 | ws->name = g_strdup(name); | |
| 113 | } | |
| 114 | ||
| 115 | void | |
| 116 | gnt_ws_hide(GntWS *ws, GHashTable *nodes) | |
| 117 | { | |
| 118 | g_list_foreach(ws->ordered, widget_hide, nodes); | |
| 119 | } | |
| 120 | ||
|
18567
8dd8eae7a1aa
Fix some focus issues.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18302
diff
changeset
|
121 | void gnt_ws_widget_hide(GntWidget *widget, GHashTable *nodes) |
|
8dd8eae7a1aa
Fix some focus issues.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18302
diff
changeset
|
122 | { |
| 16520 | 123 | widget_hide(widget, nodes); |
| 124 | } | |
| 125 | ||
|
18567
8dd8eae7a1aa
Fix some focus issues.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18302
diff
changeset
|
126 | void gnt_ws_widget_show(GntWidget *widget, GHashTable *nodes) |
|
8dd8eae7a1aa
Fix some focus issues.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18302
diff
changeset
|
127 | { |
| 16520 | 128 | widget_show(widget, nodes); |
| 129 | } | |
| 130 | ||
| 131 | void | |
| 132 | gnt_ws_show(GntWS *ws, GHashTable *nodes) | |
| 133 | { | |
| 134 | GList *l; | |
| 135 | for (l = g_list_last(ws->ordered); l; l = g_list_previous(l)) | |
| 136 | widget_show(l->data, nodes); | |
| 137 | } | |
| 138 | ||
| 139 | GType | |
| 140 | gnt_ws_get_gtype(void) | |
| 141 | { | |
| 142 | static GType type = 0; | |
| 143 | ||
| 144 | if(type == 0) { | |
| 145 | static const GTypeInfo info = { | |
| 146 | sizeof(GntWSClass), | |
| 147 | NULL, /* base_init */ | |
| 148 | NULL, /* base_finalize */ | |
| 149 | NULL, | |
| 150 | /*(GClassInitFunc)gnt_ws_class_init,*/ | |
| 151 | NULL, | |
| 152 | NULL, /* class_data */ | |
| 153 | sizeof(GntWS), | |
| 154 | 0, /* n_preallocs */ | |
| 155 | gnt_ws_init, /* instance_init */ | |
| 156 | NULL /* value_table */ | |
| 157 | }; | |
| 158 | ||
| 159 | type = g_type_register_static(GNT_TYPE_BINDABLE, | |
| 160 | "GntWS", | |
| 161 | &info, 0); | |
| 162 | } | |
| 163 | ||
| 164 | return type; | |
| 165 | } | |
| 166 | ||
|
18137
a8c54ed05eee
F9 to create a new workspace.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16779
diff
changeset
|
167 | GntWS *gnt_ws_new(const char *name) |
|
a8c54ed05eee
F9 to create a new workspace.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16779
diff
changeset
|
168 | { |
|
a8c54ed05eee
F9 to create a new workspace.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16779
diff
changeset
|
169 | GntWS *ws = GNT_WS(g_object_new(GNT_TYPE_WS, NULL)); |
|
a8c54ed05eee
F9 to create a new workspace.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16779
diff
changeset
|
170 | ws->name = g_strdup(name ? name : "(noname)"); |
|
a8c54ed05eee
F9 to create a new workspace.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16779
diff
changeset
|
171 | return ws; |
|
a8c54ed05eee
F9 to create a new workspace.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16779
diff
changeset
|
172 | } |
|
a8c54ed05eee
F9 to create a new workspace.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16779
diff
changeset
|
173 | |
|
16523
d774ca89d340
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16520
diff
changeset
|
174 | const char * gnt_ws_get_name(GntWS *ws) |
|
d774ca89d340
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16520
diff
changeset
|
175 | { |
|
d774ca89d340
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16520
diff
changeset
|
176 | return ws->name; |
|
d774ca89d340
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16520
diff
changeset
|
177 | } |
|
d774ca89d340
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16520
diff
changeset
|
178 |