Fix build
soc.2013.gobjectification.plugins
2014-04-29, Ankit Vani
* GNT - The GLib Ncurses Toolkit * GNT is the legal property of its developers, whose names are too numerous * to list here. Please refer to the COPYRIGHT file distributed with this * This library is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA /* Python.h may define _GNU_SOURCE and _XOPEN_SOURCE_EXTENDED, so protect * these checks with #ifndef/!defined() */ #if !defined _XOPEN_SOURCE_EXTENDED && (defined(__APPLE__) || defined(__unix__)) && !defined(__FreeBSD__) #define _XOPEN_SOURCE_EXTENDED #define GNT_LOG_DOMAIN "WM" #define IDLE_CHECK_INTERVAL 5 /* 5 seconds */ static guint signals[SIGS] = { 0 }; static void gnt_wm_new_window_real(GntWM *wm, GntWidget *widget); static void gnt_wm_win_resized(GntWM *wm, GntNode *node); static void gnt_wm_win_moved(GntWM *wm, GntNode *node); static void gnt_wm_give_focus(GntWM *wm, GntWidget *widget); static void update_window_in_list(GntWM *wm, GntWidget *wid); static void shift_window(GntWM *wm, GntWidget *widget, int dir); static gboolean workspace_next(GntBindable *wm, GList *n); static gboolean workspace_prev(GntBindable *wm, GList *n); static int widestringwidth(wchar_t *wide); static void ensure_normal_mode(GntWM *wm); static gboolean write_already(gpointer data); static int write_timeout; static time_t last_active_time; static gboolean idle_update; static GList *act = NULL; /* list of WS with unseen activitiy */ static gboolean ignore_keys = FALSE; static gboolean started_python = FALSE; g_list_bring_to_front(GList *list, gpointer data) list = g_list_remove(list, data); list = g_list_prepend(list, data); gnt_wm_copy_win(GntWidget *widget, GntNode *node) copywin(src, dst, node->scroll, 0, 0, 0, getmaxy(dst) - 1, getmaxx(dst) - 1, 0); /* Update the hardware cursor */ if (GNT_IS_WINDOW(widget) || GNT_IS_BOX(widget)) { GntWidget *active = GNT_BOX(widget)->active; int curx = active->priv.x + getcurx(active->window); int cury = active->priv.y + getcury(active->window); if (wmove(node->window, cury - widget->priv.y, curx - widget->priv.x) != OK) wmove(node->window, 0, 0); * The following is a workaround for a bug in most versions of ncursesw. * Read about it in: http://article.gmane.org/gmane.comp.lib.ncurses.bugs/2751 * In short, if a panel hides one cell of a multi-cell character, then the rest * of the characters in that line get screwed. The workaround here is to erase * any such character preemptively. * Caveat: If a wide character is erased, and the panel above it is moved enough * to expose the entire character, it is not always redrawn. work_around_for_ncurses_bug(void) while ((panel = panel_below(panel)) != NULL) { int sx, ex, sy, ey, w, y; ex = panel->win->_maxx + sx; ey = panel->win->_maxy + sy; while ((below = panel_below(below)) != NULL) { if (sy > below->win->_begy + below->win->_maxy || if (sx > below->win->_begx + below->win->_maxx || for (y = MAX(sy, below->win->_begy); y <= MIN(ey, below->win->_begy + below->win->_maxy); y++) { if (mvwin_wch(below->win, y - below->win->_begy, sx - 1 - below->win->_begx, &ch) != OK) w = widestringwidth(ch.chars); if (w > 1 && (ch.attr & 1)) { mvwadd_wch(below->win, y - below->win->_begy, sx - 1 - below->win->_begx, &ch); touchline(below->win, y - below->win->_begy, 1); if (mvwin_wch(below->win, y - below->win->_begy, ex + 1 - below->win->_begx, &ch) != OK) w = widestringwidth(ch.chars); if (w > 1 && !(ch.attr & 1)) { mvwadd_wch(below->win, y - below->win->_begy, ex + 1 - below->win->_begx, &ch); touchline(below->win, y - below->win->_begy, 1); static GntWidget *message = NULL; GString *text = g_string_new("act: "); gnt_widget_destroy(message); for (iter = act; iter; iter = iter->next) { g_string_append_printf(text, "%s, ", gnt_ws_get_name(ws)); g_string_erase(text, text->len - 2, 2); message = gnt_vbox_new(FALSE); label = gnt_label_new_with_format(text->str, GNT_TEXT_FLAG_BOLD | GNT_TEXT_FLAG_HIGHLIGHT); GNT_WIDGET_UNSET_FLAGS(GNT_BOX(message), GNT_WIDGET_CAN_TAKE_FOCUS); GNT_WIDGET_SET_FLAGS(GNT_BOX(message), GNT_WIDGET_TRANSIENT); gnt_box_add_widget(GNT_BOX(message), label); gnt_widget_set_name(message, "wm-message"); gnt_widget_set_position(message, 0, 0); gnt_widget_draw(message); g_string_free(text, TRUE); if (wm->mode == GNT_KP_MODE_WAIT_ON_CHILD) GntNode *node = g_hash_table_lookup(wm->nodes, top); work_around_for_ncurses_bug(); sanitize_position(GntWidget *widget, int *x, int *y, gboolean m) int X_MAX = getmaxx(stdscr); int Y_MAX = getmaxy(stdscr) - 1; gboolean changed = FALSE; GntWindowFlags flags = GNT_IS_WINDOW(widget) ? gnt_window_get_maximize(GNT_WINDOW(widget)) : 0; gnt_widget_get_size(widget, &w, &h); if (m && (flags & GNT_WINDOW_MAXIMIZE_X) && *x != 0) { } else if (*x + w > X_MAX) { if (m && (flags & GNT_WINDOW_MAXIMIZE_Y) && *y != 0) { } else if (*y + h > Y_MAX) { refresh_node(GntWidget *widget, GntNode *node, gpointer m) int X_MAX = getmaxx(stdscr); int Y_MAX = getmaxy(stdscr) - 1; GntWindowFlags flags = 0; if (m && GNT_IS_WINDOW(widget)) { flags = gnt_window_get_maximize(GNT_WINDOW(widget)); gnt_widget_get_position(widget, &x, &y); gnt_widget_get_size(widget, &w, &h); if (sanitize_position(widget, &x, &y, !!m)) gnt_screen_move_widget(widget, x, y); if (flags & GNT_WINDOW_MAXIMIZE_X) if (flags & GNT_WINDOW_MAXIMIZE_Y) gnt_screen_resize_widget(widget, nw, nh); read_window_positions(GntWM *wm) GKeyFile *gfile = g_key_file_new(); char *filename = g_build_filename(gnt_get_config_dir(), ".gntpositions", NULL); if (!g_key_file_load_from_file(gfile, filename, G_KEY_FILE_NONE, &error)) { gnt_warning("%s", error->message); keys = g_key_file_get_keys(gfile, "positions", &nk, &error); gnt_warning("%s", error->message); char **coords = g_key_file_get_string_list(gfile, "positions", title, &l, NULL); GntPosition *p = g_new0(GntPosition, 1); g_hash_table_replace(wm->positions, g_strdup(title + 1), p); gnt_warning("Invalid number of arguments (%" G_GSIZE_FORMAT ") for positioning a window.", l); static gboolean check_idle(gpointer n) gnt_wm_init(GTypeInstance *instance, gpointer class) GntWM *wm = GNT_WM(instance); wm->name_places = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); wm->title_places = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); gnt_style_read_workspaces(wm); if (wm->workspaces == NULL) { wm->cws = gnt_ws_new("default"); gnt_wm_add_workspace(wm, wm->cws); wm->cws = wm->workspaces->data; wm->nodes = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, free_node); wm->positions = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); if (gnt_style_get_bool(GNT_STYLE_REMPOS, TRUE)) read_window_positions(wm); g_timeout_add_seconds(IDLE_CHECK_INTERVAL, check_idle, NULL); gnt_wm_switch_workspace(wm, 0); switch_window(GntWM *wm, int direction, gboolean urgent) GntWidget *w = NULL, *wid = NULL; if (wm->_list.window || wm->menu) if (!wm->cws->ordered || !wm->cws->ordered->next) if (wm->mode != GNT_KP_MODE_NORMAL) { w = wm->cws->ordered->data; orgpos = pos = g_list_index(wm->cws->list, w); g_return_if_fail(pos >= 0); wid = g_list_last(wm->cws->list)->data; pos = g_list_length(wm->cws->list) - 1; } else if ((guint)pos >= g_list_length(wm->cws->list)) { wid = wm->cws->list->data; wid = g_list_nth_data(wm->cws->list, pos); } while (urgent && !GNT_WIDGET_IS_FLAG_SET(wid, GNT_WIDGET_URGENT) && pos != orgpos); gnt_wm_raise_window(wm, wid); window_next(GntBindable *bindable, GList *null) GntWM *wm = GNT_WM(bindable); switch_window(wm, 1, FALSE); window_prev(GntBindable *bindable, GList *null) GntWM *wm = GNT_WM(bindable); switch_window(wm, -1, FALSE); switch_window_n(GntBindable *bind, GList *list) GntWM *wm = GNT_WM(bind); n = GPOINTER_TO_INT(list->data); if ((l = g_list_nth(wm->cws->list, n)) != NULL) gnt_wm_raise_window(wm, l->data); window_scroll_up(GntBindable *bindable, GList *null) GntWM *wm = GNT_WM(bindable); window = wm->cws->ordered->data; node = g_hash_table_lookup(wm->nodes, window); gnt_wm_copy_win(window, node); window_scroll_down(GntBindable *bindable, GList *null) GntWM *wm = GNT_WM(bindable); window = wm->cws->ordered->data; node = g_hash_table_lookup(wm->nodes, window); gnt_widget_get_size(window, &w, &h); if (h - node->scroll > getmaxy(node->window)) { gnt_wm_copy_win(window, node); window_close(GntBindable *bindable, GList *null) GntWM *wm = GNT_WM(bindable); gnt_widget_destroy(wm->cws->ordered->data); destroy__list(GntWidget *widget, GntWM *wm) win = wm->_list.window = gnt_box_new(FALSE, FALSE); gnt_box_set_toplevel(GNT_BOX(win), TRUE); gnt_box_set_pad(GNT_BOX(win), 0); GNT_WIDGET_SET_FLAGS(win, GNT_WIDGET_TRANSIENT); tree = wm->_list.tree = gnt_tree_new(); gnt_box_add_widget(GNT_BOX(win), tree); g_signal_connect(G_OBJECT(win), "destroy", G_CALLBACK(destroy__list), wm); window_list_activate(GntTree *tree, GntWM *wm) GntBindable *sel = gnt_tree_get_selection_data(GNT_TREE(tree)); gnt_widget_destroy(wm->_list.window); gnt_wm_switch_workspace(wm, g_list_index(wm->workspaces, sel)); gnt_wm_raise_window(wm, GNT_WIDGET(sel)); populate_window_list(GntWM *wm, gboolean workspace) GntTree *tree = GNT_TREE(wm->windows->tree); for (iter = wm->cws->list; iter; iter = iter->next) { GntBox *box = GNT_BOX(iter->data); gnt_tree_add_row_last(tree, box, gnt_tree_create_row(tree, box->title), NULL); update_window_in_list(wm, GNT_WIDGET(box)); GList *ws = wm->workspaces; for (; ws; ws = ws->next) { gnt_tree_add_row_last(tree, ws->data, gnt_tree_create_row(tree, gnt_ws_get_name(GNT_WS(ws->data))), NULL); for (iter = GNT_WS(ws->data)->list; iter; iter = iter->next) { GntBox *box = GNT_BOX(iter->data); gnt_tree_add_row_last(tree, box, gnt_tree_create_row(tree, box->title), ws->data); update_window_in_list(wm, GNT_WIDGET(box)); window_list_key_pressed(GntWidget *widget, const char *text, GntWM *wm) if (text[1] == 0 && wm->cws->ordered) { GntBindable *sel = gnt_tree_get_selection_data(GNT_TREE(widget)); /* reorder the workspace. */ shift_window(wm, GNT_WIDGET(sel), -1); /* reorder the workspace. */ shift_window(wm, GNT_WIDGET(sel), 1); gnt_tree_remove_all(GNT_TREE(widget)); populate_window_list(wm, GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), "workspace"))); gnt_tree_set_selected(GNT_TREE(widget), sel); list_of_windows(GntWM *wm, gboolean workspace) wm->windows = &wm->_list; win = wm->windows->window; tree = wm->windows->tree; gnt_box_set_title(GNT_BOX(win), workspace ? "Workspace List" : "Window List"); populate_window_list(wm, workspace); gnt_tree_set_selected(GNT_TREE(tree), wm->cws->ordered->data); 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); g_object_set_data(G_OBJECT(tree), "workspace", GINT_TO_POINTER(workspace)); gnt_tree_set_col_width(GNT_TREE(tree), 0, getmaxx(stdscr) / 3); gnt_widget_set_size(tree, 0, getmaxy(stdscr) / 2); gnt_widget_set_position(win, getmaxx(stdscr) / 3, getmaxy(stdscr) / 4); window_list(GntBindable *bindable, GList *null) GntWM *wm = GNT_WM(bindable); if (wm->_list.window || wm->menu) list_of_windows(wm, FALSE); dump_file_save(GntFileSel *fs, const char *path, const char *f, gpointer n) gnt_widget_destroy(GNT_WIDGET(fs)); if ((file = g_fopen(path, "w+")) == NULL) { fprintf(file, "<head>\n <meta http-equiv='Content-Type' content='text/html; charset=utf-8' />\n</head>\n<body>\n"); for (y = 0; y < getmaxy(stdscr); y++) { for (x = 0; x < getmaxx(stdscr); x++) { char ch[2] = {0, 0}, *print; now = mvwinch(curscr, y, x); ch[0] = now & A_CHARTEXT; mvwin_wch(curscr, y, x, &wch); ch[0] = (char)(wch.chars[0] & 0xff); #define CHECK(attr, start, end) \ fprintf(file, "%s", start); \ fprintf(file, "%s", end); \ CHECK(A_BOLD, "<b>", "</b>"); CHECK(A_UNDERLINE, "<u>", "</u>"); CHECK(A_BLINK, "<blink>", "</blink>"); if ((now & A_COLOR) != (old & A_COLOR) || (now & A_REVERSE) != (old & A_REVERSE)) if (pair_content(PAIR_NUMBER(now & A_COLOR), &fgp, &bgp) != OK) { if (color_content(fgp, &r, &g, &b) != OK) { fg.r = r; fg.b = b; fg.g = g; if (color_content(bgp, &r, &g, &b) != OK) { bg.r = r; bg.b = b; bg.g = g; #define ADJUST(x) (x = x * 255 / 1000) if (x) fprintf(file, "</span>"); fprintf(file, "<span style=\"background:#%02x%02x%02x;color:#%02x%02x%02x\">", bg.r, bg.g, bg.b, fg.r, fg.g, fg.b); if (wch.chars[0] > 255) { snprintf(unicode, sizeof(unicode), "&#x%x;", (unsigned int)wch.chars[0]); for (u = 0; unis[u].ascii; u++) { if (ch[0] == unis[u].ascii) { fprintf(file, "%s", print); fprintf(file, "</span>\n"); fprintf(file, "</pre>\n</body>"); dump_file_cancel(GntWidget *w, GntFileSel *fs) gnt_widget_destroy(GNT_WIDGET(fs)); dump_screen(GntBindable *b, GList *null) GntWidget *window = gnt_file_sel_new(); GntFileSel *sel = GNT_FILE_SEL(window); g_object_set(G_OBJECT(window), "vertical", TRUE, NULL); gnt_box_add_widget(GNT_BOX(window), gnt_label_new("Please enter the filename to save the screenshot.")); gnt_box_set_title(GNT_BOX(window), "Save Screenshot..."); gnt_file_sel_set_suggested_filename(sel, "dump.html"); g_signal_connect(G_OBJECT(sel), "file_selected", G_CALLBACK(dump_file_save), NULL); g_signal_connect(G_OBJECT(sel->cancel), "activate", G_CALLBACK(dump_file_cancel), sel); shift_window(GntWM *wm, GntWidget *widget, int dir) GList *all = wm->cws->list; GList *list = g_list_find(all, widget); length = g_list_length(all); pos = g_list_position(all, list); all = g_list_insert(all, widget, pos); all = g_list_delete_link(all, list); gnt_ws_draw_taskbar(wm->cws, FALSE); GntWidget *w = wm->cws->ordered->data; GntNode *node = g_hash_table_lookup(wm->nodes, w); shift_left(GntBindable *bindable, GList *null) GntWM *wm = GNT_WM(bindable); shift_window(wm, wm->cws->ordered->data, -1); shift_right(GntBindable *bindable, GList *null) GntWM *wm = GNT_WM(bindable); shift_window(wm, wm->cws->ordered->data, 1); action_list_activate(GntTree *tree, GntWM *wm) GntAction *action = gnt_tree_get_selection_data(tree); gnt_widget_destroy(wm->_list.window); compare_action(gconstpointer p1, gconstpointer p2) const GntAction *a1 = p1; const GntAction *a2 = p2; return g_utf8_collate(a1->label, a2->label); list_actions(GntBindable *bindable, GList *null) GntWM *wm = GNT_WM(bindable); if (wm->_list.window || wm->menu) wm->actions = &wm->_list; win = wm->actions->window; tree = wm->actions->tree; gnt_box_set_title(GNT_BOX(win), "Actions"); GNT_WIDGET_SET_FLAGS(tree, GNT_WIDGET_NO_BORDER); /* XXX: Do we really want this? */ gnt_tree_set_compare_func(GNT_TREE(tree), compare_action); for (iter = wm->acts; iter; iter = iter->next) { GntAction *action = iter->data; gnt_tree_add_row_last(GNT_TREE(tree), action, gnt_tree_create_row(GNT_TREE(tree), action->label), NULL); g_signal_connect(G_OBJECT(tree), "activate", G_CALLBACK(action_list_activate), wm); n = g_list_length(wm->acts); gnt_widget_set_size(tree, 0, n); gnt_widget_set_position(win, 0, getmaxy(stdscr) - 3 - n); widestringwidth(wchar_t *wide) len = wcstombs(NULL, wide, 0) + 1; string = g_new0(char, len); wcstombs(string, wide, len); ret = string ? gnt_util_onscreen_width(string, NULL) : 1; /* Returns the onscreen width of the character at the position */ reverse_char(WINDOW *d, int y, int x, gboolean set) #define DECIDE(ch) (set ? ((ch) | A_REVERSE) : ((ch) & ~A_REVERSE)) mvwaddch(d, y, x, DECIDE(ch)); if (mvwin_wch(d, y, x, &ch) == OK) { wc = widestringwidth(ch.chars); ch.attr = DECIDE(ch.attr); ch.attr &= WA_ATTRIBUTES; /* XXX: This is a workaround for a bug */ mvwadd_wch(d, y, x, &ch); window_reverse(GntWidget *win, gboolean set, GntWM *wm) if (GNT_WIDGET_IS_FLAG_SET(win, GNT_WIDGET_NO_BORDER)) gnt_widget_get_size(win, &w, &h); if (gnt_widget_has_shadow(win)) { for (i = 0; i < w; i += reverse_char(d, 0, i, set)); for (i = 0; i < w; i += reverse_char(d, h-1, i, set)); for (i = 0; i < h; i += reverse_char(d, i, 0, set)); for (i = 0; i < h; i += reverse_char(d, i, w-1, set)); gnt_wm_copy_win(win, g_hash_table_lookup(wm->nodes, win)); ensure_normal_mode(GntWM *wm) if (wm->mode != GNT_KP_MODE_NORMAL) { window_reverse(wm->cws->ordered->data, FALSE, wm); wm->mode = GNT_KP_MODE_NORMAL; start_move(GntBindable *bindable, GList *null) GntWM *wm = GNT_WM(bindable); if (wm->_list.window || wm->menu) wm->mode = GNT_KP_MODE_MOVE; window_reverse(GNT_WIDGET(wm->cws->ordered->data), TRUE, wm); start_resize(GntBindable *bindable, GList *null) GntWM *wm = GNT_WM(bindable); if (wm->_list.window || wm->menu) wm->mode = GNT_KP_MODE_RESIZE; window_reverse(GNT_WIDGET(wm->cws->ordered->data), TRUE, wm); wm_quit(GntBindable *bindable, GList *list) GntWM *wm = GNT_WM(bindable); g_main_loop_quit(wm->loop); return_true(GntWM *wm, GntWidget *w, int *a, int *b) refresh_screen(GntBindable *bindable, GList *null) GntWM *wm = GNT_WM(bindable); 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) { GntWidget *w = iter->data; GntNode *node = g_hash_table_lookup(wm->nodes, w); gnt_ws_draw_taskbar(wm->cws, TRUE); curs_set(0); /* endwin resets the cursor to normal */ toggle_clipboard(GntBindable *bindable, GList *n) gnt_widget_destroy(clip); text = gnt_get_clipboard_string(); clip = gnt_hwindow_new(FALSE); GNT_WIDGET_SET_FLAGS(clip, GNT_WIDGET_TRANSIENT); GNT_WIDGET_SET_FLAGS(clip, GNT_WIDGET_NO_BORDER); gnt_box_set_pad(GNT_BOX(clip), 0); gnt_box_add_widget(GNT_BOX(clip), gnt_label_new(" ")); gnt_box_add_widget(GNT_BOX(clip), gnt_label_new(text)); gnt_box_add_widget(GNT_BOX(clip), gnt_label_new(" ")); gnt_widget_set_position(clip, 0, 0); static void remove_tag(gpointer wid, gpointer wim) GntWidget *w = GNT_WIDGET(wid); wm->tagged = g_list_remove(wm->tagged, w); mvwhline(w->window, 0, 1, ACS_HLINE | gnt_color_pair(GNT_COLOR_NORMAL), 3); tag_widget(GntBindable *b, GList *params) widget = wm->cws->ordered->data; if (g_list_find(wm->tagged, widget)) { wm->tagged = g_list_prepend(wm->tagged, widget); wbkgdset(widget->window, ' ' | gnt_color_pair(GNT_COLOR_HIGHLIGHT)); mvwprintw(widget->window, 0, 1, "[T]"); widget_move_ws(gpointer wid, gpointer w) gnt_wm_widget_move_workspace(wm, wm->cws, GNT_WIDGET(wid)); place_tagged(GntBindable *b, GList *params) g_list_foreach(wm->tagged, widget_move_ws, wm); g_list_foreach(wm->tagged, remove_tag, wm); workspace_list(GntBindable *b, GList *params) if (wm->_list.window || wm->menu) list_of_windows(wm, TRUE); workspace_new(GntBindable *bindable, GList *null) GntWM *wm = GNT_WM(bindable); GntWS *ws = gnt_ws_new(NULL); gnt_wm_add_workspace(wm, ws); gnt_wm_switch_workspace(wm, g_list_index(wm->workspaces, ws)); ignore_keys_start(GntBindable *bindable, GList *n) GntWM *wm = GNT_WM(bindable); if(!wm->menu && !wm->_list.window && wm->mode == GNT_KP_MODE_NORMAL){ ignore_keys_end(GntBindable *bindable, GList *n) window_next_urgent(GntBindable *bindable, GList *n) GntWM *wm = GNT_WM(bindable); switch_window(wm, 1, TRUE); window_prev_urgent(GntBindable *bindable, GList *n) GntWM *wm = GNT_WM(bindable); switch_window(wm, -1, TRUE); python_script_selected(GntFileSel *fs, const char *path, const char *f, gpointer n) char *dir = g_path_get_dirname(path); FILE *file = fopen(path, "r"); PyObject *pp = PySys_GetObject("path"); #if PY_MAJOR_VERSION >= 3 PyObject *dirobj = PyUnicode_FromString(dir); PyObject *dirobj = PyString_FromString(dir); PyList_Insert(pp, 0, dirobj); PyRun_SimpleFile(file, path); gnt_widget_destroy(GNT_WIDGET(fs)); run_python(GntBindable *bindable, GList *n) GntWidget *window = gnt_file_sel_new(); GntFileSel *sel = GNT_FILE_SEL(window); g_object_set(G_OBJECT(window), "vertical", TRUE, NULL); gnt_box_add_widget(GNT_BOX(window), gnt_label_new("Please select the python script you want to run.")); gnt_box_set_title(GNT_BOX(window), "Select Python Script..."); g_signal_connect(G_OBJECT(sel), "file_selected", G_CALLBACK(python_script_selected), NULL); g_signal_connect_swapped(G_OBJECT(sel->cancel), "activate", G_CALLBACK(gnt_widget_destroy), sel); help_for_bindable(GntWM *wm, GntBindable *bindable) GntBindableClass *klass = GNT_BINDABLE_GET_CLASS(bindable); if (klass->help_window) { gnt_wm_raise_window(wm, GNT_WIDGET(klass->help_window)); ret = gnt_bindable_build_help_window(bindable); help_for_wm(GntBindable *bindable, GList *null) return help_for_bindable(GNT_WM(bindable),bindable); help_for_window(GntBindable *bindable, GList *null) GntWM *wm = GNT_WM(bindable); widget = wm->cws->ordered->data; return help_for_bindable(wm,GNT_BINDABLE(widget)); help_for_widget(GntBindable *bindable, GList *null) GntWM *wm = GNT_WM(bindable); widget = wm->cws->ordered->data; return help_for_bindable(wm, GNT_BINDABLE(GNT_BOX(widget)->active)); accumulate_windows(gpointer window, gpointer node, gpointer p) GList *list = *(GList**)p; list = g_list_prepend(list, window); gnt_wm_destroy(GObject *obj) g_hash_table_foreach(wm->nodes, accumulate_windows, &list); g_list_foreach(list, (GFunc)gnt_widget_destroy, NULL); g_hash_table_destroy(wm->nodes); g_object_unref(wm->workspaces->data); wm->workspaces = g_list_delete_link(wm->workspaces, wm->workspaces); gnt_wm_class_init(GntWMClass *klass) GObjectClass *gclass = G_OBJECT_CLASS(klass); gclass->dispose = gnt_wm_destroy; klass->new_window = gnt_wm_new_window_real; klass->decorate_window = NULL; klass->close_window = NULL; klass->window_resize_confirm = return_true; klass->window_resized = gnt_wm_win_resized; klass->window_move_confirm = return_true; klass->window_moved = gnt_wm_win_moved; klass->window_update = NULL; klass->key_pressed = NULL; klass->mouse_clicked = NULL; klass->give_focus = gnt_wm_give_focus; G_TYPE_FROM_CLASS(klass), G_STRUCT_OFFSET(GntWMClass, new_window), g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1, G_TYPE_POINTER); signals[SIG_DECORATE_WIN] = g_signal_new("decorate_win", G_TYPE_FROM_CLASS(klass), G_STRUCT_OFFSET(GntWMClass, decorate_window), g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1, G_TYPE_POINTER); g_signal_new("close_win", G_TYPE_FROM_CLASS(klass), G_STRUCT_OFFSET(GntWMClass, close_window), g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1, G_TYPE_POINTER); signals[SIG_CONFIRM_RESIZE] = g_signal_new("confirm_resize", G_TYPE_FROM_CLASS(klass), G_STRUCT_OFFSET(GntWMClass, window_resize_confirm), gnt_boolean_handled_accumulator, NULL, gnt_closure_marshal_BOOLEAN__POINTER_POINTER_POINTER, G_TYPE_BOOLEAN, 3, G_TYPE_POINTER, G_TYPE_POINTER, G_TYPE_POINTER); signals[SIG_CONFIRM_MOVE] = g_signal_new("confirm_move", G_TYPE_FROM_CLASS(klass), G_STRUCT_OFFSET(GntWMClass, window_move_confirm), gnt_boolean_handled_accumulator, NULL, gnt_closure_marshal_BOOLEAN__POINTER_POINTER_POINTER, G_TYPE_BOOLEAN, 3, G_TYPE_POINTER, G_TYPE_POINTER, G_TYPE_POINTER); g_signal_new("window_resized", G_TYPE_FROM_CLASS(klass), G_STRUCT_OFFSET(GntWMClass, window_resized), g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1, G_TYPE_POINTER); g_signal_new("window_moved", G_TYPE_FROM_CLASS(klass), G_STRUCT_OFFSET(GntWMClass, window_moved), g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1, G_TYPE_POINTER); signals[SIG_UPDATE_WIN] = g_signal_new("window_update", G_TYPE_FROM_CLASS(klass), G_STRUCT_OFFSET(GntWMClass, window_update), g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1, G_TYPE_POINTER); signals[SIG_GIVE_FOCUS] = g_signal_new("give_focus", G_TYPE_FROM_CLASS(klass), G_STRUCT_OFFSET(GntWMClass, give_focus), g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1, G_TYPE_POINTER); signals[SIG_MOUSE_CLICK] = g_signal_new("mouse_clicked", G_TYPE_FROM_CLASS(klass), G_STRUCT_OFFSET(GntWMClass, mouse_clicked), gnt_boolean_handled_accumulator, NULL, gnt_closure_marshal_BOOLEAN__INT_INT_INT_POINTER, G_TYPE_BOOLEAN, 4, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_POINTER); signals[SIG_TERMINAL_REFRESH] = g_signal_new("terminal-refresh", G_TYPE_FROM_CLASS(klass), G_STRUCT_OFFSET(GntWMClass, terminal_refresh), g_cclosure_marshal_VOID__VOID, gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "window-next", window_next, gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "window-prev", window_prev, gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "window-close", window_close, gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "window-list", window_list, gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "dump-screen", dump_screen, gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "shift-left", shift_left, gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "shift-right", shift_right, gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "action-list", list_actions, gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "start-move", start_move, gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "start-resize", start_resize, gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "wm-quit", wm_quit, gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "refresh-screen", refresh_screen, gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "switch-window-n", switch_window_n, gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "window-scroll-down", window_scroll_down, "\033" GNT_KEY_CTRL_J, NULL); gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "window-scroll-up", window_scroll_up, "\033" GNT_KEY_CTRL_K, NULL); gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "help-for-widget", help_for_widget, gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "workspace-new", workspace_new, gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "workspace-next", workspace_next, gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "workspace-prev", workspace_prev, gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "window-tag", tag_widget, gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "place-tagged", place_tagged, gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "workspace-list", workspace_list, gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "toggle-clipboard", toggle_clipboard, gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "help-for-wm", help_for_wm, gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "help-for-window", help_for_window, gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "ignore-keys-start", ignore_keys_start, gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "ignore-keys-end", ignore_keys_end, "\033" GNT_KEY_CTRL_G, NULL); gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "window-next-urgent", window_next_urgent, snprintf(key, sizeof(key), "\033%s", GNT_KEY_BACK_TAB); gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "window-prev-urgent", window_prev_urgent, key[1] ? key : NULL, NULL); gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "run-python", run_python, if (!Py_IsInitialized()) { #if PY_MAJOR_VERSION >= 3 len = mbstowcs(NULL, "gnt", 0); name = g_new(wchar_t, len + 1); mbstowcs(name, "gnt", len + 1); Py_SetProgramName("gnt"); gnt_style_read_actions(G_OBJECT_CLASS_TYPE(klass), GNT_BINDABLE_CLASS(klass)); /* Make sure Alt+x are detected properly. */ for (i = '0'; i <= '9'; i++) { gnt_keys_add_combination(str); /****************************************************************************** *****************************************************************************/ static const GTypeInfo info = { NULL, /* base_finalize */ (GClassInitFunc)gnt_wm_class_init, gnt_wm_init, /* instance_init */ type = g_type_register_static(GNT_TYPE_BINDABLE, gnt_wm_add_workspace(GntWM *wm, GntWS *ws) wm->workspaces = g_list_append(wm->workspaces, ws); gnt_wm_switch_workspace(GntWM *wm, gint n) GntWS *s = g_list_nth_data(wm->workspaces, n); gnt_widget_destroy(wm->_list.window); gnt_ws_hide(wm->cws, wm->nodes); gnt_ws_show(wm->cws, wm->nodes); gnt_ws_draw_taskbar(wm->cws, TRUE); gnt_wm_raise_window(wm, wm->cws->ordered->data); if (act && g_list_find(act, wm->cws)) { act = g_list_remove(act, wm->cws); gnt_wm_switch_workspace_prev(GntWM *wm) int n = g_list_index(wm->workspaces, wm->cws); return gnt_wm_switch_workspace(wm, --n); gnt_wm_switch_workspace_next(GntWM *wm) int n = g_list_index(wm->workspaces, wm->cws); return gnt_wm_switch_workspace(wm, ++n); workspace_next(GntBindable *wm, GList *n) return gnt_wm_switch_workspace_next(GNT_WM(wm)); workspace_prev(GntBindable *wm, GList *n) return gnt_wm_switch_workspace_prev(GNT_WM(wm)); gnt_wm_widget_move_workspace(GntWM *wm, GntWS *neww, GntWidget *widget) GntWS *oldw = gnt_wm_widget_find_workspace(wm, widget); if (!oldw || oldw == neww) node = g_hash_table_lookup(wm->nodes, widget); if (node && node->ws == neww) gnt_ws_remove_widget(oldw, widget); gnt_ws_add_widget(neww, widget); gnt_ws_widget_show(widget, wm->nodes); gnt_ws_widget_hide(widget, wm->nodes); static gint widget_in_workspace(gconstpointer workspace, gconstpointer wid) GntWS *s = (GntWS *)workspace; if (s->list && g_list_find(s->list, wid)) GntWS *gnt_wm_widget_find_workspace(GntWM *wm, GntWidget *widget) GList *l = g_list_find_custom(wm->workspaces, widget, widget_in_workspace); static void free_workspaces(gpointer data, gpointer n) void gnt_wm_set_workspaces(GntWM *wm, GList *workspaces) g_list_foreach(wm->workspaces, free_workspaces, NULL); wm->workspaces = workspaces; gnt_wm_switch_workspace(wm, 0); update_window_in_list(GntWM *wm, GntWidget *wid) GntTextFormatFlags flag = 0; if (wm->cws->ordered && wid == wm->cws->ordered->data) flag |= GNT_TEXT_FLAG_DIM; else if (GNT_WIDGET_IS_FLAG_SET(wid, GNT_WIDGET_URGENT)) flag |= GNT_TEXT_FLAG_BOLD; gnt_tree_set_row_flags(GNT_TREE(wm->windows->tree), wid, flag); match_title(gpointer title, gpointer n, gpointer wid_title) /* XXX: do any regex magic here. */ if (g_strrstr((gchar *)wid_title, (gchar *)title)) new_widget_find_workspace(GntWM *wm, GntWidget *widget) const gchar *name, *title; title = GNT_BOX(widget)->title; ret = g_hash_table_find(wm->title_places, match_title, (gpointer)title); name = gnt_widget_get_name(widget); ret = g_hash_table_find(wm->name_places, match_title, (gpointer)name); return ret ? ret : wm->cws; gnt_wm_new_window_real(GntWM *wm, GntWidget *widget) gboolean transient = FALSE; if (widget->window == NULL) node = g_new0(GntNode, 1); g_hash_table_replace(wm->nodes, widget, node); refresh_node(widget, node, GINT_TO_POINTER(TRUE)); transient = !!GNT_WIDGET_IS_FLAG_SET(node->me, GNT_WIDGET_TRANSIENT); int x, y, w, h, maxx, maxy; if (!gnt_widget_has_shadow(widget)) w = widget->priv.width + shadow; h = widget->priv.height + shadow; maxy = getmaxy(stdscr) - 1; /* room for the taskbar */ node->window = newwin(h, w, y, x); gnt_wm_copy_win(widget, node); node->panel = new_panel(node->window); set_panel_userptr(node->panel, node); if (node->me != wm->_list.window) { if (GNT_IS_BOX(widget)) { ws = new_widget_find_workspace(wm, widget); ws->list = g_list_append(ws->list, widget); ws->ordered = g_list_append(ws->ordered, widget); if (wm->event_stack || node->me == wm->_list.window || node->me == ws->ordered->data) { gnt_wm_raise_window(wm, node->me); 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); void gnt_wm_new_window(GntWM *wm, GntWidget *widget) if (GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_INVISIBLE) || g_hash_table_lookup(wm->nodes, widget)) { if (GNT_IS_BOX(widget)) { const char *title = GNT_BOX(widget)->title; if (title && (p = g_hash_table_lookup(wm->positions, title)) != NULL) { sanitize_position(widget, &p->x, &p->y, TRUE); gnt_widget_set_position(widget, p->x, p->y); mvwin(widget->window, p->y, p->x); g_signal_emit(wm, signals[SIG_NEW_WIN], 0, widget); g_signal_emit(wm, signals[SIG_DECORATE_WIN], 0, widget); if (wm->windows && !GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_TRANSIENT)) { if ((GNT_IS_BOX(widget) && GNT_BOX(widget)->title) && wm->_list.window != widget && GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_CAN_TAKE_FOCUS)) { gnt_tree_add_row_last(GNT_TREE(wm->windows->tree), widget, gnt_tree_create_row(GNT_TREE(wm->windows->tree), GNT_BOX(widget)->title), g_object_get_data(G_OBJECT(wm->windows->tree), "workspace") ? wm->cws : NULL); update_window_in_list(wm, widget); gnt_ws_draw_taskbar(wm->cws, FALSE); void gnt_wm_window_decorate(GntWM *wm, GntWidget *widget) g_signal_emit(wm, signals[SIG_DECORATE_WIN], 0, widget); void gnt_wm_window_close(GntWM *wm, GntWidget *widget) gboolean transient = !!GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_TRANSIENT); s = gnt_wm_widget_find_workspace(wm, widget); if (g_hash_table_lookup(wm->nodes, widget) == NULL) g_signal_emit(wm, signals[SIG_CLOSE_WIN], 0, widget); g_hash_table_remove(wm->nodes, widget); gnt_tree_remove(GNT_TREE(wm->windows->tree), widget); pos = g_list_index(s->list, widget); s->list = g_list_remove(s->list, widget); s->ordered = g_list_remove(s->ordered, widget); if (s->ordered && wm->cws == s) gnt_wm_raise_window(wm, s->ordered->data); } else if (transient && wm->cws && wm->cws->ordered) { gnt_wm_update_window(wm, wm->cws->ordered->data); gnt_ws_draw_taskbar(wm->cws, FALSE); time_t gnt_wm_get_idle_time() return time(NULL) - last_active_time; gboolean gnt_wm_process_input(GntWM *wm, const char *keys) keys = gnt_bindable_remap_keys(GNT_BINDABLE(wm), keys); if(keys && !strcmp(keys, "\033" GNT_KEY_CTRL_G)){ if(gnt_bindable_perform_action_key(GNT_BINDABLE(wm), keys)){ return wm->cws->ordered ? gnt_widget_key_pressed(GNT_WIDGET(wm->cws->ordered->data), keys) : FALSE; if (gnt_bindable_perform_action_key(GNT_BINDABLE(wm), keys)) { /* Do some manual checking */ if (wm->cws->ordered && 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); gnt_widget_get_position(widget, &x, &y); gnt_widget_get_size(widget, &w, &h); if (wm->mode == GNT_KP_MODE_MOVE) { if (strcmp(keys, GNT_KEY_LEFT) == 0) { } else if (strcmp(keys, GNT_KEY_RIGHT) == 0) { } else if (strcmp(keys, GNT_KEY_UP) == 0) { } else if (strcmp(keys, GNT_KEY_DOWN) == 0) { if (ox != x || oy != y) { gnt_screen_move_widget(widget, x, y); window_reverse(widget, TRUE, wm); } else if (wm->mode == GNT_KP_MODE_RESIZE) { if (strcmp(keys, GNT_KEY_LEFT) == 0) { } else if (strcmp(keys, GNT_KEY_RIGHT) == 0) { } else if (strcmp(keys, GNT_KEY_UP) == 0) { } else if (strcmp(keys, GNT_KEY_DOWN) == 0) { if (oh != h || ow != w) { gnt_screen_resize_widget(widget, w, h); window_reverse(widget, TRUE, wm); if (strcmp(keys, "\r") == 0 || strcmp(keys, "\033") == 0) { window_reverse(widget, FALSE, wm); wm->mode = GNT_KP_MODE_NORMAL; /* Escape to close the window-list or action-list window */ if (strcmp(keys, "\033") == 0) { gnt_widget_destroy(wm->_list.window); } else if (keys[0] == '\033' && isdigit(keys[1]) && keys[2] == '\0') { /* Alt+x for quick switch */ int n = *(keys + 1) - '0'; list = g_list_append(list, GINT_TO_POINTER(n - 1)); switch_window_n(GNT_BINDABLE(wm), list); 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; if (GNT_IS_WINDOW(win)) { GntMenu *menu = GNT_WINDOW(win)->menu; const char *id = gnt_window_get_accel_item(GNT_WINDOW(win), keys); GntMenuItem *item = gnt_menu_get_item(menu, id); ret = gnt_menuitem_activate(item); ret = gnt_widget_key_pressed(win, keys); gnt_wm_win_resized(GntWM *wm, GntNode *node) /*refresh_node(node->me, node, NULL);*/ gnt_wm_win_moved(GntWM *wm, GntNode *node) refresh_node(node->me, node, NULL); void gnt_wm_resize_window(GntWM *wm, GntWidget *widget, int width, int height) node = g_hash_table_lookup(wm->nodes, widget); g_signal_emit(wm, signals[SIG_CONFIRM_RESIZE], 0, widget, &width, &height, &ret); return; /* resize is not permitted */ gnt_widget_set_size(widget, width, height); maxy = getmaxy(stdscr) - 1; height = MIN(height, maxy); width = MIN(width, maxx); wresize(node->window, height, width); replace_panel(node->panel, node->window); g_signal_emit(wm, signals[SIG_RESIZED], 0, node); write_gdi(gpointer key, gpointer value, gpointer data) fprintf(data, ".%s = %d;%d\n", (char *)key, p->x, p->y); write_already(gpointer data) filename = g_build_filename(gnt_get_config_dir(), ".gntpositions", NULL); file = fopen(filename, "wb"); gnt_warning("error opening file (%s) to save positions", filename); fprintf(file, "[positions]\n"); g_hash_table_foreach(wm->positions, write_gdi, file); g_source_remove(write_timeout); write_positions_to_file(GntWM *wm) g_source_remove(write_timeout); write_timeout = g_timeout_add_seconds(10, write_already, wm); void gnt_wm_move_window(GntWM *wm, GntWidget *widget, int x, int y) node = g_hash_table_lookup(wm->nodes, widget); g_signal_emit(wm, signals[SIG_CONFIRM_MOVE], 0, widget, &x, &y, &ret); return; /* resize is not permitted */ gnt_widget_set_position(widget, x, y); move_panel(node->panel, y, x); g_signal_emit(wm, signals[SIG_MOVED], 0, node); if (gnt_style_get_bool(GNT_STYLE_REMPOS, TRUE) && GNT_IS_BOX(widget) && !GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_TRANSIENT)) { const char *title = GNT_BOX(widget)->title; GntPosition *p = g_new0(GntPosition, 1); GntWidget *wid = node->me; g_hash_table_replace(wm->positions, g_strdup(title), p); write_positions_to_file(wm); gnt_wm_give_focus(GntWM *wm, GntWidget *widget) GntNode *node = g_hash_table_lookup(wm->nodes, widget); 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_focus(widget, TRUE); GNT_WIDGET_UNSET_FLAGS(widget, GNT_WIDGET_URGENT); GntNode *nd = g_hash_table_lookup(wm->nodes, wm->_list.window); gnt_ws_draw_taskbar(wm->cws, FALSE); void gnt_wm_update_window(GntWM *wm, GntWidget *widget) if (!GNT_IS_MENU(widget)) { gnt_box_sync_children(GNT_BOX(widget)); ws = gnt_wm_widget_find_workspace(wm, widget); node = g_hash_table_lookup(wm->nodes, widget); gnt_wm_new_window(wm, widget); g_signal_emit(wm, signals[SIG_UPDATE_WIN], 0, node); if (ws == wm->cws || GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_TRANSIENT)) { gnt_wm_copy_win(widget, node); gnt_ws_draw_taskbar(wm->cws, FALSE); } else if (ws && ws != wm->cws && GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_URGENT)) { if (!act || (act && !g_list_find(act, ws))) act = g_list_prepend(act, ws); gboolean gnt_wm_process_click(GntWM *wm, GntMouseEvent event, int x, int y, GntWidget *widget) g_signal_emit(wm, signals[SIG_MOUSE_CLICK], 0, event, x, y, widget, &ret); void gnt_wm_raise_window(GntWM *wm, GntWidget *widget) GntWS *ws = gnt_wm_widget_find_workspace(wm, widget); g_return_if_fail(wm != NULL); gnt_wm_switch_workspace(wm, g_list_index(wm->workspaces, ws)); 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); g_signal_emit(wm, signals[SIG_GIVE_FOCUS], 0, widget); void gnt_wm_set_event_stack(GntWM *wm, gboolean set)