/* track the new controled window according to preferences */ static void track_controled_window (WckUtils *win) { WnckWindow *previous_umax = NULL; WnckWindow *previous_control = NULL; previous_control = win->controlwindow; if (win->only_maximized) { previous_umax = win->umaxwindow; win->umaxwindow = get_upper_maximized(win); win->controlwindow = win->umaxwindow; } else if (win->activewindow && (!win->activeworkspace || wnck_window_is_in_viewport(win->activewindow, win->activeworkspace)) && !wnck_window_is_minimized(win->activewindow) && !wnck_window_is_sticky(win->activewindow)) { win->controlwindow = win->activewindow; } if (!win->umaxwindow || (win->umaxwindow != previous_umax)) { wck_signal_handler_disconnect (G_OBJECT(previous_umax), win->msh); wck_signal_handler_disconnect (G_OBJECT(previous_umax), win->mwh); } if (win->only_maximized) { if (win->umaxwindow && (win->umaxwindow != previous_umax)) { /* track the new upper maximized window state */ win->msh = g_signal_connect(G_OBJECT(win->umaxwindow), "state-changed", G_CALLBACK (on_umaxed_window_state_changed), win); win->mwh = g_signal_connect(G_OBJECT (win->umaxwindow), "workspace-changed", G_CALLBACK (umax_window_workspace_changed), win); } else if (win->controlwindow == previous_control) { /* track previous upper maximized window state on desktop */ win->umaxwindow = previous_umax; if (win->umaxwindow) { win->msh = g_signal_connect(G_OBJECT(win->umaxwindow), "state-changed", G_CALLBACK (track_changed_max_state), win); } } } if (!win->controlwindow) win->controlwindow = get_root_window(win->activescreen); if (win->controlwindow != previous_control) on_control_window_changed(win->controlwindow, previous_control, win->data); else on_wck_state_changed(win->controlwindow, win->data); }
static gboolean update_menu_state (WnckActionMenu *menu) { WnckActionMenuPrivate *priv; WnckWindowActions actions; WnckScreen *screen; WnckWorkspace *workspace; gboolean viewport_mode; gboolean move_workspace_sensitive; priv = menu->priv; priv->idle_handler = 0; actions = wnck_window_get_actions (priv->window); screen = wnck_window_get_screen (priv->window); viewport_mode = wnck_screen_get_workspace_count (screen) == 1 && wnck_workspace_is_virtual (wnck_screen_get_workspace (screen, 0)); move_workspace_sensitive = viewport_mode || (actions & WNCK_WINDOW_ACTION_CHANGE_WORKSPACE) != 0; if (wnck_window_is_minimized (priv->window)) { set_item_text (priv->minimize_item, _("Unmi_nimize")); set_item_stock (priv->minimize_item, NULL); gtk_widget_set_sensitive (priv->minimize_item, (actions & WNCK_WINDOW_ACTION_UNMINIMIZE) != 0); } else { set_item_text (priv->minimize_item, _("Mi_nimize")); set_item_stock (priv->minimize_item, WNCK_STOCK_MINIMIZE); gtk_widget_set_sensitive (priv->minimize_item, (actions & WNCK_WINDOW_ACTION_MINIMIZE) != 0); } if (wnck_window_is_maximized (priv->window)) { set_item_text (priv->maximize_item, _("Unma_ximize")); set_item_stock (priv->maximize_item, NULL); gtk_widget_set_sensitive (priv->maximize_item, (actions & WNCK_WINDOW_ACTION_UNMAXIMIZE) != 0); } else { set_item_text (priv->maximize_item, _("Ma_ximize")); set_item_stock (priv->maximize_item, WNCK_STOCK_MAXIMIZE); gtk_widget_set_sensitive (priv->maximize_item, (actions & WNCK_WINDOW_ACTION_MAXIMIZE) != 0); } g_signal_handlers_block_by_func (G_OBJECT (priv->above_item), item_activated_callback, GINT_TO_POINTER (ABOVE)); gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (priv->above_item), wnck_window_is_above (priv->window)); g_signal_handlers_unblock_by_func (G_OBJECT (priv->above_item), item_activated_callback, GINT_TO_POINTER (ABOVE)); gtk_widget_set_sensitive (priv->above_item, (actions & WNCK_WINDOW_ACTION_ABOVE) != 0); g_signal_handlers_block_by_func (G_OBJECT (priv->pin_item), item_activated_callback, GINT_TO_POINTER (PIN)); g_signal_handlers_block_by_func (G_OBJECT (priv->unpin_item), item_activated_callback, GINT_TO_POINTER (UNPIN)); if ((viewport_mode && wnck_window_is_sticky (priv->window)) || (!viewport_mode && wnck_window_is_pinned (priv->window))) gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (priv->pin_item), TRUE); else gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (priv->unpin_item), TRUE); g_signal_handlers_unblock_by_func (G_OBJECT (priv->pin_item), item_activated_callback, GINT_TO_POINTER (PIN)); g_signal_handlers_unblock_by_func (G_OBJECT (priv->unpin_item), item_activated_callback, GINT_TO_POINTER (UNPIN)); gtk_widget_set_sensitive (priv->pin_item, move_workspace_sensitive); gtk_widget_set_sensitive (priv->unpin_item, move_workspace_sensitive); gtk_widget_set_sensitive (priv->close_item, (actions & WNCK_WINDOW_ACTION_CLOSE) != 0); gtk_widget_set_sensitive (priv->move_item, (actions & WNCK_WINDOW_ACTION_MOVE) != 0); gtk_widget_set_sensitive (priv->resize_item, (actions & WNCK_WINDOW_ACTION_RESIZE) != 0); gtk_widget_set_sensitive (priv->workspace_item, move_workspace_sensitive); gtk_widget_set_sensitive (priv->left_item, move_workspace_sensitive); gtk_widget_set_sensitive (priv->right_item, move_workspace_sensitive); gtk_widget_set_sensitive (priv->up_item, move_workspace_sensitive); gtk_widget_set_sensitive (priv->down_item, move_workspace_sensitive); workspace = wnck_window_get_workspace (priv->window); if (viewport_mode && !wnck_window_is_sticky (priv->window)) { int window_x, window_y; int viewport_x, viewport_y; int viewport_width, viewport_height; int screen_width, screen_height; if (!workspace) workspace = wnck_screen_get_workspace (screen, 0); wnck_window_get_geometry (priv->window, &window_x, &window_y, NULL, NULL); viewport_x = wnck_workspace_get_viewport_x (workspace); viewport_y = wnck_workspace_get_viewport_y (workspace); window_x += viewport_x; window_y += viewport_y; viewport_width = wnck_workspace_get_width (workspace); viewport_height = wnck_workspace_get_height (workspace); screen_width = wnck_screen_get_width (screen); screen_height = wnck_screen_get_height (screen); if (window_x >= screen_width) gtk_widget_show (priv->left_item); else gtk_widget_hide (priv->left_item); if (window_x < viewport_width - screen_width) gtk_widget_show (priv->right_item); else gtk_widget_hide (priv->right_item); if (window_y >= screen_height) gtk_widget_show (priv->up_item); else gtk_widget_hide (priv->up_item); if (window_y < viewport_height - screen_height) gtk_widget_show (priv->down_item); else gtk_widget_hide (priv->down_item); } else if (!viewport_mode && workspace && !wnck_window_is_pinned (priv->window)) { if (wnck_workspace_get_neighbor (workspace, WNCK_MOTION_LEFT)) gtk_widget_show (priv->left_item); else gtk_widget_hide (priv->left_item); if (wnck_workspace_get_neighbor (workspace, WNCK_MOTION_RIGHT)) gtk_widget_show (priv->right_item); else gtk_widget_hide (priv->right_item); if (wnck_workspace_get_neighbor (workspace, WNCK_MOTION_UP)) gtk_widget_show (priv->up_item); else gtk_widget_hide (priv->up_item); if (wnck_workspace_get_neighbor (workspace, WNCK_MOTION_DOWN)) gtk_widget_show (priv->down_item); else gtk_widget_hide (priv->down_item); } else { gtk_widget_hide (priv->left_item); gtk_widget_hide (priv->right_item); gtk_widget_hide (priv->up_item); gtk_widget_hide (priv->down_item); } if (viewport_mode) { int viewport_width, viewport_height; int screen_width, screen_height; viewport_width = wnck_workspace_get_width (workspace); viewport_height = wnck_workspace_get_height (workspace); screen_width = wnck_screen_get_width (screen); screen_height = wnck_screen_get_height (screen); gtk_widget_show (priv->workspace_separator); gtk_widget_show (priv->pin_item); gtk_widget_show (priv->unpin_item); if (viewport_width >= 2 * screen_width || viewport_height >= 2 * screen_height) { gtk_widget_show (priv->workspace_item); refill_submenu_viewport (menu); } else { gtk_widget_hide (priv->workspace_item); gtk_menu_popdown (GTK_MENU (gtk_menu_item_get_submenu (GTK_MENU_ITEM (priv->workspace_item)))); } } else if (wnck_screen_get_workspace_count (screen) > 1) { gtk_widget_show (priv->workspace_separator); gtk_widget_show (priv->pin_item); gtk_widget_show (priv->unpin_item); gtk_widget_show (priv->workspace_item); refill_submenu_workspace (menu); } else { gtk_widget_hide (priv->workspace_separator); gtk_widget_hide (priv->pin_item); gtk_widget_hide (priv->unpin_item); gtk_widget_hide (priv->workspace_item); gtk_menu_popdown (GTK_MENU (gtk_menu_item_get_submenu (GTK_MENU_ITEM (priv->workspace_item)))); } gtk_menu_reposition (GTK_MENU (menu)); return FALSE; }