diff --git a/ChangeLog b/ChangeLog index d51537684..a9a0987d0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,32 @@ +2007-04-15 Elijah Newren + + Remove incorrect usage of window.h from menu.c. See #426791 & + #382962. + + * src/menu.c (enum MetaMenuItemType, variable menuitems, + meta_menu_item_new): + cleanup: add a MENU_ITEM_RADIOBUTTON for the sticky stuff + + * src/menu.c (variable menuitems): + * src/core.c (meta_core_get_menu_accelerator): + * src/window.c (menu_callback, meta_window_show_menu): + * src/common.h (enum MetaMenuOp): + reinstate META_MENU_OP_UNABOVE + + * src/menu.c (meta_window_menu_new): + remove hacks (using inappropriate data) for STICK/UNSTICK/ABOVE + and clean it up while just setting STICK/UNSTICK activeness as + necessary + + * src/menu.[ch] (meta_window_menu_new): + * src/ui.[ch] (meta_ui_window_menu_new): + make the active_workspace parameter an unsigned long + +2007-04-15 Bruno Boaventura + + * src/menu.c (meta_window_menu_new): don't show the current + workspace as a possible workspace to switch to. Fixes #426791. + 2007-04-12 Elijah Newren * src/place.c (meta_window_place): do not auto-maximize windows diff --git a/src/common.h b/src/common.h index c24def532..8bdce9d37 100644 --- a/src/common.h +++ b/src/common.h @@ -64,11 +64,12 @@ typedef enum META_MENU_OP_MOVE = 1 << 9, META_MENU_OP_RESIZE = 1 << 10, META_MENU_OP_ABOVE = 1 << 11, - META_MENU_OP_MOVE_LEFT = 1 << 12, - META_MENU_OP_MOVE_RIGHT = 1 << 13, - META_MENU_OP_MOVE_UP = 1 << 14, - META_MENU_OP_MOVE_DOWN = 1 << 15, - META_MENU_OP_RECOVER = 1 << 16 + META_MENU_OP_UNABOVE = 1 << 12, + META_MENU_OP_MOVE_LEFT = 1 << 13, + META_MENU_OP_MOVE_RIGHT = 1 << 14, + META_MENU_OP_MOVE_UP = 1 << 15, + META_MENU_OP_MOVE_DOWN = 1 << 16, + META_MENU_OP_RECOVER = 1 << 17 } MetaMenuOp; typedef struct _MetaWindowMenu MetaWindowMenu; diff --git a/src/core.c b/src/core.c index fe918bfe5..a11b653eb 100644 --- a/src/core.c +++ b/src/core.c @@ -531,6 +531,7 @@ meta_core_get_menu_accelerator (MetaMenuOp menu_op, name = META_KEYBINDING_TOGGLE_STICKY; break; case META_MENU_OP_ABOVE: + case META_MENU_OP_UNABOVE: name = META_KEYBINDING_TOGGLE_ABOVE; break; case META_MENU_OP_WORKSPACES: diff --git a/src/menu.c b/src/menu.c index 7f7dd0624..674c5dfe6 100644 --- a/src/menu.c +++ b/src/menu.c @@ -32,7 +32,6 @@ #include "core.h" #include "themewidget.h" #include "metaaccellabel.h" -#include "window.h" typedef struct _MenuItem MenuItem; typedef struct _MenuData MenuData; @@ -43,6 +42,7 @@ typedef enum MENU_ITEM_NORMAL, MENU_ITEM_IMAGE, MENU_ITEM_CHECKBOX, + MENU_ITEM_RADIOBUTTON, } MetaMenuItemType; struct _MenuItem @@ -87,9 +87,11 @@ static MenuItem menuitems[] = { /* Translators: Translate this string the same way as you do in libwnck! */ { META_MENU_OP_ABOVE, MENU_ITEM_CHECKBOX, NULL, FALSE, N_("Always on _Top") }, /* Translators: Translate this string the same way as you do in libwnck! */ - { META_MENU_OP_STICK, MENU_ITEM_CHECKBOX, NULL, FALSE, N_("_Always on Visible Workspace") }, + { META_MENU_OP_UNABOVE, MENU_ITEM_CHECKBOX, NULL, TRUE, N_("Always on _Top") }, /* Translators: Translate this string the same way as you do in libwnck! */ - { META_MENU_OP_UNSTICK, MENU_ITEM_CHECKBOX, NULL, FALSE, N_("_Only on This Workspace") }, + { META_MENU_OP_STICK, MENU_ITEM_RADIOBUTTON, NULL, FALSE, N_("_Always on Visible Workspace") }, + /* Translators: Translate this string the same way as you do in libwnck! */ + { META_MENU_OP_UNSTICK, MENU_ITEM_RADIOBUTTON, NULL, FALSE, N_("_Only on This Workspace") }, /* Translators: Translate this string the same way as you do in libwnck! */ { META_MENU_OP_MOVE_LEFT, MENU_ITEM_NORMAL, NULL, FALSE, N_("Move to Workspace _Left") }, /* Translators: Translate this string the same way as you do in libwnck! */ @@ -274,14 +276,18 @@ menu_item_new (MenuItem *menuitem, int workspace_id) { mi = gtk_check_menu_item_new (); - if (menuitem->op == META_MENU_OP_STICK || menuitem->op == META_MENU_OP_UNSTICK) - { - gtk_check_menu_item_set_draw_as_radio (GTK_CHECK_MENU_ITEM (mi), - TRUE); - } - else - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (mi), menuitem->checked); + gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (mi), + menuitem->checked); } + else if (menuitem->type == MENU_ITEM_RADIOBUTTON) + { + mi = gtk_check_menu_item_new (); + + gtk_check_menu_item_set_draw_as_radio (GTK_CHECK_MENU_ITEM (mi), + TRUE); + gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (mi), + menuitem->checked); + } else return gtk_separator_menu_item_new (); @@ -305,7 +311,7 @@ meta_window_menu_new (MetaFrames *frames, MetaMenuOp ops, MetaMenuOp insensitive, Window client_xwindow, - int active_workspace, + unsigned long active_workspace, int n_workspaces, MetaWindowMenuFunc func, gpointer data) @@ -313,6 +319,7 @@ meta_window_menu_new (MetaFrames *frames, int i; MetaWindowMenu *menu; + /* FIXME: Modifications to 'ops' should happen in meta_window_show_menu */ if (n_workspaces < 2) ops &= ~(META_MENU_OP_STICK | META_MENU_OP_UNSTICK | META_MENU_OP_WORKSPACES); else if (n_workspaces == 2) @@ -344,26 +351,19 @@ meta_window_menu_new (MetaFrames *frames, mi = menu_item_new (&menuitem, -1); - if ((menuitem.op == META_MENU_OP_STICK) || - (menuitem.op == META_MENU_OP_UNSTICK) || - (menuitem.op == META_MENU_OP_ABOVE)) + /* Set the activeness of radiobuttons. */ + switch (menuitem.op) { - Display *xdisplay; - MetaDisplay *display; - MetaWindow *window; - - xdisplay = gdk_x11_drawable_get_xdisplay (GTK_WIDGET (frames)->window); - display = meta_display_for_x_display (xdisplay); - window = meta_display_lookup_x_window (display, client_xwindow); - - if (menuitem.op == META_MENU_OP_STICK) - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (mi), window->on_all_workspaces); - else - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (mi), !window->on_all_workspaces); - - if (menuitem.op == META_MENU_OP_ABOVE) - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (mi), window->wm_state_above); - + case META_MENU_OP_STICK: + gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (mi), + active_workspace == 0xFFFFFFFF); + break; + case META_MENU_OP_UNSTICK: + gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (mi), + active_workspace != 0xFFFFFFFF); + break; + default: + break; } if (menuitem.type != MENU_ITEM_SEPARATOR) @@ -407,7 +407,7 @@ meta_window_menu_new (MetaFrames *frames, N_("Move to Another _Workspace") }; - meta_verbose ("Creating %d-workspace menu current space %d\n", + meta_verbose ("Creating %d-workspace menu current space %lu\n", n_workspaces, active_workspace); display = gdk_x11_drawable_get_xdisplay (GTK_WIDGET (frames)->window); @@ -443,12 +443,9 @@ meta_window_menu_new (MetaFrames *frames, g_free (label); - if (!(ops & META_MENU_OP_UNSTICK) && - (active_workspace == i || - insensitive & META_MENU_OP_WORKSPACES)) - gtk_widget_set_sensitive (mi, FALSE); - else if (insensitive & META_MENU_OP_WORKSPACES) + if ((active_workspace == (unsigned)i) && (ops & META_MENU_OP_UNSTICK)) gtk_widget_set_sensitive (mi, FALSE); + md = g_new (MenuData, 1); md->menu = menu; diff --git a/src/menu.h b/src/menu.h index 6bb544a68..39bb7fa34 100644 --- a/src/menu.h +++ b/src/menu.h @@ -47,7 +47,7 @@ MetaWindowMenu* meta_window_menu_new (MetaFrames *frames, MetaMenuOp ops, MetaMenuOp insensitive, Window client_xwindow, - int active_workspace, + unsigned long active_workspace, int n_workspaces, MetaWindowMenuFunc func, gpointer data); diff --git a/src/ui.c b/src/ui.c index 16b95255a..6f0e8789c 100644 --- a/src/ui.c +++ b/src/ui.c @@ -319,7 +319,7 @@ meta_ui_window_menu_new (MetaUI *ui, Window client_xwindow, MetaMenuOp ops, MetaMenuOp insensitive, - int active_workspace, + unsigned long active_workspace, int n_workspaces, MetaWindowMenuFunc func, gpointer data) diff --git a/src/ui.h b/src/ui.h index bb8122f9a..6038a7675 100644 --- a/src/ui.h +++ b/src/ui.h @@ -116,7 +116,7 @@ MetaWindowMenu* meta_ui_window_menu_new (MetaUI *ui, Window client_xwindow, MetaMenuOp ops, MetaMenuOp insensitive, - int active_workspace, + unsigned long active_workspace, int n_workspaces, MetaWindowMenuFunc func, gpointer data); diff --git a/src/window.c b/src/window.c index 6b81d399f..59267c808 100644 --- a/src/window.c +++ b/src/window.c @@ -6408,6 +6408,7 @@ menu_callback (MetaWindowMenu *menu, break; case META_MENU_OP_ABOVE: + case META_MENU_OP_UNABOVE: if (window->wm_state_above == FALSE) meta_window_make_above (window); else @@ -6537,7 +6538,10 @@ meta_window_show_menu (MetaWindow *window, ops |= META_MENU_OP_UNSTICK; ops |= META_MENU_OP_STICK; - ops |= META_MENU_OP_ABOVE; + if (window->wm_state_above) + ops |= META_MENU_OP_UNABOVE; + else + ops |= META_MENU_OP_ABOVE; if (!window->has_maximize_func) insensitive |= META_MENU_OP_UNMAXIMIZE | META_MENU_OP_MAXIMIZE; @@ -6563,7 +6567,7 @@ meta_window_show_menu (MetaWindow *window, if ((window->type == META_WINDOW_DESKTOP) || (window->type == META_WINDOW_DOCK) || (window->type == META_WINDOW_SPLASHSCREEN)) - insensitive |= META_MENU_OP_ABOVE; + insensitive |= META_MENU_OP_ABOVE | META_MENU_OP_UNABOVE; /* If all operations are disabled, just quit without showing the menu. * This is the case, for example, with META_WINDOW_DESKTOP windows.