From 3f122b87a866edb62d0402058f83974cf8a8fd54 Mon Sep 17 00:00:00 2001 From: Dylan McCall Date: Mon, 9 Jan 2012 02:36:16 +0100 Subject: Use positional sound for audible window bell Many components in the GNOME desktop use libcanberra-gtk to play sounds, which has led us to a wonderful world of positional sounds (in many cases), where a sound seems to come from the same direction as an interaction on the screen. Metacity uses libcanberra for audible bells, so it is pretty straight-forward to get the same feature. In my opinion, it would make Metacity's bell sound suddenly awesome, for a number of reasons. To implement the feature, Metacity needs to give a few extra properties to Canberra, which describe the position of the window associated with the bell. taken from https://bugzilla.gnome.org/show_bug.cgi?id=616743 --- src/core/bell.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'src/core') diff --git a/src/core/bell.c b/src/core/bell.c index 560b3569..efbfb7fd 100644 --- a/src/core/bell.c +++ b/src/core/bell.c @@ -300,10 +300,46 @@ meta_bell_notify (MetaDisplay *display, if (window) { + int x=-1, y=-1, width=-1, height=-1, screen_width=-1, screen_height=-1; + MetaScreen *screen; + + screen = meta_window_get_screen (window); + ca_proplist_sets (p, CA_PROP_WINDOW_NAME, window->title); ca_proplist_setf (p, CA_PROP_WINDOW_X11_XID, "%lu", (unsigned long)window->xwindow); + ca_proplist_setf (p, CA_PROP_WINDOW_X11_SCREEN, "%i", meta_screen_get_screen_number(screen)); ca_proplist_sets (p, CA_PROP_APPLICATION_NAME, window->res_name); ca_proplist_setf (p, CA_PROP_APPLICATION_PROCESS_ID, "%d", window->net_wm_pid); + + /* properties for positional sound based on window placement */ + meta_window_get_geometry (window, &x, &y, &width, &height); + ca_proplist_setf (p, CA_PROP_WINDOW_X, "%i", x); + ca_proplist_setf (p, CA_PROP_WINDOW_Y, "%i", y); + ca_proplist_setf (p, CA_PROP_WINDOW_WIDTH, "%i", width); + ca_proplist_setf (p, CA_PROP_WINDOW_HEIGHT, "%i", height); + + meta_screen_get_size (screen, &screen_width, &screen_height); + if (screen_width > 1) + { + x += width/2; + x = CLAMP(x, 0, screen_width-1); + + /* From libcanberra-gtk. + * We use these strange format strings here to avoid that libc + * applies locale information on the formatting of floating + * numbers. */ + + ca_proplist_setf (p, CA_PROP_WINDOW_HPOS, "%i.%03i", + (int) (x/(screen_width-1)), (int) (1000.0*x/(screen_width-1)) % 1000); + } + if (screen_height > 1) + { + y += height/2; + y = CLAMP(y, 0, screen_height-1); + + ca_proplist_setf (p, CA_PROP_WINDOW_VPOS, "%i.%03i", + (int) (y/(screen_height-1)), (int) (1000.0*y/(screen_height-1)) % 1000); + } } /* First, we try to play a real sound ... */ -- cgit v1.2.1 From dacdbd19b2d6037235aa4ed1bd28f89286236046 Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Mon, 9 Jan 2012 17:47:29 +0100 Subject: implement option for classic and toroidal workspace switching, based on https://bugzilla.gnome.org/show_bug.cgi?id=89315 --- src/core/prefs.c | 25 ++++++++++++++- src/core/workspace.c | 87 ++++++++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 102 insertions(+), 10 deletions(-) (limited to 'src/core') diff --git a/src/core/prefs.c b/src/core/prefs.c index 494d3da1..5b546f57 100644 --- a/src/core/prefs.c +++ b/src/core/prefs.c @@ -81,6 +81,7 @@ static MetaFocusNewWindows focus_new_windows = META_FOCUS_NEW_WINDOWS_SMART; static gboolean raise_on_click = TRUE; static char* current_theme = NULL; static int num_workspaces = 4; +static MetaWrapStyle wrap_style = META_WRAP_NONE; static MetaActionTitlebar action_double_click_titlebar = META_ACTION_TITLEBAR_TOGGLE_MAXIMIZE; static MetaActionTitlebar action_middle_click_titlebar = META_ACTION_TITLEBAR_LOWER; static MetaActionTitlebar action_right_click_titlebar = META_ACTION_TITLEBAR_MENU; @@ -188,6 +189,14 @@ static MateConfEnumStringPair symtab_focus_new_windows[] = { 0, NULL }, }; +static MateConfEnumStringPair symtab_wrap_style[] = + { + { META_WRAP_NONE, "no wrap" }, + { META_WRAP_CLASSIC, "classic" }, + { META_WRAP_TOROIDAL, "toroidal" }, + { 0, NULL }, + }; + static MateConfEnumStringPair symtab_visual_bell_type[] = { /* Note to the reader: 0 is an invalid value; these start at 1. */ @@ -327,6 +336,11 @@ static MetaEnumPreference preferences_enum[] = symtab_focus_mode, &focus_mode, }, + { "/apps/marco/general/wrap_style", + META_PREF_WRAP_STYLE, + symtab_wrap_style, + &wrap_style, + }, { "/apps/marco/general/visual_bell_type", META_PREF_VISUAL_BELL_TYPE, symtab_visual_bell_type, @@ -1642,6 +1656,12 @@ meta_prefs_get_num_workspaces (void) return num_workspaces; } +MetaWrapStyle +meta_prefs_get_wrap_style (void) +{ + return wrap_style; +} + gboolean meta_prefs_get_application_based (void) { @@ -1679,7 +1699,7 @@ meta_preference_to_string (MetaPreference pref) case META_PREF_RAISE_ON_CLICK: return "RAISE_ON_CLICK"; - + case META_PREF_THEME: return "THEME"; @@ -1689,6 +1709,9 @@ meta_preference_to_string (MetaPreference pref) case META_PREF_NUM_WORKSPACES: return "NUM_WORKSPACES"; + case META_PREF_WRAP_STYLE: + return "WRAP_STYLE"; + case META_PREF_APPLICATION_BASED: return "APPLICATION_BASED"; diff --git a/src/core/workspace.c b/src/core/workspace.c index 2b28fe0b..9694c1f9 100644 --- a/src/core/workspace.c +++ b/src/core/workspace.c @@ -809,21 +809,23 @@ MetaWorkspace* meta_workspace_get_neighbor (MetaWorkspace *workspace, MetaMotionDirection direction) { - MetaWorkspaceLayout layout; + MetaWorkspaceLayout layout; int i, current_space, num_workspaces; gboolean ltr; + MetaWrapStyle wrap; current_space = meta_workspace_index (workspace); num_workspaces = meta_screen_get_n_workspaces (workspace->screen); meta_screen_calc_workspace_layout (workspace->screen, num_workspaces, current_space, &layout); + wrap = meta_prefs_get_wrap_style(); meta_verbose ("Getting neighbor of %d in direction %s\n", current_space, meta_motion_direction_to_string (direction)); - + ltr = meta_ui_get_direction() == META_UI_DIRECTION_LTR; - switch (direction) + switch (direction) { case META_MOTION_LEFT: layout.current_col -= ltr ? 1 : -1; @@ -839,14 +841,81 @@ meta_workspace_get_neighbor (MetaWorkspace *workspace, break; } + /* LEFT */ if (layout.current_col < 0) - layout.current_col = 0; + switch (wrap) + { + case META_WRAP_NONE: + layout.current_col = 0; + break; + case META_WRAP_TOROIDAL: + layout.current_row = layout.current_row > 0 ? layout.current_row - 1 : layout.rows - 1; + /* fall through */ + case META_WRAP_CLASSIC: + layout.current_col = layout.cols - 1; + } + /* RIGHT */ if (layout.current_col >= layout.cols) - layout.current_col = layout.cols - 1; + switch (wrap) + { + case META_WRAP_NONE: + layout.current_col = layout.cols - 1; + break; + case META_WRAP_TOROIDAL: + layout.current_row = layout.current_row < layout.rows - 1 ? layout.current_row + 1 : 0; + /* fall through */ + case META_WRAP_CLASSIC: + layout.current_col = 0; + } + /* UP */ if (layout.current_row < 0) - layout.current_row = 0; + switch (wrap) + { + case META_WRAP_NONE: + layout.current_row = 0; + break; + case META_WRAP_TOROIDAL: + layout.current_col = layout.current_col > 0 ? layout.current_col - 1 : layout.cols - 1; + /* fall through */ + case META_WRAP_CLASSIC: + layout.current_row = layout.rows - 1; + } + /* DOWN */ if (layout.current_row >= layout.rows) - layout.current_row = layout.rows - 1; + switch (wrap) + { + case META_WRAP_NONE: + layout.current_row = layout.rows - 1; + break; + case META_WRAP_TOROIDAL: + layout.current_col = layout.current_col < layout.cols - 1 ? layout.current_col + 1 : 0; + /* fall through */ + case META_WRAP_CLASSIC: + layout.current_row = 0; + } + + /* If we have an uneven arrangement of workspaces, (layout.cols - n, layout.rows - 1) may be an invalid workspace + e.g. we have 7 workspaces on a 3x3 pane */ + if (wrap != META_WRAP_NONE && (layout.current_row * layout.cols + layout.current_col >= num_workspaces)) + switch (direction) + { + case META_MOTION_LEFT: + layout.current_col = num_workspaces - (layout.current_row * layout.cols + 1); + break; + case META_MOTION_RIGHT: + layout.current_col = 0; + if (wrap == META_WRAP_TOROIDAL) + layout.current_row = 0; + break; + case META_MOTION_UP: + layout.current_row -= 1; + break; + case META_MOTION_DOWN: + layout.current_row = 0; + if (wrap == META_WRAP_TOROIDAL) + layout.current_col = layout.current_col < layout.cols - 1 ? layout.current_col + 1 : 0; + break; + } i = layout.grid[layout.current_row * layout.cols + layout.current_col]; @@ -856,12 +925,12 @@ meta_workspace_get_neighbor (MetaWorkspace *workspace, if (i >= num_workspaces) meta_bug ("calc_workspace_layout left an invalid (too-high) workspace number %d in the grid\n", i); - + meta_verbose ("Neighbor workspace is %d at row %d col %d\n", i, layout.current_row, layout.current_col); meta_screen_free_workspace_layout (&layout); - + return meta_screen_get_workspace_by_index (workspace->screen, i); } -- cgit v1.2.1 From e2d0da87ec3f7add9643c7f7f424df080d95d8dc Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Mon, 9 Jan 2012 17:55:18 +0100 Subject: Introduce key combination to switch between windows on all workspaces taken from https://bugzilla.gnome.org/show_bug.cgi?id=577699 --- src/core/display-private.h | 3 +- src/core/display.c | 121 +++++++++++++++++++++++++++++---------------- src/core/keybindings.c | 11 +++++ 3 files changed, 92 insertions(+), 43 deletions(-) (limited to 'src/core') diff --git a/src/core/display-private.h b/src/core/display-private.h index 692e25f2..c59c5e19 100644 --- a/src/core/display-private.h +++ b/src/core/display-private.h @@ -445,7 +445,8 @@ typedef enum { META_TAB_LIST_NORMAL, META_TAB_LIST_DOCKS, - META_TAB_LIST_GROUP + META_TAB_LIST_GROUP, + META_TAB_LIST_NORMAL_ALL_WORKSPACES } MetaTabList; typedef enum diff --git a/src/core/display.c b/src/core/display.c index 59ec9021..647581f5 100644 --- a/src/core/display.c +++ b/src/core/display.c @@ -90,7 +90,9 @@ (g == META_GRAB_OP_KEYBOARD_TABBING_NORMAL || \ g == META_GRAB_OP_KEYBOARD_TABBING_DOCK || \ g == META_GRAB_OP_KEYBOARD_TABBING_GROUP || \ + g == META_GRAB_OP_KEYBOARD_TABBING_NORMAL_ALL_WORKSPACES || \ g == META_GRAB_OP_KEYBOARD_ESCAPING_NORMAL || \ + g == META_GRAB_OP_KEYBOARD_ESCAPING_NORMAL_ALL_WORKSPACES || \ g == META_GRAB_OP_KEYBOARD_ESCAPING_DOCK || \ g == META_GRAB_OP_KEYBOARD_ESCAPING_GROUP) @@ -1141,9 +1143,11 @@ grab_op_is_keyboard (MetaGrabOp op) case META_GRAB_OP_KEYBOARD_RESIZING_SW: case META_GRAB_OP_KEYBOARD_RESIZING_NW: case META_GRAB_OP_KEYBOARD_TABBING_NORMAL: + case META_GRAB_OP_KEYBOARD_TABBING_NORMAL_ALL_WORKSPACES: case META_GRAB_OP_KEYBOARD_TABBING_DOCK: case META_GRAB_OP_KEYBOARD_TABBING_GROUP: case META_GRAB_OP_KEYBOARD_ESCAPING_NORMAL: + case META_GRAB_OP_KEYBOARD_ESCAPING_NORMAL_ALL_WORKSPACES: case META_GRAB_OP_KEYBOARD_ESCAPING_DOCK: case META_GRAB_OP_KEYBOARD_ESCAPING_GROUP: case META_GRAB_OP_KEYBOARD_WORKSPACE_SWITCHING: @@ -3625,12 +3629,23 @@ meta_display_begin_grab_op (MetaDisplay *display, META_TAB_LIST_NORMAL, META_TAB_SHOW_ICON); break; + case META_GRAB_OP_KEYBOARD_TABBING_NORMAL_ALL_WORKSPACES: + meta_screen_ensure_tab_popup (screen, + META_TAB_LIST_NORMAL_ALL_WORKSPACES, + META_TAB_SHOW_ICON); + break; case META_GRAB_OP_KEYBOARD_ESCAPING_NORMAL: meta_screen_ensure_tab_popup (screen, META_TAB_LIST_NORMAL, META_TAB_SHOW_INSTANTLY); break; + case META_GRAB_OP_KEYBOARD_ESCAPING_NORMAL_ALL_WORKSPACES: + meta_screen_ensure_tab_popup (screen, + META_TAB_LIST_NORMAL_ALL_WORKSPACES, + META_TAB_SHOW_INSTANTLY); + break; + case META_GRAB_OP_KEYBOARD_TABBING_DOCK: meta_screen_ensure_tab_popup (screen, META_TAB_LIST_DOCKS, @@ -4441,7 +4456,9 @@ get_focussed_group (MetaDisplay *display) return NULL; } -#define IN_TAB_CHAIN(w,t) (((t) == META_TAB_LIST_NORMAL && META_WINDOW_IN_NORMAL_TAB_CHAIN (w)) \ +#define IN_TAB_CHAIN(w,t) \ + (((t) == META_TAB_LIST_NORMAL && META_WINDOW_IN_NORMAL_TAB_CHAIN (w)) \ + || ((t) == META_TAB_LIST_NORMAL_ALL_WORKSPACES && META_WINDOW_IN_NORMAL_TAB_CHAIN (w)) \ || ((t) == META_TAB_LIST_DOCKS && META_WINDOW_IN_DOCK_TAB_CHAIN (w)) \ || ((t) == META_TAB_LIST_GROUP && META_WINDOW_IN_GROUP_TAB_CHAIN (w, get_focussed_group(w->display)))) @@ -4532,56 +4549,76 @@ GList* meta_display_get_tab_list (MetaDisplay *display, MetaTabList type, MetaScreen *screen, - MetaWorkspace *workspace) + MetaWorkspace *active_workspace) { - GList *tab_list; + GList *tab_list, *workspace_list, *l, link; + MetaWorkspace *workspace; - g_return_val_if_fail (workspace != NULL, NULL); + g_return_val_if_fail (active_workspace != NULL, NULL); + + if (type == META_TAB_LIST_NORMAL_ALL_WORKSPACES) + { + workspace_list = screen->workspaces; + type = META_TAB_LIST_NORMAL; + } + else + { + link.next = NULL; + link.prev = NULL; + link.data = active_workspace; + workspace_list = &link; + } + tab_list = NULL; /* Windows sellout mode - MRU order. Collect unminimized windows * then minimized so minimized windows aren't in the way so much. */ - { - GList *tmp; - - tab_list = NULL; - tmp = workspace->mru_list; - while (tmp != NULL) - { - MetaWindow *window = tmp->data; - - if (!window->minimized && - window->screen == screen && - IN_TAB_CHAIN (window, type)) - tab_list = g_list_prepend (tab_list, window); - - tmp = tmp->next; - } - } - - { - GList *tmp; - - tmp = workspace->mru_list; - while (tmp != NULL) - { - MetaWindow *window = tmp->data; - - if (window->minimized && - window->screen == screen && - IN_TAB_CHAIN (window, type)) - tab_list = g_list_prepend (tab_list, window); - - tmp = tmp->next; - } - } - + for (l = workspace_list; l != NULL; l = l->next) + { + GList *tmp; + + workspace = l->data; + + tmp = workspace->mru_list; + while (tmp != NULL) + { + MetaWindow *window = tmp->data; + + if (!window->minimized && + window->screen == screen && + IN_TAB_CHAIN (window, type)) + tab_list = g_list_prepend (tab_list, window); + + tmp = tmp->next; + } + } + + for (l = workspace_list; l != NULL; l = l->next) + { + GList *tmp; + + workspace = l->data; + + tmp = workspace->mru_list; + while (tmp != NULL) + { + MetaWindow *window = tmp->data; + + if (window->minimized && + window->screen == screen && + IN_TAB_CHAIN (window, type)) + tab_list = g_list_prepend (tab_list, window); + + tmp = tmp->next; + } + } + tab_list = g_list_reverse (tab_list); - + { GSList *tmp; MetaWindow *l_window; - + tmp = meta_display_list_windows (display); /* Go through all windows */ @@ -4591,7 +4628,7 @@ meta_display_get_tab_list (MetaDisplay *display, /* Check to see if it demands attention */ if (l_window->wm_state_demands_attention && - l_window->workspace!=workspace && + l_window->workspace!=active_workspace && IN_TAB_CHAIN (l_window, type)) { /* if it does, add it to the popup */ diff --git a/src/core/keybindings.c b/src/core/keybindings.c index b9371c85..e1d87920 100644 --- a/src/core/keybindings.c +++ b/src/core/keybindings.c @@ -1340,9 +1340,11 @@ meta_display_process_key_event (MetaDisplay *display, break; case META_GRAB_OP_KEYBOARD_TABBING_NORMAL: + case META_GRAB_OP_KEYBOARD_TABBING_NORMAL_ALL_WORKSPACES: case META_GRAB_OP_KEYBOARD_TABBING_DOCK: case META_GRAB_OP_KEYBOARD_TABBING_GROUP: case META_GRAB_OP_KEYBOARD_ESCAPING_NORMAL: + case META_GRAB_OP_KEYBOARD_ESCAPING_NORMAL_ALL_WORKSPACES: case META_GRAB_OP_KEYBOARD_ESCAPING_DOCK: case META_GRAB_OP_KEYBOARD_ESCAPING_GROUP: meta_topic (META_DEBUG_KEYBINDINGS, @@ -2029,6 +2031,7 @@ process_tab_grab (MetaDisplay *display, target_window->desc); display->mouse_mode = FALSE; meta_window_activate (target_window, event->xkey.time); + meta_workspace_activate (target_window->workspace, event->xkey.time); meta_topic (META_DEBUG_KEYBINDINGS, "Ending grab early so we can focus the target window\n"); @@ -2070,6 +2073,7 @@ process_tab_grab (MetaDisplay *display, switch (display->grab_op) { case META_GRAB_OP_KEYBOARD_ESCAPING_NORMAL: + case META_GRAB_OP_KEYBOARD_ESCAPING_NORMAL_ALL_WORKSPACES: case META_GRAB_OP_KEYBOARD_ESCAPING_DOCK: /* carry on */ break; @@ -2087,6 +2091,7 @@ process_tab_grab (MetaDisplay *display, switch (display->grab_op) { case META_GRAB_OP_KEYBOARD_TABBING_NORMAL: + case META_GRAB_OP_KEYBOARD_TABBING_NORMAL_ALL_WORKSPACES: case META_GRAB_OP_KEYBOARD_TABBING_DOCK: /* carry on */ break; @@ -2810,6 +2815,8 @@ tab_op_from_tab_type (MetaTabList type) { case META_TAB_LIST_NORMAL: return META_GRAB_OP_KEYBOARD_TABBING_NORMAL; + case META_TAB_LIST_NORMAL_ALL_WORKSPACES: + return META_GRAB_OP_KEYBOARD_TABBING_NORMAL_ALL_WORKSPACES; case META_TAB_LIST_DOCKS: return META_GRAB_OP_KEYBOARD_TABBING_DOCK; case META_TAB_LIST_GROUP: @@ -2828,6 +2835,8 @@ cycle_op_from_tab_type (MetaTabList type) { case META_TAB_LIST_NORMAL: return META_GRAB_OP_KEYBOARD_ESCAPING_NORMAL; + case META_TAB_LIST_NORMAL_ALL_WORKSPACES: + return META_GRAB_OP_KEYBOARD_ESCAPING_NORMAL_ALL_WORKSPACES; case META_TAB_LIST_DOCKS: return META_GRAB_OP_KEYBOARD_ESCAPING_DOCK; case META_TAB_LIST_GROUP: @@ -2888,6 +2897,7 @@ do_choose_window (MetaDisplay *display, initial_selection->desc); display->mouse_mode = FALSE; meta_window_activate (initial_selection, event->xkey.time); + meta_workspace_activate (initial_selection->workspace, event->xkey.time); } else if (meta_display_begin_grab_op (display, screen, @@ -2917,6 +2927,7 @@ do_choose_window (MetaDisplay *display, meta_display_end_grab_op (display, event->xkey.time); display->mouse_mode = FALSE; meta_window_activate (initial_selection, event->xkey.time); + meta_workspace_activate (initial_selection->workspace, event->xkey.time); } else { -- cgit v1.2.1