--- a/gntwm.c Fri May 10 01:00:51 2019 -0400
+++ b/gntwm.c Fri May 10 01:29:37 2019 -0400
@@ -78,6 +78,7 @@
GList *tagged; /* tagged windows */
GntListWindow *windows; /* Window-list window */
@@ -412,10 +413,10 @@
wm->title_places = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
gnt_style_read_workspaces(wm);
if (priv->workspaces == NULL) {
- wm->cws = gnt_ws_new("default");
- gnt_wm_add_workspace(wm, wm->cws);
+ priv->cws = gnt_ws_new("default"); + gnt_wm_add_workspace(wm, priv->cws); - wm->cws = priv->workspaces->data;
+ priv->cws = priv->workspaces->data; wm->nodes = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, free_node);
@@ -439,7 +440,7 @@
- if (gnt_ws_is_empty(wm->cws) || gnt_ws_is_single(wm->cws)) {
+ if (gnt_ws_is_empty(priv->cws) || gnt_ws_is_single(priv->cws)) { @@ -447,8 +448,8 @@
- w = gnt_ws_get_top_widget(wm->cws);
- list = gnt_ws_get_list(wm->cws);
+ w = gnt_ws_get_top_widget(priv->cws); + list = gnt_ws_get_list(priv->cws); orgpos = pos = g_list_index(list, w);
g_return_if_fail(pos >= 0);
@@ -489,10 +490,11 @@
switch_window_n(GntBindable *bind, GList *list)
GntWM *wm = GNT_WM(bind);
+ GntWMPrivate *priv = gnt_wm_get_instance_private(wm); - if (gnt_ws_is_empty(wm->cws)) {
+ if (gnt_ws_is_empty(priv->cws)) { @@ -501,7 +503,7 @@
- if ((l = g_list_nth(gnt_ws_get_list(wm->cws), n)) != NULL) {
+ if ((l = g_list_nth(gnt_ws_get_list(priv->cws), n)) != NULL) { gnt_wm_raise_window(wm, l->data);
@@ -512,14 +514,15 @@
window_scroll_up(GntBindable *bindable, G_GNUC_UNUSED GList *params)
GntWM *wm = GNT_WM(bindable);
+ GntWMPrivate *priv = gnt_wm_get_instance_private(wm); - if (gnt_ws_is_empty(wm->cws)) {
+ if (gnt_ws_is_empty(priv->cws)) { - window = gnt_ws_get_top_widget(wm->cws);
+ window = gnt_ws_get_top_widget(priv->cws); node = g_hash_table_lookup(wm->nodes, window);
@@ -536,15 +539,16 @@
window_scroll_down(GntBindable *bindable, G_GNUC_UNUSED GList *params)
GntWM *wm = GNT_WM(bindable);
+ GntWMPrivate *priv = gnt_wm_get_instance_private(wm); - if (gnt_ws_is_empty(wm->cws)) {
+ if (gnt_ws_is_empty(priv->cws)) { - window = gnt_ws_get_top_widget(wm->cws);
+ window = gnt_ws_get_top_widget(priv->cws); node = g_hash_table_lookup(wm->nodes, window);
@@ -568,8 +572,8 @@
- if (!gnt_ws_is_empty(wm->cws)) {
- gnt_widget_destroy(gnt_ws_get_top_widget(wm->cws));
+ if (!gnt_ws_is_empty(priv->cws)) { + gnt_widget_destroy(gnt_ws_get_top_widget(priv->cws)); @@ -631,7 +635,7 @@
GntTree *tree = GNT_TREE(priv->windows->tree);
- for (iter = gnt_ws_get_list(wm->cws); iter; iter = iter->next) {
+ for (iter = gnt_ws_get_list(priv->cws); iter; iter = iter->next) { GntBox *box = GNT_BOX(iter->data);
@@ -664,7 +668,9 @@
window_list_key_pressed(GntWidget *widget, const char *text, GntWM *wm)
- if (text[1] == 0 && !gnt_ws_is_empty(wm->cws)) {
+ GntWMPrivate *priv = gnt_wm_get_instance_private(wm); + if (text[1] == 0 && !gnt_ws_is_empty(priv->cws)) { GntBindable *sel = gnt_tree_get_selection_data(GNT_TREE(widget));
@@ -707,10 +713,10 @@
populate_window_list(wm, workspace);
- if (!gnt_ws_is_empty(wm->cws)) {
- gnt_tree_set_selected(GNT_TREE(tree), gnt_ws_get_top_widget(wm->cws));
+ if (!gnt_ws_is_empty(priv->cws)) { + gnt_tree_set_selected(GNT_TREE(tree), gnt_ws_get_top_widget(priv->cws)); - gnt_tree_set_selected(GNT_TREE(tree), wm->cws);
+ gnt_tree_set_selected(GNT_TREE(tree), priv->cws); g_signal_connect(G_OBJECT(tree), "activate", G_CALLBACK(window_list_activate), wm);
@@ -734,7 +740,7 @@
- if (gnt_ws_is_empty(wm->cws)) {
+ if (gnt_ws_is_empty(priv->cws)) { @@ -912,7 +918,8 @@
shift_window(GntWM *wm, GntWidget *widget, int dir)
- GList *all = gnt_ws_get_list(wm->cws);
+ GntWMPrivate *priv = gnt_wm_get_instance_private(wm); + GList *all = gnt_ws_get_list(priv->cws); GList *list = g_list_find(all, widget);
@@ -932,10 +939,10 @@
all = g_list_insert(all, widget, pos);
all = g_list_delete_link(all, list);
- gnt_ws_set_list(wm->cws, all);
- gnt_ws_draw_taskbar(wm->cws, FALSE);
- if (!gnt_ws_is_empty(wm->cws)) {
- GntWidget *w = gnt_ws_get_top_widget(wm->cws);
+ gnt_ws_set_list(priv->cws, all); + gnt_ws_draw_taskbar(priv->cws, FALSE); + if (!gnt_ws_is_empty(priv->cws)) { + GntWidget *w = gnt_ws_get_top_widget(priv->cws); GntNode *node = g_hash_table_lookup(wm->nodes, w);
@@ -953,11 +960,11 @@
- if (gnt_ws_is_empty(wm->cws)) {
+ if (gnt_ws_is_empty(priv->cws)) { - shift_window(wm, gnt_ws_get_top_widget(wm->cws), -1);
+ shift_window(wm, gnt_ws_get_top_widget(priv->cws), -1); @@ -971,11 +978,11 @@
- if (gnt_ws_is_empty(wm->cws)) {
+ if (gnt_ws_is_empty(priv->cws)) { - shift_window(wm, gnt_ws_get_top_widget(wm->cws), 1);
+ shift_window(wm, gnt_ws_get_top_widget(priv->cws), 1); @@ -1113,9 +1120,10 @@
ensure_normal_mode(GntWM *wm)
+ GntWMPrivate *priv = gnt_wm_get_instance_private(wm); if (wm->mode != GNT_KP_MODE_NORMAL) {
- if (!gnt_ws_is_empty(wm->cws)) {
- window_reverse(gnt_ws_get_top_widget(wm->cws), FALSE, wm);
+ if (!gnt_ws_is_empty(priv->cws)) { + window_reverse(gnt_ws_get_top_widget(priv->cws), FALSE, wm); wm->mode = GNT_KP_MODE_NORMAL;
@@ -1130,12 +1138,12 @@
if (priv->list.window || wm->menu) {
- if (gnt_ws_is_empty(wm->cws)) {
+ if (gnt_ws_is_empty(priv->cws)) { wm->mode = GNT_KP_MODE_MOVE;
- window_reverse(gnt_ws_get_top_widget(wm->cws), TRUE, wm);
+ window_reverse(gnt_ws_get_top_widget(priv->cws), TRUE, wm); @@ -1149,12 +1157,12 @@
if (priv->list.window || wm->menu) {
- if (gnt_ws_is_empty(wm->cws)) {
+ if (gnt_ws_is_empty(priv->cws)) { wm->mode = GNT_KP_MODE_RESIZE;
- window_reverse(gnt_ws_get_top_widget(wm->cws), TRUE, wm);
+ window_reverse(gnt_ws_get_top_widget(priv->cws), TRUE, wm); @@ -1180,6 +1188,7 @@
refresh_screen(GntBindable *bindable, G_GNUC_UNUSED GList *params)
GntWM *wm = GNT_WM(bindable);
+ GntWMPrivate *priv = gnt_wm_get_instance_private(wm); @@ -1188,13 +1197,13 @@
g_hash_table_foreach(wm->nodes, (GHFunc)refresh_node, GINT_TO_POINTER(TRUE));
g_signal_emit(wm, signals[SIG_TERMINAL_REFRESH], 0);
- for (iter = gnt_ws_get_last(wm->cws); iter; iter = iter->prev) {
+ for (iter = gnt_ws_get_last(priv->cws); iter; iter = iter->prev) { GntWidget *w = iter->data;
GntNode *node = g_hash_table_lookup(wm->nodes, w);
- gnt_ws_draw_taskbar(wm->cws, TRUE);
+ gnt_ws_draw_taskbar(priv->cws, TRUE); curs_set(0); /* endwin resets the cursor to normal */
@@ -1244,10 +1253,10 @@
- if (gnt_ws_is_empty(wm->cws)) {
+ if (gnt_ws_is_empty(priv->cws)) { - widget = gnt_ws_get_top_widget(wm->cws);
+ widget = gnt_ws_get_top_widget(priv->cws); link = g_list_find(priv->tagged, widget);
@@ -1273,7 +1282,7 @@
for (iter = priv->tagged; iter; iter = g_list_delete_link(iter, iter)) {
GntWidget *widget = GNT_WIDGET(iter->data);
- gnt_wm_widget_move_workspace(wm, wm->cws, widget);
+ gnt_wm_widget_move_workspace(wm, priv->cws, widget); @@ -1416,13 +1425,14 @@
help_for_window(GntBindable *bindable, G_GNUC_UNUSED GList *params)
GntWM *wm = GNT_WM(bindable);
+ GntWMPrivate *priv = gnt_wm_get_instance_private(wm); - if (gnt_ws_is_empty(wm->cws)) {
+ if (gnt_ws_is_empty(priv->cws)) { - widget = gnt_ws_get_top_widget(wm->cws);
+ widget = gnt_ws_get_top_widget(priv->cws); return help_for_bindable(wm,GNT_BINDABLE(widget));
@@ -1431,13 +1441,14 @@
help_for_widget(GntBindable *bindable, G_GNUC_UNUSED GList *params)
GntWM *wm = GNT_WM(bindable);
+ GntWMPrivate *priv = gnt_wm_get_instance_private(wm); - if (gnt_ws_is_empty(wm->cws)) {
+ if (gnt_ws_is_empty(priv->cws)) { - widget = gnt_ws_get_top_widget(wm->cws);
+ widget = gnt_ws_get_top_widget(priv->cws); @@ -1667,6 +1678,17 @@
/******************************************************************************
*****************************************************************************/
+gnt_wm_get_current_workspace(GntWM *wm) + GntWMPrivate *priv = NULL; + g_return_val_if_fail(GNT_IS_WM(wm), NULL); + priv = gnt_wm_get_instance_private(wm); gnt_wm_add_workspace(GntWM *wm, GntWS *ws)
@@ -1696,18 +1718,18 @@
gnt_widget_destroy(priv->list.window);
- gnt_ws_hide(wm->cws, wm->nodes);
- gnt_ws_show(wm->cws, wm->nodes);
+ gnt_ws_hide(priv->cws, wm->nodes); + gnt_ws_show(priv->cws, wm->nodes); - gnt_ws_draw_taskbar(wm->cws, TRUE);
+ gnt_ws_draw_taskbar(priv->cws, TRUE); - if (!gnt_ws_is_empty(wm->cws)) {
- gnt_wm_raise_window(wm, gnt_ws_get_top_widget(wm->cws));
+ if (!gnt_ws_is_empty(priv->cws)) { + gnt_wm_raise_window(wm, gnt_ws_get_top_widget(priv->cws)); - if (act && g_list_find(act, wm->cws)) {
- act = g_list_remove(act, wm->cws);
+ if (act && g_list_find(act, priv->cws)) { + act = g_list_remove(act, priv->cws); @@ -1722,7 +1744,7 @@
g_return_val_if_fail(GNT_IS_WM(wm), FALSE);
priv = gnt_wm_get_instance_private(wm);
- n = g_list_index(priv->workspaces, wm->cws);
+ n = g_list_index(priv->workspaces, priv->cws); return gnt_wm_switch_workspace(wm, --n);
@@ -1735,7 +1757,7 @@
g_return_val_if_fail(GNT_IS_WM(wm), FALSE);
priv = gnt_wm_get_instance_private(wm);
- n = g_list_index(priv->workspaces, wm->cws);
+ n = g_list_index(priv->workspaces, priv->cws); return gnt_wm_switch_workspace(wm, ++n);
@@ -1754,8 +1776,14 @@
gnt_wm_widget_move_workspace(GntWM *wm, GntWS *neww, GntWidget *widget)
- GntWS *oldw = gnt_wm_widget_find_workspace(wm, widget);
+ GntWMPrivate *priv = NULL; + g_return_if_fail(GNT_IS_WM(wm)); + priv = gnt_wm_get_instance_private(wm); + oldw = gnt_wm_widget_find_workspace(wm, widget); if (!oldw || oldw == neww)
node = g_hash_table_lookup(wm->nodes, widget);
@@ -1767,7 +1795,7 @@
gnt_ws_remove_widget(oldw, widget);
gnt_ws_add_widget(neww, widget);
+ if (neww == priv->cws) { gnt_ws_widget_show(widget, wm->nodes);
gnt_ws_widget_hide(widget, wm->nodes);
@@ -1819,7 +1847,7 @@
- if (gnt_ws_is_top_widget(wm->cws, wid)) {
+ if (gnt_ws_is_top_widget(priv->cws, wid)) { flag |= GNT_TEXT_FLAG_DIM;
} else if (gnt_widget_get_is_urgent(wid)) {
flag |= GNT_TEXT_FLAG_BOLD;
@@ -1839,6 +1867,7 @@
new_widget_find_workspace(GntWM *wm, GntWidget *widget)
+ GntWMPrivate *priv = gnt_wm_get_instance_private(wm); const gchar *name, *title;
title = gnt_box_get_title(GNT_BOX(widget));
@@ -1853,12 +1882,13 @@
ret = g_hash_table_find(wm->name_places, (GHRFunc)match_title,
- return ret ? ret : wm->cws;
+ return ret ? ret : priv->cws; gnt_wm_new_window_real(GntWM *wm, GntWidget *widget)
+ GntWMPrivate *priv = gnt_wm_get_instance_private(wm); gboolean transient = FALSE;
@@ -1906,7 +1936,7 @@
set_panel_userptr(node->panel, node);
if (!gnt_wm_is_list_window(wm, node->me)) {
if (GNT_IS_BOX(widget)) {
ws = new_widget_find_workspace(wm, widget);
@@ -1922,8 +1952,9 @@
bottom_panel(node->panel); /* New windows should not grab focus */
gnt_widget_set_focus(node->me, FALSE);
gnt_widget_set_urgent(node->me);
gnt_ws_widget_hide(widget, wm->nodes);
@@ -1968,13 +1999,13 @@
gnt_box_get_title(GNT_BOX(widget))),
g_object_get_data(G_OBJECT(priv->windows->tree),
update_window_in_list(wm, widget);
- gnt_ws_draw_taskbar(wm->cws, FALSE);
+ gnt_ws_draw_taskbar(priv->cws, FALSE); @@ -2013,15 +2044,15 @@
gnt_ws_remove_widget(s, widget);
- if (!gnt_ws_is_empty(s) && wm->cws == s) {
+ if (!gnt_ws_is_empty(s) && priv->cws == s) { gnt_wm_raise_window(wm, gnt_ws_get_top_widget(s));
- } else if (transient && wm->cws && !gnt_ws_is_empty(wm->cws)) {
- gnt_wm_update_window(wm, gnt_ws_get_top_widget(wm->cws));
+ } else if (transient && priv->cws && !gnt_ws_is_empty(priv->cws)) { + gnt_wm_update_window(wm, gnt_ws_get_top_widget(priv->cws)); - gnt_ws_draw_taskbar(wm->cws, FALSE);
+ gnt_ws_draw_taskbar(priv->cws, FALSE); @@ -2044,10 +2075,10 @@
- if (gnt_ws_is_empty(wm->cws)) {
+ if (gnt_ws_is_empty(priv->cws)) { - return gnt_widget_key_pressed(gnt_ws_get_top_widget(wm->cws), keys);
+ return gnt_widget_key_pressed(gnt_ws_get_top_widget(priv->cws), keys); if (gnt_bindable_perform_action_key(GNT_BINDABLE(wm), keys)) {
@@ -2055,10 +2086,10 @@
/* Do some manual checking */
- if (!gnt_ws_is_empty(wm->cws) && wm->mode != GNT_KP_MODE_NORMAL) {
+ if (!gnt_ws_is_empty(priv->cws) && wm->mode != GNT_KP_MODE_NORMAL) { int xmin = 0, ymin = 0, xmax = getmaxx(stdscr), ymax = getmaxy(stdscr) - 1;
- GntWidget *widget = gnt_ws_get_top_widget(wm->cws);
+ GntWidget *widget = gnt_ws_get_top_widget(priv->cws); gnt_widget_get_position(widget, &x, &y);
@@ -2134,8 +2165,8 @@
ret = gnt_widget_key_pressed(GNT_WIDGET(wm->menu), keys);
} else if (priv->list.window) {
ret = gnt_widget_key_pressed(priv->list.window, keys);
- } else if (!gnt_ws_is_empty(wm->cws)) {
- GntWidget *win = gnt_ws_get_top_widget(wm->cws);
+ } else if (!gnt_ws_is_empty(priv->cws)) { + GntWidget *win = gnt_ws_get_top_widget(priv->cws); if (GNT_IS_WINDOW(win)) {
GntMenu *menu = gnt_window_get_menu(GNT_WINDOW(win));
@@ -2279,7 +2310,7 @@
gnt_widget_set_is_urgent(widget, FALSE);
if (!gnt_wm_is_list_window(wm, widget) && !GNT_IS_MENU(widget)) {
- gnt_ws_bring_to_front(wm->cws, widget);
+ gnt_ws_bring_to_front(priv->cws, widget); @@ -2289,15 +2320,19 @@
GntNode *nd = g_hash_table_lookup(wm->nodes, priv->list.window);
- gnt_ws_draw_taskbar(wm->cws, FALSE);
+ gnt_ws_draw_taskbar(priv->cws, FALSE); void gnt_wm_update_window(GntWM *wm, GntWidget *widget)
+ GntWMPrivate *priv = NULL; + g_return_if_fail(GNT_IS_WM(wm)); + priv = gnt_wm_get_instance_private(wm); widget = gnt_widget_get_toplevel(widget);
if (!GNT_IS_MENU(widget)) {
@@ -2312,11 +2347,11 @@
g_signal_emit(wm, signals[SIG_UPDATE_WIN], 0, node);
- if (ws == wm->cws || gnt_widget_get_transient(widget)) {
+ if (ws == priv->cws || gnt_widget_get_transient(widget)) { gnt_wm_copy_win(widget, node);
- gnt_ws_draw_taskbar(wm->cws, FALSE);
+ gnt_ws_draw_taskbar(priv->cws, FALSE); - } else if (ws && ws != wm->cws && gnt_widget_get_is_urgent(widget)) {
+ } else if (ws && ws != priv->cws && gnt_widget_get_is_urgent(widget)) { if (!act || (act && !g_list_find(act, ws)))
act = g_list_prepend(act, ws);
@@ -2341,12 +2376,13 @@
ws = gnt_wm_widget_find_workspace(wm, widget);
gnt_wm_switch_workspace(wm, g_list_index(priv->workspaces, ws));
- g_return_if_fail(wm->cws != NULL);
+ g_return_if_fail(priv->cws != NULL); - gnt_ws_bring_to_front(wm->cws, widget);
+ gnt_ws_bring_to_front(priv->cws, widget); g_signal_emit(wm, signals[SIG_GIVE_FOCUS], 0, widget);