2006-10-01 22:30:10 +00:00
|
|
|
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
|
|
|
|
Comprehensively rename to Mutter
Code:
All references in the code not related to themes, keybindings, or
GConf were changed from 'metacity' to 'mutter'. This includes, among other
things, strings, comments, the atoms used in the message protocol, and
the envvars used for debugging. The GConf schema file was reduced to
the 3 settings new to mutter.
The overall version was brought up to 2.27 to match current gnome.
Structure:
All files named '*metacity*' were renamed '*mutter*' with appropriate
changes in the automake system. Files removed are
doc/creating_themes, src/themes, doc/metacity-theme.dtd,
metacity.doap. These files will eventually end up in an external
gnome-wm-data module.
Installation location:
On the filesystem the mutter-plugindir was change from
$(libdir)/metacity/plugins/clutter to just $(libdir)/mutter/plugins.
The mutter-plugins.pc.in reflects these changes.
Note:
mutter.desktop.in and mutter-wm.desktop both continue to have
X-GNOME-WMSettingsModule=metacity set. This allows
gnome-control-center to continue using libmetacity.so for
configuration. This is fine since most the general keybindings and wm
settings are being read from /apps/metacity/* in gconf.
2009-06-10 10:29:20 +00:00
|
|
|
/* Mutter window menu */
|
2001-06-07 02:42:24 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (C) 2001 Havoc Pennington
|
2004-02-23 01:48:29 +00:00
|
|
|
* Copyright (C) 2004 Rob Adams
|
Merge of all the changes on the constraints_experiments branch. This is
2005-11-18 Elijah Newren <newren@gmail.com>
Merge of all the changes on the constraints_experiments branch.
This is just a summary, to get the full ChangeLog of those
changes (approx. 2000 lines):
cvs -q -z3 update -Pd -r constraints_experiments
cvs -q -z3 diff -pu -r CONSTRAINTS_EXPERIMENTS_BRANCHPOINT ChangeLog
Bugs fixed:
unfiled - constraints.c is overly complicated[1]
unfiled - constraints.c is not robust when all constraints
cannot simultaneously be met (constraints need to be
prioritized)
unfiled - keep-titlebar-onscreen constraint is decoration
unaware (since get_outermost_onscreen_positions()
forgets to include decorations)
unfiled - keyboard snap-moving and snap-resizing snap to hidden
edges
109553 - gravity w/ simultaneous move & resize doesn't work
113601 - maximize vertical and horizontal should toggle and be
constrained
122196 - windows show up under vertical panels
122670 - jerky/random resizing of window via keyboard[2]
124582 - keyboard and mouse snap-resizing and snap-moving
erroneously moves the window multidimensionally
136307 - don't allow apps to resize themselves off the screen
(*cough* filechooser *cough*)
142016, 143784 - windows should not span multiple xineramas
unless placed there by the user
143145 - clamp new windows to screensize and force them
onscreen, if they'll fit
144126 - Handle pathological strut lists sanely[3]
149867 - fixed aspect ratio windows are difficult to resize[4]
152898 - make screen edges consistent; allow easy slamming of
windows into the left, right, and bottom edges of the
screen too.
154706 - bouncing weirdness at screen edge with keyboard moving
or resizing
156699 - avoid struts when placing windows, if possible (nasty
a11y blocker)
302456 - dragging offscreen too restrictive
304857 - wireframe moving off the top of the screen is misleading
308521 - make uni-directional resizing easier with
alt-middle-drag and prevent the occasional super
annoying resize-the-wrong-side(s) behavior
312007 - snap-resize moves windows with a minimum size
constraint
312104 - resizing the top of a window can cause the bottom to
grow
319351 - don't instantly snap on mouse-move-snapping, remove
braindeadedness of having order of releasing shift and
releasing button press matter so much
[1] fixed in my opinion, anyway.
[2] Actually, it's not totally fixed--it's just annoying
instead of almost completely unusable. Matthias had a
suggestion that may fix the remainder of the problems (see
http://tinyurl.com/bwzuu).
[3] This bug was originally about not-quite-so-pathological
cases but was left open for the worse cases. The code from
the branch handles the remainder of the cases mentioned in
this bug.
[4] Actually, although it's far better there's still some minor
issues left: a slight drift that's only noticeable after
lots of resizing, and potential problems with partially
onscreen constraints due to not clearing any
fixed_directions flags (aspect ratio windows get resized in
both directions and thus aren't fixed in one of them)
New feature:
81704 - edge resistance for user move and resize operations;
in particular 3 different kinds of resistance are
implemented:
Pixel-Distance: window movement is resisted when it
aligns with an edge unless the movement is greater than
a threshold number of pixels
Timeout: window movement past an edge is prevented until
a certain amount of time has elapsed during the
operation since the first request to move it past that
edge
Keyboard-Buildup: when moving or resizing with the
keyboard, once a window is aligned with a certain edge
it cannot move past until the correct direction has
been pressed enough times (e.g. 2 or 3 times)
Major changes:
- constraints.c has been rewritten; very few lines of code from
the old version remain. There is a comment near the top of
the function explaining the basics of how the new framework
works. A more detailed explanation can be found in
doc/how-constraints-works.txt
- edge-resistance.[ch] are new files implementing edge-resistance.
- boxes.[ch] are new files containing low-level error-prone
functions used heavily in constraints.c and edge-resistance.c,
among various places throughout the code. testboxes.c
contains a thorough testsuite for the boxes.[ch] functions
compiled into a program, testboxes.
- meta_window_move_resize_internal() *must* be told the gravity
of the associated operation (if it's just a move operation,
the gravity will be ignored, but for resize and move+resize
the correct value is needed)
- the craziness of different values that
meta_window_move_resize_internal() accepts has been documented
in a large comment at the beginning of the function. It may
be possible to clean this up some, but until then things will
remain as they were before--caller beware.
- screen and xinerama usable areas (i.e. places not covered by
e.g. panels) are cached in the workspace now, as are the
screen and xinerama edges. These get updated with the
workarea in src/workspace.c:ensure_work_areas_validated()
2005-11-19 14:58:50 +00:00
|
|
|
* Copyright (C) 2005 Elijah Newren
|
2001-06-07 02:42:24 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
|
|
* 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2001-12-09 22:41:12 +00:00
|
|
|
#include <config.h>
|
2002-07-23 20:52:22 +00:00
|
|
|
#include <stdio.h>
|
2002-07-24 18:28:56 +00:00
|
|
|
#include <string.h>
|
2001-06-07 02:42:24 +00:00
|
|
|
#include "menu.h"
|
|
|
|
#include "main.h"
|
2001-06-21 06:08:35 +00:00
|
|
|
#include "util.h"
|
|
|
|
#include "core.h"
|
2002-09-27 01:40:17 +00:00
|
|
|
#include "metaaccellabel.h"
|
2007-05-25 14:36:12 +00:00
|
|
|
#include "ui.h"
|
2001-06-09 06:08:44 +00:00
|
|
|
|
2001-06-07 02:42:24 +00:00
|
|
|
typedef struct _MenuItem MenuItem;
|
|
|
|
typedef struct _MenuData MenuData;
|
|
|
|
|
2006-11-15 13:16:32 +00:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
MENU_ITEM_SEPARATOR = 0,
|
|
|
|
MENU_ITEM_NORMAL,
|
|
|
|
MENU_ITEM_IMAGE,
|
|
|
|
MENU_ITEM_CHECKBOX,
|
2007-04-16 04:48:14 +00:00
|
|
|
MENU_ITEM_RADIOBUTTON,
|
2007-08-02 13:45:46 +00:00
|
|
|
MENU_ITEM_WORKSPACE_LIST,
|
2006-11-15 13:16:32 +00:00
|
|
|
} MetaMenuItemType;
|
|
|
|
|
2001-06-07 02:42:24 +00:00
|
|
|
struct _MenuItem
|
|
|
|
{
|
2001-06-21 03:40:14 +00:00
|
|
|
MetaMenuOp op;
|
2006-11-15 13:16:32 +00:00
|
|
|
MetaMenuItemType type;
|
2001-06-07 02:42:24 +00:00
|
|
|
const char *stock_id;
|
2003-12-21 06:31:40 +00:00
|
|
|
const gboolean checked;
|
2001-06-07 02:42:24 +00:00
|
|
|
const char *label;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct _MenuData
|
|
|
|
{
|
2001-06-23 05:49:35 +00:00
|
|
|
MetaWindowMenu *menu;
|
2001-06-21 06:08:35 +00:00
|
|
|
MetaMenuOp op;
|
2001-06-07 02:42:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static void activate_cb (GtkWidget *menuitem, gpointer data);
|
|
|
|
|
|
|
|
static MenuItem menuitems[] = {
|
2006-09-28 00:32:23 +00:00
|
|
|
/* Translators: Translate this string the same way as you do in libwnck! */
|
2006-11-15 13:16:32 +00:00
|
|
|
{ META_MENU_OP_MINIMIZE, MENU_ITEM_IMAGE, METACITY_STOCK_MINIMIZE, FALSE, N_("Mi_nimize") },
|
2006-09-28 00:32:23 +00:00
|
|
|
/* Translators: Translate this string the same way as you do in libwnck! */
|
2006-11-15 13:16:32 +00:00
|
|
|
{ META_MENU_OP_MAXIMIZE, MENU_ITEM_IMAGE, METACITY_STOCK_MAXIMIZE, FALSE, N_("Ma_ximize") },
|
2006-09-28 00:32:23 +00:00
|
|
|
/* Translators: Translate this string the same way as you do in libwnck! */
|
2006-11-15 13:16:32 +00:00
|
|
|
{ META_MENU_OP_UNMAXIMIZE, MENU_ITEM_NORMAL, NULL, FALSE, N_("Unma_ximize") },
|
2006-09-28 00:32:23 +00:00
|
|
|
/* Translators: Translate this string the same way as you do in libwnck! */
|
2006-11-15 13:16:32 +00:00
|
|
|
{ META_MENU_OP_SHADE, MENU_ITEM_NORMAL, NULL, FALSE, N_("Roll _Up") },
|
2006-09-28 00:32:23 +00:00
|
|
|
/* Translators: Translate this string the same way as you do in libwnck! */
|
2006-11-15 13:16:32 +00:00
|
|
|
{ META_MENU_OP_UNSHADE, MENU_ITEM_NORMAL, NULL, FALSE, N_("_Unroll") },
|
2006-09-28 00:32:23 +00:00
|
|
|
/* Translators: Translate this string the same way as you do in libwnck! */
|
2006-11-15 13:16:32 +00:00
|
|
|
{ META_MENU_OP_MOVE, MENU_ITEM_NORMAL, NULL, FALSE, N_("_Move") },
|
2006-09-28 00:32:23 +00:00
|
|
|
/* Translators: Translate this string the same way as you do in libwnck! */
|
2006-11-15 13:16:32 +00:00
|
|
|
{ META_MENU_OP_RESIZE, MENU_ITEM_NORMAL, NULL, FALSE, N_("_Resize") },
|
2006-09-28 00:32:23 +00:00
|
|
|
/* Translators: Translate this string the same way as you do in libwnck! */
|
2006-11-15 13:16:32 +00:00
|
|
|
{ META_MENU_OP_RECOVER, MENU_ITEM_NORMAL, NULL, FALSE, N_("Move Titlebar On_screen") },
|
|
|
|
{ META_MENU_OP_WORKSPACES, MENU_ITEM_SEPARATOR, NULL, FALSE, NULL }, /* separator */
|
2006-09-28 00:32:23 +00:00
|
|
|
/* Translators: Translate this string the same way as you do in libwnck! */
|
2006-12-27 15:51:49 +00:00
|
|
|
{ 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! */
|
2007-04-16 04:48:14 +00:00
|
|
|
{ META_MENU_OP_UNABOVE, MENU_ITEM_CHECKBOX, NULL, TRUE, N_("Always on _Top") },
|
2006-09-28 00:32:23 +00:00
|
|
|
/* Translators: Translate this string the same way as you do in libwnck! */
|
2007-04-16 04:48:14 +00:00
|
|
|
{ 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") },
|
2006-09-28 00:32:23 +00:00
|
|
|
/* Translators: Translate this string the same way as you do in libwnck! */
|
2006-11-15 13:16:32 +00:00
|
|
|
{ META_MENU_OP_MOVE_LEFT, MENU_ITEM_NORMAL, NULL, FALSE, N_("Move to Workspace _Left") },
|
2006-09-28 00:32:23 +00:00
|
|
|
/* Translators: Translate this string the same way as you do in libwnck! */
|
2006-11-15 13:16:32 +00:00
|
|
|
{ META_MENU_OP_MOVE_RIGHT, MENU_ITEM_NORMAL, NULL, FALSE, N_("Move to Workspace R_ight") },
|
2006-09-28 00:32:23 +00:00
|
|
|
/* Translators: Translate this string the same way as you do in libwnck! */
|
2006-11-15 13:16:32 +00:00
|
|
|
{ META_MENU_OP_MOVE_UP, MENU_ITEM_NORMAL, NULL, FALSE, N_("Move to Workspace _Up") },
|
2006-09-28 00:32:23 +00:00
|
|
|
/* Translators: Translate this string the same way as you do in libwnck! */
|
2007-08-02 13:45:46 +00:00
|
|
|
{ META_MENU_OP_MOVE_DOWN, MENU_ITEM_NORMAL, NULL, FALSE, N_("Move to Workspace _Down") },
|
|
|
|
{ 0, MENU_ITEM_WORKSPACE_LIST, NULL, FALSE, NULL },
|
|
|
|
{ 0, MENU_ITEM_SEPARATOR, NULL, FALSE, NULL }, /* separator */
|
|
|
|
/* Translators: Translate this string the same way as you do in libwnck! */
|
|
|
|
{ META_MENU_OP_DELETE, MENU_ITEM_IMAGE, METACITY_STOCK_DELETE, FALSE, N_("_Close") }
|
2001-06-07 02:42:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
popup_position_func (GtkMenu *menu,
|
|
|
|
gint *x,
|
|
|
|
gint *y,
|
|
|
|
gboolean *push_in,
|
2006-11-15 13:16:32 +00:00
|
|
|
gpointer user_data)
|
2001-06-07 02:42:24 +00:00
|
|
|
{
|
|
|
|
GtkRequisition req;
|
|
|
|
GdkPoint *pos;
|
|
|
|
|
|
|
|
pos = user_data;
|
|
|
|
|
|
|
|
gtk_widget_size_request (GTK_WIDGET (menu), &req);
|
|
|
|
|
|
|
|
*x = pos->x;
|
|
|
|
*y = pos->y;
|
|
|
|
|
2007-05-25 14:36:12 +00:00
|
|
|
if (meta_ui_get_direction() == META_UI_DIRECTION_RTL)
|
|
|
|
*x = MAX (0, *x - req.width);
|
|
|
|
|
2001-06-07 02:42:24 +00:00
|
|
|
/* Ensure onscreen */
|
|
|
|
*x = CLAMP (*x, 0, MAX (0, gdk_screen_width () - req.width));
|
|
|
|
*y = CLAMP (*y, 0, MAX (0, gdk_screen_height () - req.height));
|
|
|
|
}
|
|
|
|
|
2001-06-21 06:08:35 +00:00
|
|
|
static void
|
2001-06-23 05:49:35 +00:00
|
|
|
menu_closed (GtkMenu *widget,
|
2001-06-21 06:08:35 +00:00
|
|
|
gpointer data)
|
|
|
|
{
|
2001-06-23 05:49:35 +00:00
|
|
|
MetaWindowMenu *menu;
|
|
|
|
|
|
|
|
menu = data;
|
2001-06-10 03:17:15 +00:00
|
|
|
|
2001-06-23 05:49:35 +00:00
|
|
|
meta_frames_notify_menu_hide (menu->frames);
|
2010-09-10 07:17:55 +00:00
|
|
|
(* menu->func) (menu,
|
|
|
|
GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
|
2001-06-23 05:49:35 +00:00
|
|
|
menu->client_xwindow,
|
2006-11-15 13:16:32 +00:00
|
|
|
gtk_get_current_event_time (),
|
2001-06-23 05:49:35 +00:00
|
|
|
0, 0,
|
|
|
|
menu->data);
|
|
|
|
|
|
|
|
/* menu may now be freed */
|
2001-06-09 05:14:43 +00:00
|
|
|
}
|
|
|
|
|
2001-06-23 05:49:35 +00:00
|
|
|
static void
|
|
|
|
activate_cb (GtkWidget *menuitem, gpointer data)
|
2001-06-07 02:42:24 +00:00
|
|
|
{
|
2001-06-23 05:49:35 +00:00
|
|
|
MenuData *md;
|
2001-06-07 02:42:24 +00:00
|
|
|
|
2001-06-23 05:49:35 +00:00
|
|
|
g_return_if_fail (GTK_IS_WIDGET (menuitem));
|
2001-06-21 06:08:35 +00:00
|
|
|
|
2001-06-23 05:49:35 +00:00
|
|
|
md = data;
|
2001-06-21 06:08:35 +00:00
|
|
|
|
2001-06-23 05:49:35 +00:00
|
|
|
meta_frames_notify_menu_hide (md->menu->frames);
|
2010-09-10 07:17:55 +00:00
|
|
|
(* md->menu->func) (md->menu,
|
|
|
|
GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
|
2001-06-23 05:49:35 +00:00
|
|
|
md->menu->client_xwindow,
|
2006-11-15 13:16:32 +00:00
|
|
|
gtk_get_current_event_time (),
|
2001-06-23 05:49:35 +00:00
|
|
|
md->op,
|
|
|
|
GPOINTER_TO_INT (g_object_get_data (G_OBJECT (menuitem),
|
|
|
|
"workspace")),
|
|
|
|
md->menu->data);
|
2001-06-07 02:42:24 +00:00
|
|
|
|
2001-06-23 05:49:35 +00:00
|
|
|
/* menu may now be freed */
|
|
|
|
}
|
2001-06-07 02:42:24 +00:00
|
|
|
|
2002-07-23 20:52:22 +00:00
|
|
|
/*
|
|
|
|
* Given a Display and an index, get the workspace name and add any
|
|
|
|
* accelerators. At the moment this means adding a _ if the name is of
|
|
|
|
* the form "Workspace n" where n is less than 10, and escaping any
|
|
|
|
* other '_'s so they do not create inadvertant accelerators.
|
|
|
|
*
|
|
|
|
* The calling code owns the string, and is reponsible to free the
|
|
|
|
* memory after use.
|
2008-03-21 02:56:52 +00:00
|
|
|
*
|
|
|
|
* See also http://mail.gnome.org/archives/gnome-i18n/2008-March/msg00380.html
|
|
|
|
* which discusses possible i18n concerns.
|
2002-07-23 20:52:22 +00:00
|
|
|
*/
|
2002-11-20 04:54:01 +00:00
|
|
|
static char*
|
2002-07-23 20:52:22 +00:00
|
|
|
get_workspace_name_with_accel (Display *display,
|
2002-10-16 20:12:24 +00:00
|
|
|
Window xroot,
|
|
|
|
int index)
|
2002-07-23 20:52:22 +00:00
|
|
|
{
|
2002-11-03 19:06:39 +00:00
|
|
|
const char *name;
|
|
|
|
int number;
|
2008-03-21 02:56:52 +00:00
|
|
|
int charcount=0;
|
2002-07-23 20:52:22 +00:00
|
|
|
|
2002-10-16 20:12:24 +00:00
|
|
|
name = meta_core_get_workspace_name_with_index (display, xroot, index);
|
2002-07-23 20:52:22 +00:00
|
|
|
|
2002-11-20 03:57:20 +00:00
|
|
|
g_assert (name != NULL);
|
|
|
|
|
2002-07-23 20:52:22 +00:00
|
|
|
/*
|
|
|
|
* If the name is of the form "Workspace x" where x is an unsigned
|
|
|
|
* integer, insert a '_' before the number if it is less than 10 and
|
|
|
|
* return it
|
|
|
|
*/
|
2002-11-20 04:54:01 +00:00
|
|
|
number = 0;
|
2008-03-21 02:56:52 +00:00
|
|
|
if (sscanf (name, _("Workspace %d%n"), &number, &charcount) != 0 &&
|
|
|
|
*(name + charcount)=='\0')
|
2002-07-23 20:52:22 +00:00
|
|
|
{
|
2002-11-03 19:06:39 +00:00
|
|
|
char *new_name;
|
|
|
|
|
2002-07-23 20:52:22 +00:00
|
|
|
/*
|
|
|
|
* Above name is a pointer into the Workspace struct. Here we make
|
|
|
|
* a copy copy so we can have our wicked way with it.
|
|
|
|
*/
|
2003-12-21 06:31:40 +00:00
|
|
|
if (number == 10)
|
|
|
|
new_name = g_strdup_printf (_("Workspace 1_0"));
|
|
|
|
else
|
|
|
|
new_name = g_strdup_printf (_("Workspace %s%d"),
|
|
|
|
number < 10 ? "_" : "",
|
|
|
|
number);
|
2002-11-03 19:06:39 +00:00
|
|
|
return new_name;
|
2002-07-23 20:52:22 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/*
|
2003-12-21 06:31:40 +00:00
|
|
|
* Otherwise this is just a normal name. Escape any _ characters so that
|
|
|
|
* the user's workspace names do not get mangled. If the number is less
|
|
|
|
* than 10 we provide an accelerator.
|
2002-07-23 20:52:22 +00:00
|
|
|
*/
|
2002-11-03 19:06:39 +00:00
|
|
|
char *new_name;
|
|
|
|
const char *source;
|
|
|
|
char *dest;
|
2002-11-20 04:54:01 +00:00
|
|
|
|
2002-07-23 20:52:22 +00:00
|
|
|
/*
|
2003-12-21 06:31:40 +00:00
|
|
|
* Assume the worst case, that every character is a _. We also
|
|
|
|
* provide memory for " (_#)"
|
2002-07-23 20:52:22 +00:00
|
|
|
*/
|
2003-12-21 06:31:40 +00:00
|
|
|
new_name = g_malloc0 (strlen (name) * 2 + 6 + 1);
|
2002-11-20 04:54:01 +00:00
|
|
|
|
2002-07-23 20:52:22 +00:00
|
|
|
/*
|
|
|
|
* Now iterate down the strings, adding '_' to escape as we go
|
|
|
|
*/
|
2002-11-20 04:54:01 +00:00
|
|
|
dest = new_name;
|
|
|
|
source = name;
|
2002-07-23 20:52:22 +00:00
|
|
|
while (*source != '\0')
|
|
|
|
{
|
|
|
|
if (*source == '_')
|
|
|
|
*dest++ = '_';
|
|
|
|
*dest++ = *source++;
|
|
|
|
}
|
2002-11-20 04:54:01 +00:00
|
|
|
|
2008-03-21 02:56:52 +00:00
|
|
|
/* People don't start at workspace 0, but workspace 1 */
|
2003-12-21 06:31:40 +00:00
|
|
|
if (index < 9)
|
|
|
|
{
|
|
|
|
g_snprintf (dest, 6, " (_%d)", index + 1);
|
|
|
|
}
|
|
|
|
else if (index == 9)
|
|
|
|
{
|
|
|
|
g_snprintf (dest, 6, " (_0)");
|
|
|
|
}
|
|
|
|
|
2002-07-23 20:52:22 +00:00
|
|
|
return new_name;
|
2002-11-20 03:57:20 +00:00
|
|
|
}
|
2002-07-23 20:52:22 +00:00
|
|
|
}
|
2002-02-07 03:07:56 +00:00
|
|
|
|
2006-11-15 13:16:32 +00:00
|
|
|
static GtkWidget *
|
|
|
|
menu_item_new (MenuItem *menuitem, int workspace_id)
|
2002-09-27 01:40:17 +00:00
|
|
|
{
|
2006-11-15 13:16:32 +00:00
|
|
|
unsigned int key;
|
|
|
|
MetaVirtualModifier mods;
|
|
|
|
const char *i18n_label;
|
|
|
|
GtkWidget *mi;
|
2002-09-27 01:40:17 +00:00
|
|
|
GtkWidget *accel_label;
|
|
|
|
|
2006-11-15 13:16:32 +00:00
|
|
|
if (menuitem->type == MENU_ITEM_NORMAL)
|
|
|
|
{
|
|
|
|
mi = gtk_menu_item_new ();
|
|
|
|
}
|
|
|
|
else if (menuitem->type == MENU_ITEM_IMAGE)
|
2003-12-21 06:31:40 +00:00
|
|
|
{
|
2006-11-15 13:16:32 +00:00
|
|
|
GtkWidget *image;
|
|
|
|
|
|
|
|
image = gtk_image_new_from_stock (menuitem->stock_id, GTK_ICON_SIZE_MENU);
|
|
|
|
mi = gtk_image_menu_item_new ();
|
|
|
|
|
|
|
|
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (mi), image);
|
|
|
|
gtk_widget_show (image);
|
2003-12-21 06:31:40 +00:00
|
|
|
}
|
2006-11-15 13:16:32 +00:00
|
|
|
else if (menuitem->type == MENU_ITEM_CHECKBOX)
|
|
|
|
{
|
|
|
|
mi = gtk_check_menu_item_new ();
|
|
|
|
|
2007-04-16 04:48:14 +00:00
|
|
|
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (mi),
|
|
|
|
menuitem->checked);
|
2006-11-15 13:16:32 +00:00
|
|
|
}
|
2007-04-16 04:48:14 +00:00
|
|
|
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);
|
|
|
|
}
|
2007-08-02 13:45:46 +00:00
|
|
|
else if (menuitem->type == MENU_ITEM_WORKSPACE_LIST)
|
|
|
|
return NULL;
|
2002-09-27 01:40:17 +00:00
|
|
|
else
|
2006-11-15 13:16:32 +00:00
|
|
|
return gtk_separator_menu_item_new ();
|
|
|
|
|
|
|
|
i18n_label = _(menuitem->label);
|
|
|
|
meta_core_get_menu_accelerator (menuitem->op, workspace_id, &key, &mods);
|
|
|
|
|
|
|
|
accel_label = meta_accel_label_new_with_mnemonic (i18n_label);
|
2002-09-27 01:40:17 +00:00
|
|
|
gtk_misc_set_alignment (GTK_MISC (accel_label), 0.0, 0.5);
|
|
|
|
|
2006-11-15 13:16:32 +00:00
|
|
|
gtk_container_add (GTK_CONTAINER (mi), accel_label);
|
2002-09-27 01:40:17 +00:00
|
|
|
gtk_widget_show (accel_label);
|
|
|
|
|
|
|
|
meta_accel_label_set_accelerator (META_ACCEL_LABEL (accel_label),
|
|
|
|
key, mods);
|
|
|
|
|
2006-11-15 13:16:32 +00:00
|
|
|
return mi;
|
2002-09-27 01:40:17 +00:00
|
|
|
}
|
|
|
|
|
2001-06-23 05:49:35 +00:00
|
|
|
MetaWindowMenu*
|
|
|
|
meta_window_menu_new (MetaFrames *frames,
|
|
|
|
MetaMenuOp ops,
|
|
|
|
MetaMenuOp insensitive,
|
|
|
|
Window client_xwindow,
|
2007-04-16 04:48:14 +00:00
|
|
|
unsigned long active_workspace,
|
2001-06-23 05:49:35 +00:00
|
|
|
int n_workspaces,
|
|
|
|
MetaWindowMenuFunc func,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
MetaWindowMenu *menu;
|
|
|
|
|
2007-04-16 04:48:14 +00:00
|
|
|
/* FIXME: Modifications to 'ops' should happen in meta_window_show_menu */
|
2003-10-30 21:11:11 +00:00
|
|
|
if (n_workspaces < 2)
|
|
|
|
ops &= ~(META_MENU_OP_STICK | META_MENU_OP_UNSTICK | META_MENU_OP_WORKSPACES);
|
2006-02-20 02:15:14 +00:00
|
|
|
else if (n_workspaces == 2)
|
|
|
|
/* #151183: If we only have two workspaces, disable the menu listing them. */
|
|
|
|
ops &= ~(META_MENU_OP_WORKSPACES);
|
2003-10-30 21:11:11 +00:00
|
|
|
|
2001-06-23 05:49:35 +00:00
|
|
|
menu = g_new (MetaWindowMenu, 1);
|
|
|
|
menu->frames = frames;
|
|
|
|
menu->client_xwindow = client_xwindow;
|
|
|
|
menu->func = func;
|
|
|
|
menu->data = data;
|
|
|
|
menu->ops = ops;
|
2003-10-30 21:11:11 +00:00
|
|
|
menu->insensitive = insensitive;
|
2001-06-21 06:08:35 +00:00
|
|
|
|
2001-06-23 05:49:35 +00:00
|
|
|
menu->menu = gtk_menu_new ();
|
2003-04-21 23:37:42 +00:00
|
|
|
|
2002-05-08 16:24:28 +00:00
|
|
|
gtk_menu_set_screen (GTK_MENU (menu->menu),
|
2006-11-15 13:16:32 +00:00
|
|
|
gtk_widget_get_screen (GTK_WIDGET (frames)));
|
2003-04-21 23:37:42 +00:00
|
|
|
|
2006-11-15 13:16:32 +00:00
|
|
|
for (i = 0; i < (int) G_N_ELEMENTS (menuitems); i++)
|
2001-06-07 02:42:24 +00:00
|
|
|
{
|
2006-11-15 13:16:32 +00:00
|
|
|
MenuItem menuitem = menuitems[i];
|
|
|
|
if (ops & menuitem.op || menuitem.op == 0)
|
2001-06-07 02:42:24 +00:00
|
|
|
{
|
|
|
|
GtkWidget *mi;
|
|
|
|
MenuData *md;
|
2002-09-27 01:40:17 +00:00
|
|
|
unsigned int key;
|
|
|
|
MetaVirtualModifier mods;
|
2001-06-21 06:08:35 +00:00
|
|
|
|
2006-11-15 13:16:32 +00:00
|
|
|
mi = menu_item_new (&menuitem, -1);
|
2001-06-21 06:08:35 +00:00
|
|
|
|
2007-04-16 04:48:14 +00:00
|
|
|
/* Set the activeness of radiobuttons. */
|
|
|
|
switch (menuitem.op)
|
2006-11-15 13:16:32 +00:00
|
|
|
{
|
2007-04-16 04:48:14 +00:00
|
|
|
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;
|
2006-11-15 13:16:32 +00:00
|
|
|
}
|
2006-12-27 15:51:49 +00:00
|
|
|
|
2007-08-02 13:45:46 +00:00
|
|
|
if (menuitem.type == MENU_ITEM_WORKSPACE_LIST)
|
|
|
|
{
|
|
|
|
if (ops & META_MENU_OP_WORKSPACES)
|
|
|
|
{
|
|
|
|
Display *display;
|
|
|
|
Window xroot;
|
|
|
|
GdkScreen *screen;
|
2010-04-11 18:30:44 +00:00
|
|
|
GdkWindow *window;
|
2007-08-02 13:45:46 +00:00
|
|
|
GtkWidget *submenu;
|
|
|
|
int j;
|
|
|
|
|
|
|
|
MenuItem to_another_workspace = {
|
|
|
|
0, MENU_ITEM_NORMAL,
|
|
|
|
NULL, FALSE,
|
|
|
|
N_("Move to Another _Workspace")
|
|
|
|
};
|
|
|
|
|
|
|
|
meta_verbose ("Creating %d-workspace menu current space %lu\n",
|
|
|
|
n_workspaces, active_workspace);
|
|
|
|
|
2010-04-11 18:30:44 +00:00
|
|
|
window = gtk_widget_get_window (GTK_WIDGET (frames));
|
2010-12-02 14:51:36 +00:00
|
|
|
display = GDK_WINDOW_XDISPLAY (window);
|
2007-08-02 13:45:46 +00:00
|
|
|
|
2010-09-24 11:30:40 +00:00
|
|
|
screen = gdk_window_get_screen (window);
|
2010-12-02 14:51:36 +00:00
|
|
|
xroot = GDK_WINDOW_XID (gdk_screen_get_root_window (screen));
|
2007-08-02 13:45:46 +00:00
|
|
|
|
|
|
|
submenu = gtk_menu_new ();
|
|
|
|
|
|
|
|
g_assert (mi==NULL);
|
|
|
|
mi = menu_item_new (&to_another_workspace, -1);
|
|
|
|
gtk_menu_item_set_submenu (GTK_MENU_ITEM (mi), submenu);
|
|
|
|
|
|
|
|
for (j = 0; j < n_workspaces; j++)
|
|
|
|
{
|
|
|
|
char *label;
|
|
|
|
MenuData *md;
|
|
|
|
unsigned int key;
|
|
|
|
MetaVirtualModifier mods;
|
|
|
|
MenuItem moveitem;
|
|
|
|
GtkWidget *submi;
|
|
|
|
|
|
|
|
meta_core_get_menu_accelerator (META_MENU_OP_WORKSPACES,
|
|
|
|
j + 1,
|
|
|
|
&key, &mods);
|
|
|
|
|
|
|
|
label = get_workspace_name_with_accel (display, xroot, j);
|
|
|
|
|
|
|
|
moveitem.type = MENU_ITEM_NORMAL;
|
|
|
|
moveitem.op = META_MENU_OP_WORKSPACES;
|
|
|
|
moveitem.label = label;
|
|
|
|
submi = menu_item_new (&moveitem, j + 1);
|
|
|
|
|
|
|
|
g_free (label);
|
|
|
|
|
|
|
|
if ((active_workspace == (unsigned)j) && (ops & META_MENU_OP_UNSTICK))
|
|
|
|
gtk_widget_set_sensitive (submi, FALSE);
|
|
|
|
|
|
|
|
md = g_new (MenuData, 1);
|
|
|
|
|
|
|
|
md->menu = menu;
|
|
|
|
md->op = META_MENU_OP_WORKSPACES;
|
|
|
|
|
|
|
|
g_object_set_data (G_OBJECT (submi),
|
|
|
|
"workspace",
|
|
|
|
GINT_TO_POINTER (j));
|
|
|
|
|
2010-09-27 17:47:54 +00:00
|
|
|
g_signal_connect_data (G_OBJECT (submi),
|
2007-08-02 13:45:46 +00:00
|
|
|
"activate",
|
2009-08-04 08:17:20 +00:00
|
|
|
G_CALLBACK (activate_cb),
|
2007-08-02 13:45:46 +00:00
|
|
|
md,
|
2010-06-26 15:09:30 +00:00
|
|
|
(GClosureNotify) g_free, 0);
|
2007-08-02 13:45:46 +00:00
|
|
|
|
|
|
|
gtk_menu_shell_append (GTK_MENU_SHELL (submenu), submi);
|
|
|
|
|
|
|
|
gtk_widget_show (submi);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
meta_verbose ("not creating workspace menu\n");
|
|
|
|
}
|
|
|
|
else if (menuitem.type != MENU_ITEM_SEPARATOR)
|
2006-11-15 13:16:32 +00:00
|
|
|
{
|
2002-09-27 01:40:17 +00:00
|
|
|
meta_core_get_menu_accelerator (menuitems[i].op, -1,
|
|
|
|
&key, &mods);
|
2003-12-21 06:31:40 +00:00
|
|
|
|
2006-11-15 13:16:32 +00:00
|
|
|
if (insensitive & menuitem.op)
|
2001-06-10 03:17:15 +00:00
|
|
|
gtk_widget_set_sensitive (mi, FALSE);
|
|
|
|
|
|
|
|
md = g_new (MenuData, 1);
|
|
|
|
|
2001-06-23 05:49:35 +00:00
|
|
|
md->menu = menu;
|
2006-11-15 13:16:32 +00:00
|
|
|
md->op = menuitem.op;
|
2001-06-10 03:17:15 +00:00
|
|
|
|
2010-09-27 17:47:54 +00:00
|
|
|
g_signal_connect_data (G_OBJECT (mi),
|
2010-06-26 15:09:30 +00:00
|
|
|
"activate",
|
|
|
|
G_CALLBACK (activate_cb),
|
|
|
|
md,
|
|
|
|
(GClosureNotify) g_free, 0);
|
2001-06-07 02:42:24 +00:00
|
|
|
}
|
2003-10-30 21:11:11 +00:00
|
|
|
|
2007-12-09 23:03:45 +00:00
|
|
|
if (mi)
|
|
|
|
{
|
|
|
|
gtk_menu_shell_append (GTK_MENU_SHELL (menu->menu), mi);
|
2001-06-09 05:14:43 +00:00
|
|
|
|
2007-12-09 23:03:45 +00:00
|
|
|
gtk_widget_show (mi);
|
|
|
|
}
|
2001-06-09 05:14:43 +00:00
|
|
|
}
|
|
|
|
}
|
2007-08-02 13:45:46 +00:00
|
|
|
|
|
|
|
|
A load of fixes of issues reported by sparse. Closes bug #152849
2004-09-17 Kjartan Maraas <kmaraas@gnome.org>
* src/bell.c: (meta_bell_flash_screen):
* src/compositor.c:
* src/effects.c: (meta_effects_draw_box_animation):
* src/fixedtip.c: (meta_fixed_tip_show):
* src/frame.c: (find_argb_visual):
* src/frames.c: (unsigned_long_hash), (meta_frames_manage_window),
(meta_frames_apply_shapes):
* src/iconcache.c: (find_largest_sizes), (find_best_size):
* src/keybindings.c: (meta_spawn_command_line_async_on_screen):
* src/main.c: (main):
* src/menu.c: (meta_window_menu_new):
* src/prefs.c: (meta_prefs_get_visual_bell),
(meta_prefs_bell_is_audible), (meta_prefs_get_visual_bell_type),
(meta_prefs_get_action_double_click_titlebar),
(meta_prefs_get_auto_raise), (meta_prefs_get_auto_raise_delay),
(meta_prefs_get_reduced_resources):
* src/screen.c: (meta_create_offscreen_window):
* src/tabpopup.c: (meta_ui_tab_popup_get_selected):
* src/theme-parser.c: (meta_theme_load):
* src/theme.c: (meta_gtk_widget_get_font_desc):
* src/tools/metacity-mag.c: (mouse_press), (begin_area_grab):
* src/util.c: (meta_unsigned_long_hash): A load of fixes of issues
reported by sparse. Closes bug #152849
2004-09-16 23:18:22 +00:00
|
|
|
g_signal_connect (menu->menu, "selection_done",
|
|
|
|
G_CALLBACK (menu_closed), menu);
|
2001-06-23 05:49:35 +00:00
|
|
|
|
|
|
|
return menu;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_window_menu_popup (MetaWindowMenu *menu,
|
|
|
|
int root_x,
|
|
|
|
int root_y,
|
|
|
|
int button,
|
|
|
|
guint32 timestamp)
|
|
|
|
{
|
|
|
|
GdkPoint *pt;
|
2001-06-07 02:42:24 +00:00
|
|
|
|
|
|
|
pt = g_new (GdkPoint, 1);
|
|
|
|
|
2001-06-23 05:49:35 +00:00
|
|
|
g_object_set_data_full (G_OBJECT (menu->menu),
|
2001-06-07 02:42:24 +00:00
|
|
|
"destroy-point",
|
|
|
|
pt,
|
|
|
|
g_free);
|
|
|
|
|
|
|
|
pt->x = root_x;
|
|
|
|
pt->y = root_y;
|
|
|
|
|
2001-06-23 05:49:35 +00:00
|
|
|
gtk_menu_popup (GTK_MENU (menu->menu),
|
2001-06-07 02:42:24 +00:00
|
|
|
NULL, NULL,
|
|
|
|
popup_position_func, pt,
|
|
|
|
button,
|
|
|
|
timestamp);
|
|
|
|
|
2010-05-10 21:40:06 +00:00
|
|
|
if (!gtk_widget_get_visible (menu->menu))
|
2001-06-21 06:08:35 +00:00
|
|
|
meta_warning ("GtkMenu failed to grab the pointer\n");
|
2001-06-09 05:14:43 +00:00
|
|
|
}
|
|
|
|
|
2001-06-23 05:49:35 +00:00
|
|
|
void
|
|
|
|
meta_window_menu_free (MetaWindowMenu *menu)
|
2001-06-07 02:42:24 +00:00
|
|
|
{
|
2001-06-23 05:49:35 +00:00
|
|
|
gtk_widget_destroy (menu->menu);
|
|
|
|
g_free (menu);
|
2001-06-07 02:42:24 +00:00
|
|
|
}
|