void max_button_event (WnckWindow *win, decor_event *gtkwd_event, decor_event_type gtkwd_type) { decor_t *d = g_object_get_data (G_OBJECT (win), "decor"); guint state = d->button_states[BUTTON_MAX]; if (action_menu_mapped && gtkwd_type == GButtonPress) { gtk_object_destroy (GTK_OBJECT (action_menu)); } if (wnck_window_is_maximized (win)) common_button_event (win, gtkwd_event, gtkwd_type, BUTTON_MAX, 3, _("Unmaximize Window")); else common_button_event (win, gtkwd_event, gtkwd_type, BUTTON_MAX, 3, _("Maximize Window")); switch (gtkwd_type) { case GButtonRelease: if (gtkwd_event->button <= 3) { if (state == BUTTON_EVENT_ACTION_STATE) { if (gtkwd_event->button == 1) { if (wnck_window_is_maximized (win)) wnck_window_unmaximize (win); else if (wnck_window_is_maximized_vertically (win)) wnck_window_unmaximize_vertically (win); else if (wnck_window_is_maximized_horizontally (win)) wnck_window_unmaximize_horizontally (win); else wnck_window_maximize (win); } else if (gtkwd_event->button == 2) { if (wnck_window_is_maximized_vertically (win)) wnck_window_unmaximize_vertically (win); else wnck_window_maximize_vertically (win); } else if (gtkwd_event->button == 3) { if (wnck_window_is_maximized_horizontally (win)) wnck_window_unmaximize_horizontally (win); else wnck_window_maximize_horizontally (win); } } } break; default: break; } }
void toggle_maximize (WnckWindow *window) { if (window && wnck_window_is_maximized(window)) wnck_window_unmaximize(window); else wnck_window_maximize(window); }
static gboolean wnck_window_timeout_cb (WnckWindow *window) { const gchar *game; gint x, y; gint width, height; gchar *sql; GError *error = NULL; if (wnck_window_is_fullscreen (window)) goto exit; game = wnck_window_get_game (window); wnck_window_get_geometry (window, &x, &y, &width, &height); if (wnck_window_is_maximized (window)) sql = g_strdup_printf ( "UPDATE window SET maximized = 1 " "WHERE name = '%s'", game); else sql = g_strdup_printf ( "UPDATE window SET x = %d, y = %d, width = %d, " "height = %d, maximized = 0 WHERE name = '%s'", x, y, width, height, game); gva_db_execute (sql, &error); gva_error_handle (&error); g_free (sql); exit: g_object_set_data (G_OBJECT (window), TIMEOUT_SOURCE_ID_KEY, NULL); return FALSE; }
void handle_title_button_event (WnckWindow *win, int action, decor_event *gtkwd_event) { switch (action) { case CLICK_ACTION_SHADE: if (wnck_window_is_shaded (win)) wnck_window_unshade (win); else wnck_window_shade (win); break; case CLICK_ACTION_MAXIMIZE: if (wnck_window_is_maximized (win)) wnck_window_unmaximize (win); else wnck_window_maximize (win); break; case CLICK_ACTION_MINIMIZE: if (!wnck_window_is_minimized (win)) wnck_window_minimize (win); break; case CLICK_ACTION_RAISE: restack_window (win, Above); break; case CLICK_ACTION_LOWER: restack_window (win, Below); break; case CLICK_ACTION_MENU: action_menu_map (win, gtkwd_event->button, gtkwd_event->time); break; } }
gboolean wibuti_watcher_is_maximized(WibutiWatcher *self) { if (WNCK_IS_WINDOW(self->tracked)) { return wnck_window_is_maximized(self->tracked); } else { return FALSE; } }
/** * ww_filter_user_windows * @windows: List of %WnckWindow<!-- -->s to filter * @current_workspace: Only use windows on this workspace. %NULL indicates * that all windows should be used * * Extract the user controlled visible windows from a %GList of * %WnckWindows. * * Return value: A newly allocated list containing only windows that are * not minimized, shaded, or wnck_window_skip_task_list() on the current * workspace. */ GList* ww_filter_user_windows (GList * windows, WnckWorkspace *current_workspace) { GList *next; GList *result; WnckWindow *win; WnckWorkspace *win_ws; result = NULL; for (next = windows; next; next = next->next) { win = WNCK_WINDOW(next->data); if (!wnck_window_is_skip_tasklist (win) && !wnck_window_is_minimized (win) && !wnck_window_is_maximized (win) && !wnck_window_is_shaded (win)) { win_ws = wnck_window_get_workspace (win); if (current_workspace == NULL || (win_ws == current_workspace && wnck_window_is_in_viewport(win, current_workspace)) || win_ws == NULL) result = g_list_append (result, win); } } return result; }
/* Triggers when a window has been closed */ static void on_window_closed (WnckScreen *screen, WnckWindow *window, WckUtils *win) { // track closed maximized window if (wnck_window_is_maximized(window)) track_controled_window (win); }
void wibuti_watcher_maximize_restore(WibutiWatcher *self) { if (WNCK_IS_WINDOW(self->tracked)) { if (wnck_window_is_maximized(self->tracked)) { wnck_window_unmaximize(self->tracked); } else { wnck_window_maximize(self->tracked); } } }
/* Returns the highest maximized window */ static WnckWindow *getUpperMaximized (WTApplet *wtapplet) { if (!wtapplet->prefs->only_maximized) return wtapplet->activewindow; GList *windows = wnck_screen_get_windows_stacked(wtapplet->activescreen); WnckWindow *returnwindow = NULL; while (windows && windows->data) { if (wnck_window_is_maximized(windows->data)) { // if(wnck_window_is_on_workspace(windows->data, wtapplet->activeworkspace)) if (!wnck_window_is_minimized(windows->data)) if (wnck_window_is_in_viewport(windows->data, wtapplet->activeworkspace)) returnwindow = windows->data; } windows = windows->next; } // start tracking the new umaxed window if (wtapplet->umaxedwindow) { if (g_signal_handler_is_connected(G_OBJECT(wtapplet->umaxedwindow), wtapplet->umaxed_handler_state)) g_signal_handler_disconnect(G_OBJECT(wtapplet->umaxedwindow), wtapplet->umaxed_handler_state); if (g_signal_handler_is_connected(G_OBJECT(wtapplet->umaxedwindow), wtapplet->umaxed_handler_name)) g_signal_handler_disconnect(G_OBJECT(wtapplet->umaxedwindow), wtapplet->umaxed_handler_name); if (g_signal_handler_is_connected(G_OBJECT(wtapplet->umaxedwindow), wtapplet->umaxed_handler_icon)) g_signal_handler_disconnect(G_OBJECT(wtapplet->umaxedwindow), wtapplet->umaxed_handler_icon); } if (returnwindow) { // maxed window was found wtapplet->umaxed_handler_state = g_signal_connect(G_OBJECT(returnwindow), "state-changed", G_CALLBACK (umaxed_window_state_changed), wtapplet); wtapplet->umaxed_handler_name = g_signal_connect(G_OBJECT(returnwindow), "name-changed", G_CALLBACK (umaxed_window_nameicon_changed), wtapplet); wtapplet->umaxed_handler_icon = g_signal_connect(G_OBJECT(returnwindow), "icon-changed", G_CALLBACK (umaxed_window_nameicon_changed), wtapplet); //return returnwindow; } else { // maxed window was not found returnwindow = wtapplet->rootwindow; //return wtapplet->rootwindow; } return returnwindow; // WARNING: if this function returns NULL, applet won't detect clicks! }
/* Triggers when umaxedwindow's state changes */ static void on_umaxed_window_state_changed (WnckWindow *window, WnckWindowState changed_mask, WnckWindowState new_state, WckUtils *win) { /* WARNING : only if window is unmaximized to prevent growing loop !!!*/ if (!wnck_window_is_maximized(window) || wnck_window_is_minimized(window) || changed_mask & (WNCK_WINDOW_STATE_ABOVE)) { track_controled_window (win); } else { on_wck_state_changed(win->controlwindow, win->data); } }
/* Trigger when a specific window's state changes */ static void track_changed_max_state (WnckWindow *window, WnckWindowState changed_mask, WnckWindowState new_state, WckUtils *win) { /* track the window max state only if it isn't the control window */ if (window != win->controlwindow) { if (window && !wnck_window_is_minimized(window) && wnck_window_is_maximized(window)) { track_controled_window (win); } } }
static gboolean title_clicked (GtkWidget *title, GdkEventButton *event, WTApplet *wtapplet) { // only allow left and right mouse button //if (event->button != 1 && event->button != 3) return FALSE; WnckWindow *controlledwindow; if (wtapplet->prefs->only_maximized) { controlledwindow = wtapplet->umaxedwindow; } else { controlledwindow = wtapplet->activewindow; } if (!controlledwindow) return FALSE; // single click (left/right) if (event->button == 1) { // left-click wnck_window_activate(controlledwindow, gtk_get_current_event_time()); if (event->type==GDK_2BUTTON_PRESS || event->type==GDK_3BUTTON_PRESS) { // double/tripple click //if (event->type==GDK_2BUTTON_PRESS) { if (wnck_window_is_maximized(controlledwindow)) { wnck_window_unmaximize(controlledwindow); } else { wnck_window_maximize(controlledwindow); } } } else if (event->button == 3) { // right-click if (wtapplet->prefs->show_window_menu) { wnck_window_activate(controlledwindow, gtk_get_current_event_time()); GtkMenu *window_menu = GTK_MENU(wnck_action_menu_new(controlledwindow)); gtk_menu_popup(window_menu, NULL, NULL, NULL, NULL, event->button, gtk_get_current_event_time()); //TODO: somehow alter the panel action menu to also display the wnck_action_menu ! } else { return FALSE; } } else { return FALSE; } return TRUE; }
static gboolean is_window_on_active_workspace_and_no_other_maximized_windows_above(WnckWindow *window) { WnckWorkspace *workspace = wnck_window_get_workspace(window); WnckScreen *screen = wnck_workspace_get_screen(workspace); if (wnck_screen_get_active_workspace(screen) != workspace) { return FALSE; } GList *windows = wnck_screen_get_windows_stacked(screen); GList *top_window = g_list_last(windows); GList *bottom_window = g_list_first(windows); while (top_window->data != window && top_window != bottom_window) { if (wnck_window_is_maximized((WnckWindow *)top_window->data)) { return FALSE; } top_window = top_window->prev; } return TRUE; }
/** * Depending on whether the window is maximized the task title is shown * or hidden. */ static void on_state_changed (WnckWindow *window, WnckWindowState changed_mask, WnckWindowState new_state, TaskTitle *title) { TaskTitlePrivate *priv = title->priv; g_return_if_fail (TASK_IS_TITLE (title)); g_return_if_fail (WNCK_IS_WINDOW (window)); if (priv->window != window) return; if (wnck_window_is_maximized (window)) { gtk_widget_set_state_flags (GTK_WIDGET (title), GTK_STATE_FLAG_ACTIVE, TRUE); gtk_widget_show (priv->grid); } else { gtk_widget_set_state_flags (GTK_WIDGET (title), GTK_STATE_FLAG_NORMAL, TRUE); gtk_widget_hide (priv->grid); } }
/* Returns the highest maximized window */ static WnckWindow *get_upper_maximized (WckUtils *win) { WnckWindow *umaxedwindow = NULL; GList *windows = wnck_screen_get_windows_stacked(win->activescreen); while (windows && windows->data) { if (!win->activeworkspace || wnck_window_is_in_viewport(windows->data, win->activeworkspace)) if (wnck_window_is_maximized(windows->data) && !wnck_window_is_minimized(windows->data)) { umaxedwindow = windows->data; } windows = windows->next; } /* NULL if no maximized window found */ return umaxedwindow; }
int c_get_window_is_maximized(lua_State *lua) { int top = lua_gettop(lua); if (top != 0) { luaL_error(lua, "get_window_is__maximized: %s", no_indata_expected_error); return 0; } WnckWindow *window = get_current_window(); gboolean is_maximized = FALSE; if (window) { is_maximized = wnck_window_is_maximized(window); } lua_pushboolean(lua, is_maximized); return 1; }
/** * Event handler for clicking on the title (not the close button) * On double click unmaximized the window * On right click it shows the context menu for the current window */ static gboolean on_button_press (GtkWidget *title, GdkEventButton *event) { g_return_val_if_fail (TASK_IS_TITLE (title), FALSE); TaskTitlePrivate *priv = TASK_TITLE (title)->priv; WnckWindow *window = wnck_screen_get_active_window (priv->screen); g_return_val_if_fail (WNCK_IS_WINDOW (window), FALSE); if (event->button == 3) { //right click if (wnck_window_get_window_type (window) != WNCK_WINDOW_DESKTOP) { GtkWidget *menu = wnck_action_menu_new (window); gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, event->button, event->time); return TRUE; } } else if (event->button == 1) { //left button double click if (event->type == GDK_2BUTTON_PRESS && wnck_window_is_maximized (window)) { wnck_window_unmaximize (window); } } return FALSE; }
static void on_active_window_changed (WnckScreen *screen, WnckWindow *old_window, TaskTitle *title) { g_return_if_fail (TASK_IS_TITLE (title)); WnckWindow *act_window = wnck_screen_get_active_window (screen); WnckWindowType type = WNCK_WINDOW_NORMAL; TaskTitlePrivate *priv = title->priv; if (act_window) type = wnck_window_get_window_type (act_window); disconnect_window (title); // Depending on the type and state of the window we adjust the title if(WNCK_IS_WINDOW(act_window)) { if(type == WNCK_WINDOW_DESKTOP) { /* The current window is the desktop so we show the home title if * the user has configured this, otherwise we hide the title */ if (window_picker_applet_get_show_home_title (priv->windowPickerApplet)) { show_home_title(title); } else { hide_title (title); } } else if(wnck_window_is_skip_tasklist (act_window) && type != WNCK_WINDOW_DESKTOP) { /* The current window is not in the task list, we dont change the * current title. */ return; } else if(type == WNCK_WINDOW_DOCK || type == WNCK_WINDOW_SPLASHSCREEN || type == WNCK_WINDOW_MENU) { return; } else { //for all other types if(wnck_window_is_maximized (act_window) && window_picker_applet_get_show_application_title (priv->windowPickerApplet)) { //show normal title of window gtk_label_set_text (GTK_LABEL (priv->label), wnck_window_get_name (act_window)); gtk_image_set_from_icon_name (GTK_IMAGE (priv->button_image), "window-close", GTK_ICON_SIZE_MENU); gtk_widget_set_tooltip_text (GTK_WIDGET (title), wnck_window_get_name (act_window)); gtk_widget_set_tooltip_text (priv->button, _("Close window")); g_signal_connect (act_window, "name-changed", G_CALLBACK (on_name_changed), title); g_signal_connect_after (act_window, "state-changed", G_CALLBACK (on_state_changed), title); gtk_widget_show (priv->grid); priv->window = act_window; } else { hide_title (title); //only show the title for maximized windows } } } else { //its not a window if (task_list_get_desktop_visible (TASK_LIST (window_picker_applet_get_tasks (priv->windowPickerApplet))) && window_picker_applet_get_show_home_title (priv->windowPickerApplet)) { show_home_title(title); } else { //reset the task title and hide it hide_title (title); } } gtk_widget_queue_draw (GTK_WIDGET (title)); }
static void wnck_window_initialize (WnckWindow *window) { const gchar *game; sqlite3_stmt *stmt; gchar *sql; gint errcode; gboolean success; GError *error = NULL; game = wnck_window_get_game (window); sql = g_strdup_printf (SQL_SELECT_GAME_WINDOW, game); success = gva_db_prepare (sql, &stmt, &error); gva_error_handle (&error); g_free (sql); if (!success) return; errcode = sqlite3_step (stmt); /* Restore the window's previous geometry. */ if (errcode == SQLITE_ROW) { gint x, y; gint width, height; gboolean maximized; x = sqlite3_column_int (stmt, COLUMN_X); y = sqlite3_column_int (stmt, COLUMN_Y); width = sqlite3_column_int (stmt, COLUMN_WIDTH); height = sqlite3_column_int (stmt, COLUMN_HEIGHT); maximized = sqlite3_column_int (stmt, COLUMN_MAXIMIZED); wnck_window_set_geometry ( window, WNCK_WINDOW_GRAVITY_CURRENT, WNCK_WINDOW_CHANGE_X | WNCK_WINDOW_CHANGE_Y | WNCK_WINDOW_CHANGE_WIDTH | WNCK_WINDOW_CHANGE_HEIGHT, x, y, width, height); if (maximized) wnck_window_maximize (window); else wnck_window_unmaximize (window); } /* Create a new record using the current geometry. */ else if (errcode == SQLITE_DONE) { gint x, y; gint width, height; gboolean maximized; maximized = wnck_window_is_maximized (window); wnck_window_get_geometry (window, &x, &y, &width, &height); sql = g_strdup_printf ( "INSERT INTO window VALUES " "('%s', %d, %d, %d, %d, %d)", game, x, y, width, height, maximized); gva_db_execute (sql, &error); gva_error_handle (&error); g_free (sql); } /* Something went wrong. */ else { gva_db_set_error (&error, 0, NULL); gva_error_handle (&error); } sqlite3_finalize (stmt); }
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; }
gboolean on_title_pressed(GtkWidget *title, GdkEventButton *event, WindowckPlugin *wckp) { if (!wckp->win->controlwindow) return FALSE; if (event->button == 1 && (wnck_window_get_window_type (wckp->win->controlwindow) != WNCK_WINDOW_DESKTOP)) { /* double/tripple click */ if (event->type == GDK_2BUTTON_PRESS || event->type == GDK_3BUTTON_PRESS) { toggle_maximize(wckp->win->controlwindow); } else /* left-click */ { wnck_window_activate(wckp->win->controlwindow, gtk_get_current_event_time()); // WnckScreen *screen = wnck_screen_get_default (); // wnck_screen_force_update (screen); WnckWindow *active_window = wckp->win->controlwindow; if (!wnck_window_is_maximized(active_window)) return TRUE; GdkDisplay *gdkdisp = gdk_display_get_default (); // Gdk 3 // GdkDevice *mouse = gdk_device_manager_get_client_pointer(gdk_display_get_device_manager(gdkdisp)); GdkDevice *mouse = gdk_device_get_core_pointer(); Display *d = gdk_x11_display_get_xdisplay(gdkdisp); XEvent xev; Atom netMoveResize = XInternAtom(d, "_NET_WM_MOVERESIZE", FALSE); xev.xclient.type = ClientMessage; xev.xclient.message_type = netMoveResize; xev.xclient.display = d; xev.xclient.window = wnck_window_get_xid(active_window); xev.xclient.format = 32; // Gdk 3 // int x, y; // gdk_device_get_position(mouse, NULL, &x, &y); // TODO: Provide a second argument to gdk_device_get_state gdouble xy[2]; gdk_device_get_state(mouse, NULL, xy, NULL); xev.xclient.data.l[0] = xy[0]; xev.xclient.data.l[1] = xy[1]; xev.xclient.data.l[2] = 8; // _NET_WM_MOVERESIZE_MOVE xev.xclient.data.l[3] = Button1; xev.xclient.data.l[4] = 0; XUngrabPointer(d, CurrentTime); XSendEvent(d, RootWindow(d, 0), FALSE, SubstructureRedirectMask | SubstructureNotifyMask, &xev); } return TRUE; } if (event->button == 3) { /* right-click */ wnck_window_activate(wckp->win->controlwindow, gtk_get_current_event_time()); /* let the panel show the menu */ return TRUE; } return FALSE; }
static void wibuti_watcher_find_window(WibutiWatcher *self) { WnckWorkspace *activeworkspace = wnck_screen_get_active_workspace(self->screen); WnckWindow *new_active = wnck_screen_get_active_window(self->screen); WnckWindow *new_tracked = NULL; // stop tracking the old active window if (G_IS_OBJECT(self->active)) { if (g_signal_handler_is_connected(G_OBJECT(self->active), self->handler_active_state_changed)) { g_signal_handler_disconnect(G_OBJECT(self->active), self->handler_active_state_changed); } } if (self->only_maximized) { // find upper maximized window GList *windows = wnck_screen_get_windows_stacked(self->screen); while (windows && windows->data) { if (!self->only_maximized || wnck_window_is_maximized(windows->data)) if (!wnck_window_is_minimized(windows->data) && !wnck_window_is_skip_pager(windows->data)) if (wnck_window_is_in_viewport(windows->data, activeworkspace)) new_tracked = windows->data; windows = windows->next; } // start tracking the new active window if (new_active) { self->handler_active_state_changed = g_signal_connect(G_OBJECT(new_active), "state-changed", G_CALLBACK(wibuti_watcher_window_state_changed_cb), self); } } else { new_tracked = new_active; } // stop tracking the old window if (G_IS_OBJECT(self->tracked)) { #ifdef WIBUTI_WITH_TITLE if (g_signal_handler_is_connected(G_OBJECT(self->tracked), self->handler_name_changed)) { g_signal_handler_disconnect(G_OBJECT(self->tracked), self->handler_name_changed); } if (g_signal_handler_is_connected(G_OBJECT(self->tracked), self->handler_icon_changed)) { g_signal_handler_disconnect(G_OBJECT(self->tracked), self->handler_icon_changed); } #endif // WIBUTI_WITH_TITLE if (g_signal_handler_is_connected(G_OBJECT(self->tracked), self->handler_tracked_state_changed)) { g_signal_handler_disconnect(G_OBJECT(self->tracked), self->handler_tracked_state_changed); } } // start tracking the new window if (new_tracked) { #ifdef WIBUTI_WITH_TITLE self->handler_name_changed = g_signal_connect(G_OBJECT(new_tracked), "name-changed", G_CALLBACK(wibuti_watcher_name_changed_cb), self); self->handler_icon_changed = g_signal_connect(G_OBJECT(new_tracked), "icon-changed", G_CALLBACK(wibuti_watcher_icon_changed_cb), self); #endif // WIBUTI_WITH_TITLE self->handler_tracked_state_changed = g_signal_connect(G_OBJECT(new_tracked), "state-changed", G_CALLBACK(wibuti_watcher_window_state_changed_cb), self); } self->tracked = new_tracked; self->active = new_active; }
static void item_activated_callback (GtkWidget *menu_item, gpointer data) { WnckActionMenu *menu; WnckWindow *window; WindowAction action = GPOINTER_TO_INT (data); WnckScreen *screen; gboolean viewport_mode; menu = get_action_menu (menu_item); if (menu == NULL) return; window = menu->priv->window; screen = wnck_window_get_screen (window); viewport_mode = wnck_screen_get_workspace_count (screen) == 1 && wnck_workspace_is_virtual (wnck_screen_get_workspace (screen, 0)); switch (action) { case CLOSE: /* In an activate callback, so gtk_get_current_event_time() suffices */ wnck_window_close (window, gtk_get_current_event_time ()); break; case MINIMIZE: if (wnck_window_is_minimized (window)) wnck_window_unminimize (window, gtk_get_current_event_time ()); else wnck_window_minimize (window); break; case MAXIMIZE: if (wnck_window_is_maximized (window)) wnck_window_unmaximize (window); else wnck_window_maximize (window); break; case ABOVE: if (wnck_window_is_above (window)) wnck_window_unmake_above (window); else wnck_window_make_above (window); break; case MOVE: wnck_window_keyboard_move (window); break; case RESIZE: wnck_window_keyboard_size (window); break; case PIN: if (!viewport_mode) wnck_window_pin (window); else wnck_window_stick (window); break; case UNPIN: if (!viewport_mode) wnck_window_unpin (window); else wnck_window_unstick (window); break; case LEFT: if (!viewport_mode) { WnckWorkspace *workspace; workspace = wnck_workspace_get_neighbor (wnck_window_get_workspace (window), WNCK_MOTION_LEFT); wnck_window_move_to_workspace (window, workspace); } else { int width, xw, yw, ww, hw; width = wnck_screen_get_width (screen); wnck_window_get_geometry (window, &xw, &yw, &ww, &hw); wnck_window_unstick (window); wnck_window_set_geometry (window, 0, WNCK_WINDOW_CHANGE_X | WNCK_WINDOW_CHANGE_Y, xw - width, yw, ww, hw); } break; case RIGHT: if (!viewport_mode) { WnckWorkspace *workspace; workspace = wnck_workspace_get_neighbor (wnck_window_get_workspace (window), WNCK_MOTION_RIGHT); wnck_window_move_to_workspace (window, workspace); } else { int width, xw, yw, ww, hw; width = wnck_screen_get_width (screen); wnck_window_get_geometry (window, &xw, &yw, &ww, &hw); wnck_window_unstick (window); wnck_window_set_geometry (window, 0, WNCK_WINDOW_CHANGE_X | WNCK_WINDOW_CHANGE_Y, xw + width, yw, ww, hw); } break; case UP: if (!viewport_mode) { WnckWorkspace *workspace; workspace = wnck_workspace_get_neighbor (wnck_window_get_workspace (window), WNCK_MOTION_UP); wnck_window_move_to_workspace (window, workspace); } else { int height, xw, yw, ww, hw; height = wnck_screen_get_height (screen); wnck_window_get_geometry (window, &xw, &yw, &ww, &hw); wnck_window_unstick (window); wnck_window_set_geometry (window, 0, WNCK_WINDOW_CHANGE_X | WNCK_WINDOW_CHANGE_Y, xw, yw - height, ww, hw); } break; case DOWN: if (!viewport_mode) { WnckWorkspace *workspace; workspace = wnck_workspace_get_neighbor (wnck_window_get_workspace (window), WNCK_MOTION_DOWN); wnck_window_move_to_workspace (window, workspace); } else { int height, xw, yw, ww, hw; height = wnck_screen_get_height (screen); wnck_window_get_geometry (window, &xw, &yw, &ww, &hw); wnck_window_unstick (window); wnck_window_set_geometry (window, 0, WNCK_WINDOW_CHANGE_X | WNCK_WINDOW_CHANGE_Y, xw, yw + height, ww, hw); } break; case MOVE_TO_WORKSPACE: if (!viewport_mode) { int workspace_index; WnckWorkspace *workspace; workspace_index = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (menu_item), "workspace")); workspace = wnck_screen_get_workspace (screen, workspace_index); wnck_window_move_to_workspace (window, workspace); } else { WnckWorkspace *workspace; int new_viewport_x, new_viewport_y; int width, height; int xw, yw, ww, hw; int viewport_x, viewport_y; new_viewport_x = GPOINTER_TO_INT ( g_object_get_data (G_OBJECT (menu_item), "viewport_x")); new_viewport_y = GPOINTER_TO_INT ( g_object_get_data (G_OBJECT (menu_item), "viewport_y")); workspace = wnck_screen_get_workspace (screen, 0); width = wnck_screen_get_width (screen); height = wnck_screen_get_height (screen); wnck_window_get_geometry (window, &xw, &yw, &ww, &hw); viewport_x = wnck_workspace_get_viewport_x (workspace); viewport_y = wnck_workspace_get_viewport_y (workspace); wnck_window_unstick (window); wnck_window_set_geometry (window, 0, WNCK_WINDOW_CHANGE_X | WNCK_WINDOW_CHANGE_Y, xw + new_viewport_x - viewport_x, yw + new_viewport_y - viewport_y, ww, hw); } break; default: g_assert_not_reached (); } }