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; } }
void toggle_maximize (WnckWindow *window) { if (window && wnck_window_is_maximized(window)) wnck_window_unmaximize(window); else wnck_window_maximize(window); }
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 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); } } }
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; }
/** * Unmaximize window */ int c_unmaximize_window(lua_State *lua) { int top = lua_gettop(lua); if (top != 0) { luaL_error(lua, "unmaximize: %s", no_indata_expected_error); return 0; } if (!devilspie2_emulate) { WnckWindow *window = get_current_window(); if (window) { wnck_window_unmaximize(window); } } return 0; }
/** * 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 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 (); } }
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); }