--- a/gntmain.c Wed Apr 24 04:24:43 2019 +0000
+++ b/gntmain.c Wed Apr 24 21:54:50 2019 -0400
@@ -50,6 +50,8 @@
+#include "gntwsprivate.h" @@ -158,8 +160,9 @@
GntWidget *widget = NULL;
- if (!wm->cws->ordered || buffer[0] != 27)
+ if (gnt_ws_is_empty(wm->cws) || buffer[0] != 27) { @@ -214,7 +217,7 @@
if (event == GNT_LEFT_MOUSE_DOWN && widget &&
widget != wm->_list.window && !gnt_widget_get_transient(widget)) {
- if (widget != wm->cws->ordered->data) {
+ if (!gnt_ws_is_top_widget(wm->cws, widget)) { gnt_wm_raise_window(wm, widget);
if (y == widget->priv.y) {
@@ -707,7 +710,7 @@
if (widget == wm->_list.window)
- if (wm->cws->ordered && wm->cws->ordered->data == widget) {
+ if (gnt_ws_is_top_widget(wm->cws, widget)) { if (GNT_IS_BOX(widget) &&
(GNT_BOX(widget)->active == w || widget == w))
@@ -719,8 +722,9 @@
widget = gnt_widget_get_toplevel(widget);
- if (wm->cws->ordered && wm->cws->ordered->data == widget)
+ if (gnt_ws_is_top_widget(wm->cws, widget)) { gnt_widget_set_is_urgent(widget, TRUE);
--- a/gntwm.c Wed Apr 24 04:24:43 2019 +0000
+++ b/gntwm.c Wed Apr 24 21:54:50 2019 -0400
@@ -60,6 +60,8 @@
+#include "gntwsprivate.h" #define IDLE_CHECK_INTERVAL 5 /* 5 seconds */
@@ -106,14 +108,6 @@
G_DEFINE_TYPE(GntWM, gnt_wm, GNT_TYPE_BINDABLE)
-g_list_bring_to_front(GList *list, gpointer data)
- list = g_list_remove(list, data);
- list = g_list_prepend(list, data);
@@ -417,14 +411,15 @@
if (wm->_list.window || wm->menu)
- if (!wm->cws->ordered || !wm->cws->ordered->next)
+ if (gnt_ws_is_empty(wm->cws) || gnt_ws_is_single(wm->cws)) { if (wm->mode != GNT_KP_MODE_NORMAL) {
- w = wm->cws->ordered->data;
+ w = gnt_ws_get_top_widget(wm->cws); orgpos = pos = g_list_index(wm->cws->list, w);
g_return_if_fail(pos >= 0);
@@ -467,8 +462,9 @@
+ if (gnt_ws_is_empty(wm->cws)) { n = GPOINTER_TO_INT(list->data);
@@ -490,10 +486,11 @@
+ if (gnt_ws_is_empty(wm->cws)) { - window = wm->cws->ordered->data;
+ window = gnt_ws_get_top_widget(wm->cws); node = g_hash_table_lookup(wm->nodes, window);
@@ -514,10 +511,11 @@
+ if (gnt_ws_is_empty(wm->cws)) { - window = wm->cws->ordered->data;
+ window = gnt_ws_get_top_widget(wm->cws); node = g_hash_table_lookup(wm->nodes, window);
@@ -539,8 +537,8 @@
- if (wm->cws->ordered) {
- gnt_widget_destroy(wm->cws->ordered->data);
+ if (!gnt_ws_is_empty(wm->cws)) { + gnt_widget_destroy(gnt_ws_get_top_widget(wm->cws)); @@ -622,7 +620,7 @@
window_list_key_pressed(GntWidget *widget, const char *text, GntWM *wm)
- if (text[1] == 0 && wm->cws->ordered) {
+ if (text[1] == 0 && !gnt_ws_is_empty(wm->cws)) { GntBindable *sel = gnt_tree_get_selection_data(GNT_TREE(widget));
@@ -664,10 +662,11 @@
populate_window_list(wm, workspace);
- gnt_tree_set_selected(GNT_TREE(tree), wm->cws->ordered->data);
+ if (!gnt_ws_is_empty(wm->cws)) { + gnt_tree_set_selected(GNT_TREE(tree), gnt_ws_get_top_widget(wm->cws)); + } else if (workspace) { gnt_tree_set_selected(GNT_TREE(tree), wm->cws);
g_signal_connect(G_OBJECT(tree), "activate", G_CALLBACK(window_list_activate), wm);
g_signal_connect(G_OBJECT(tree), "key_pressed", G_CALLBACK(window_list_key_pressed), wm);
@@ -688,8 +687,9 @@
if (wm->_list.window || wm->menu)
+ if (gnt_ws_is_empty(wm->cws)) { list_of_windows(wm, FALSE);
@@ -887,8 +887,8 @@
all = g_list_delete_link(all, list);
gnt_ws_draw_taskbar(wm->cws, FALSE);
- if (wm->cws->ordered) {
- GntWidget *w = wm->cws->ordered->data;
+ if (!gnt_ws_is_empty(wm->cws)) { + GntWidget *w = gnt_ws_get_top_widget(wm->cws); GntNode *node = g_hash_table_lookup(wm->nodes, w);
@@ -903,10 +903,11 @@
+ if (gnt_ws_is_empty(wm->cws)) { - shift_window(wm, wm->cws->ordered->data, -1);
+ shift_window(wm, gnt_ws_get_top_widget(wm->cws), -1); @@ -918,10 +919,11 @@
+ if (gnt_ws_is_empty(wm->cws)) { - shift_window(wm, wm->cws->ordered->data, 1);
+ shift_window(wm, gnt_ws_get_top_widget(wm->cws), 1); @@ -1055,8 +1057,9 @@
ensure_normal_mode(GntWM *wm)
if (wm->mode != GNT_KP_MODE_NORMAL) {
- window_reverse(wm->cws->ordered->data, FALSE, wm);
+ if (!gnt_ws_is_empty(wm->cws)) { + window_reverse(gnt_ws_get_top_widget(wm->cws), FALSE, wm); wm->mode = GNT_KP_MODE_NORMAL;
@@ -1067,11 +1070,12 @@
GntWM *wm = GNT_WM(bindable);
if (wm->_list.window || wm->menu)
+ if (gnt_ws_is_empty(wm->cws)) { wm->mode = GNT_KP_MODE_MOVE;
- window_reverse(GNT_WIDGET(wm->cws->ordered->data), TRUE, wm);
+ window_reverse(gnt_ws_get_top_widget(wm->cws), TRUE, wm); @@ -1082,11 +1086,12 @@
GntWM *wm = GNT_WM(bindable);
if (wm->_list.window || wm->menu)
+ if (gnt_ws_is_empty(wm->cws)) { wm->mode = GNT_KP_MODE_RESIZE;
- window_reverse(GNT_WIDGET(wm->cws->ordered->data), TRUE, wm);
+ window_reverse(gnt_ws_get_top_widget(wm->cws), TRUE, wm); @@ -1120,7 +1125,7 @@
g_hash_table_foreach(wm->nodes, (GHFunc)refresh_node, GINT_TO_POINTER(TRUE));
g_signal_emit(wm, signals[SIG_TERMINAL_REFRESH], 0);
- for (iter = g_list_last(wm->cws->ordered); iter; iter = iter->prev) {
+ for (iter = gnt_ws_get_last(wm->cws); iter; iter = iter->prev) { GntWidget *w = iter->data;
GntNode *node = g_hash_table_lookup(wm->nodes, w);
@@ -1175,9 +1180,10 @@
+ if (gnt_ws_is_empty(wm->cws)) { - widget = wm->cws->ordered->data;
+ widget = gnt_ws_get_top_widget(wm->cws); if (g_list_find(wm->tagged, widget)) {
@@ -1342,10 +1348,11 @@
GntWM *wm = GNT_WM(bindable);
+ if (gnt_ws_is_empty(wm->cws)) { - widget = wm->cws->ordered->data;
+ widget = gnt_ws_get_top_widget(wm->cws); return help_for_bindable(wm,GNT_BINDABLE(widget));
@@ -1356,10 +1363,11 @@
GntWM *wm = GNT_WM(bindable);
+ if (gnt_ws_is_empty(wm->cws)) { - widget = wm->cws->ordered->data;
+ widget = gnt_ws_get_top_widget(wm->cws); @@ -1611,8 +1619,8 @@
gnt_ws_draw_taskbar(wm->cws, TRUE);
- if (wm->cws->ordered) {
- gnt_wm_raise_window(wm, wm->cws->ordered->data);
+ if (!gnt_ws_is_empty(wm->cws)) { + gnt_wm_raise_window(wm, gnt_ws_get_top_widget(wm->cws)); if (act && g_list_find(act, wm->cws)) {
@@ -1701,10 +1709,11 @@
- if (wm->cws->ordered && wid == wm->cws->ordered->data)
+ if (gnt_ws_is_top_widget(wm->cws, wid)) { flag |= GNT_TEXT_FLAG_DIM;
- else if (gnt_widget_get_is_urgent(wid))
+ } else if (gnt_widget_get_is_urgent(wid)) { flag |= GNT_TEXT_FLAG_BOLD;
gnt_tree_set_row_flags(GNT_TREE(wm->windows->tree), wid, flag);
@@ -1794,12 +1803,11 @@
ws = new_widget_find_workspace(wm, widget);
- ws->list = g_list_append(ws->list, widget);
- ws->ordered = g_list_append(ws->ordered, widget);
+ gnt_ws_append_widget(ws, widget); if (wm->event_stack || node->me == wm->_list.window ||
- node->me == ws->ordered->data) {
+ gnt_ws_is_top_widget(ws, node->me)) { gnt_wm_raise_window(wm, node->me);
bottom_panel(node->panel); /* New windows should not grab focus */
@@ -1876,14 +1884,14 @@
pos = g_list_index(s->list, widget);
- s->list = g_list_remove(s->list, widget);
- s->ordered = g_list_remove(s->ordered, widget);
+ gnt_ws_remove_widget(s, widget); - if (s->ordered && wm->cws == s)
- gnt_wm_raise_window(wm, s->ordered->data);
+ if (!gnt_ws_is_empty(s) && wm->cws == s) { + gnt_wm_raise_window(wm, gnt_ws_get_top_widget(s)); - } else if (transient && wm->cws && wm->cws->ordered) {
- gnt_wm_update_window(wm, wm->cws->ordered->data);
+ } else if (transient && wm->cws && !gnt_ws_is_empty(wm->cws)) { + gnt_wm_update_window(wm, gnt_ws_get_top_widget(wm->cws)); gnt_ws_draw_taskbar(wm->cws, FALSE);
@@ -1908,7 +1916,10 @@
- return wm->cws->ordered ? gnt_widget_key_pressed(GNT_WIDGET(wm->cws->ordered->data), keys) : FALSE;
+ if (gnt_ws_is_empty(wm->cws)) { + return gnt_widget_key_pressed(gnt_ws_get_top_widget(wm->cws), keys); if (gnt_bindable_perform_action_key(GNT_BINDABLE(wm), keys)) {
@@ -1916,10 +1927,10 @@
/* Do some manual checking */
- if (wm->cws->ordered && wm->mode != GNT_KP_MODE_NORMAL) {
+ if (!gnt_ws_is_empty(wm->cws) && wm->mode != GNT_KP_MODE_NORMAL) { int xmin = 0, ymin = 0, xmax = getmaxx(stdscr), ymax = getmaxy(stdscr) - 1;
- GntWidget *widget = GNT_WIDGET(wm->cws->ordered->data);
+ GntWidget *widget = gnt_ws_get_top_widget(wm->cws); gnt_widget_get_position(widget, &x, &y);
@@ -1995,8 +2006,8 @@
ret = gnt_widget_key_pressed(GNT_WIDGET(wm->menu), keys);
else if (wm->_list.window)
ret = gnt_widget_key_pressed(wm->_list.window, keys);
- else if (wm->cws->ordered) {
- GntWidget *win = wm->cws->ordered->data;
+ else if (!gnt_ws_is_empty(wm->cws)) { + GntWidget *win = gnt_ws_get_top_widget(wm->cws); if (GNT_IS_WINDOW(win)) {
GntMenu *menu = gnt_window_get_menu(GNT_WINDOW(win));
@@ -2139,15 +2150,11 @@
- if (widget != wm->_list.window && !GNT_IS_MENU(widget) &&
- wm->cws->ordered->data != widget) {
- GntWidget *w = wm->cws->ordered->data;
- wm->cws->ordered = g_list_bring_to_front(wm->cws->ordered, widget);
- gnt_widget_set_focus(w, FALSE);
+ gnt_widget_set_is_urgent(widget, FALSE); + if (widget != wm->_list.window && !GNT_IS_MENU(widget)) { + gnt_ws_bring_to_front(wm->cws, widget); - gnt_widget_set_focus(widget, TRUE);
- gnt_widget_set_is_urgent(widget, FALSE);
@@ -2208,14 +2215,7 @@
g_return_if_fail(wm->cws != NULL);
- if (widget != wm->cws->ordered->data) {
- GntWidget *wid = wm->cws->ordered->data;
- wm->cws->ordered = g_list_bring_to_front(wm->cws->ordered, widget);
- gnt_widget_set_focus(wid, FALSE);
- gnt_widget_set_focus(widget, TRUE);
- gnt_widget_draw(widget);
+ gnt_ws_bring_to_front(wm->cws, widget); g_signal_emit(wm, signals[SIG_GIVE_FOCUS], 0, widget);