2001-08-19 02:23:59 -04:00
|
|
|
/* Metacity popup window thing showing windows you can tab to */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (C) 2001 Havoc Pennington
|
2002-10-17 12:04:53 -04:00
|
|
|
* Copyright (C) 2002 Red Hat, Inc.
|
2005-10-08 15:38:54 -04:00
|
|
|
* Copyright (C) 2005 Elijah Newren
|
2001-08-19 02:23:59 -04: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.
|
|
|
|
*/
|
|
|
|
|
2002-05-11 02:59:54 -04:00
|
|
|
#include <config.h>
|
|
|
|
|
2001-08-19 02:23:59 -04:00
|
|
|
#include "util.h"
|
2001-08-30 00:01:38 -04:00
|
|
|
#include "core.h"
|
|
|
|
#include "tabpopup.h"
|
2002-07-06 15:05:37 -04:00
|
|
|
#include "workspace.h" /* FIXME should not be included in this file */
|
|
|
|
#include "draw-workspace.h"
|
|
|
|
#include "frame.h"
|
2001-08-19 02:23:59 -04:00
|
|
|
#include <gtk/gtk.h>
|
2002-02-06 22:07:56 -05:00
|
|
|
#include <math.h>
|
2001-08-19 02:23:59 -04:00
|
|
|
|
2001-08-22 23:24:51 -04:00
|
|
|
#define OUTSIDE_SELECT_RECT 2
|
|
|
|
#define INSIDE_SELECT_RECT 2
|
|
|
|
|
2001-08-19 02:23:59 -04:00
|
|
|
typedef struct _TabEntry TabEntry;
|
|
|
|
|
|
|
|
struct _TabEntry
|
|
|
|
{
|
2002-06-08 23:44:16 -04:00
|
|
|
MetaTabEntryKey key;
|
|
|
|
char *title;
|
2005-01-18 11:48:53 -05:00
|
|
|
GdkPixbuf *icon, *dimmed_icon;
|
2002-06-08 23:44:16 -04:00
|
|
|
GtkWidget *widget;
|
|
|
|
GdkRectangle rect;
|
|
|
|
GdkRectangle inner_rect;
|
2003-01-05 13:36:01 -05:00
|
|
|
guint blank : 1;
|
2001-08-19 02:23:59 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
struct _MetaTabPopup
|
|
|
|
{
|
|
|
|
GtkWidget *window;
|
|
|
|
GtkWidget *label;
|
|
|
|
GList *current;
|
|
|
|
GList *entries;
|
2001-08-29 01:07:39 -04:00
|
|
|
TabEntry *current_selected_entry;
|
2001-08-29 00:53:48 -04:00
|
|
|
GtkWidget *outline_window;
|
2002-06-08 23:44:16 -04:00
|
|
|
gboolean outline;
|
2001-08-19 02:23:59 -04:00
|
|
|
};
|
|
|
|
|
2001-08-22 23:24:51 -04:00
|
|
|
static GtkWidget* selectable_image_new (GdkPixbuf *pixbuf);
|
|
|
|
static void select_image (GtkWidget *widget);
|
|
|
|
static void unselect_image (GtkWidget *widget);
|
|
|
|
|
2002-07-06 15:05:37 -04:00
|
|
|
static GtkWidget* selectable_workspace_new (MetaWorkspace *workspace);
|
|
|
|
static void select_workspace (GtkWidget *widget);
|
|
|
|
static void unselect_workspace (GtkWidget *widget);
|
|
|
|
|
2001-08-29 01:07:39 -04:00
|
|
|
static gboolean
|
|
|
|
outline_window_expose (GtkWidget *widget,
|
|
|
|
GdkEventExpose *event,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
MetaTabPopup *popup;
|
2001-08-30 00:01:38 -04:00
|
|
|
TabEntry *te;
|
2001-08-29 01:07:39 -04:00
|
|
|
|
|
|
|
popup = data;
|
|
|
|
|
2002-06-08 23:44:16 -04:00
|
|
|
if (!popup->outline || popup->current_selected_entry == NULL)
|
2001-08-29 01:07:39 -04:00
|
|
|
return FALSE;
|
2001-08-30 00:01:38 -04:00
|
|
|
|
|
|
|
te = popup->current_selected_entry;
|
2001-08-29 01:07:39 -04:00
|
|
|
|
|
|
|
gdk_draw_rectangle (widget->window,
|
|
|
|
widget->style->white_gc,
|
2001-08-30 00:01:38 -04:00
|
|
|
FALSE,
|
|
|
|
0, 0,
|
|
|
|
te->rect.width - 1,
|
|
|
|
te->rect.height - 1);
|
2001-08-29 01:07:39 -04:00
|
|
|
|
2001-08-30 00:01:38 -04:00
|
|
|
gdk_draw_rectangle (widget->window,
|
|
|
|
widget->style->white_gc,
|
|
|
|
FALSE,
|
|
|
|
te->inner_rect.x - 1, te->inner_rect.y - 1,
|
|
|
|
te->inner_rect.width + 1,
|
2002-06-08 23:44:16 -04:00
|
|
|
te->inner_rect.height + 1);
|
|
|
|
|
2001-08-29 01:07:39 -04:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2005-01-18 11:48:53 -05:00
|
|
|
static GdkPixbuf*
|
|
|
|
dimm_icon (GdkPixbuf *pixbuf)
|
|
|
|
{
|
|
|
|
int x, y, pixel_stride, row_stride;
|
|
|
|
guchar *row, *pixels;
|
|
|
|
int w, h;
|
|
|
|
GdkPixbuf *dimmed_pixbuf;
|
|
|
|
|
2005-01-20 20:58:10 -05:00
|
|
|
if (gdk_pixbuf_get_has_alpha (pixbuf))
|
2005-01-18 11:48:53 -05:00
|
|
|
{
|
|
|
|
dimmed_pixbuf = gdk_pixbuf_copy (pixbuf);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dimmed_pixbuf = gdk_pixbuf_add_alpha (pixbuf, FALSE, 0, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
w = gdk_pixbuf_get_width (dimmed_pixbuf);
|
|
|
|
h = gdk_pixbuf_get_height (dimmed_pixbuf);
|
|
|
|
|
|
|
|
pixel_stride = 4;
|
|
|
|
|
|
|
|
row = gdk_pixbuf_get_pixels (dimmed_pixbuf);
|
|
|
|
row_stride = gdk_pixbuf_get_rowstride (dimmed_pixbuf);
|
|
|
|
|
|
|
|
for (y = 0; y < h; y++)
|
|
|
|
{
|
|
|
|
pixels = row;
|
|
|
|
for (x = 0; x < w; x++)
|
|
|
|
{
|
|
|
|
pixels[3] /= 2;
|
|
|
|
pixels += pixel_stride;
|
|
|
|
}
|
|
|
|
row += row_stride;
|
|
|
|
}
|
|
|
|
return dimmed_pixbuf;
|
|
|
|
}
|
|
|
|
|
2001-08-19 02:23:59 -04:00
|
|
|
MetaTabPopup*
|
2002-05-11 02:59:54 -04:00
|
|
|
meta_ui_tab_popup_new (const MetaTabEntry *entries,
|
2002-06-08 23:44:16 -04:00
|
|
|
int screen_number,
|
|
|
|
int entry_count,
|
|
|
|
int width,
|
|
|
|
gboolean outline)
|
2001-08-19 02:23:59 -04:00
|
|
|
{
|
|
|
|
MetaTabPopup *popup;
|
|
|
|
int i, left, right, top, bottom;
|
|
|
|
GList *tab_entries;
|
|
|
|
int height;
|
|
|
|
GtkWidget *table;
|
2001-08-30 00:01:38 -04:00
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *align;
|
2001-08-19 02:23:59 -04:00
|
|
|
GList *tmp;
|
2001-08-19 14:09:10 -04:00
|
|
|
GtkWidget *frame;
|
2003-09-29 19:42:45 -04:00
|
|
|
int max_label_width; /* the actual max width of the labels we create */
|
2003-09-26 13:04:37 -04:00
|
|
|
AtkObject *obj;
|
2003-09-29 19:42:45 -04:00
|
|
|
int max_chars_per_title; /* max chars we allow in a label */
|
|
|
|
GdkScreen *screen;
|
|
|
|
|
2001-08-19 02:23:59 -04:00
|
|
|
popup = g_new (MetaTabPopup, 1);
|
2001-08-29 00:53:48 -04:00
|
|
|
|
|
|
|
popup->outline_window = gtk_window_new (GTK_WINDOW_POPUP);
|
2003-04-21 19:37:42 -04:00
|
|
|
|
2002-05-11 02:59:54 -04:00
|
|
|
gtk_window_set_screen (GTK_WINDOW (popup->outline_window),
|
2002-06-25 03:08:18 -04:00
|
|
|
gdk_display_get_screen (gdk_display_get_default (),
|
2002-05-11 02:59:54 -04:00
|
|
|
screen_number));
|
|
|
|
|
2001-08-29 00:53:48 -04:00
|
|
|
gtk_widget_set_app_paintable (popup->outline_window, TRUE);
|
|
|
|
gtk_widget_realize (popup->outline_window);
|
2001-08-30 00:01:38 -04:00
|
|
|
|
2001-08-29 01:07:39 -04:00
|
|
|
g_signal_connect (G_OBJECT (popup->outline_window), "expose_event",
|
|
|
|
G_CALLBACK (outline_window_expose), popup);
|
2001-08-29 00:53:48 -04:00
|
|
|
|
2001-08-19 02:23:59 -04:00
|
|
|
popup->window = gtk_window_new (GTK_WINDOW_POPUP);
|
2003-04-21 19:37:42 -04:00
|
|
|
|
2003-09-29 19:42:45 -04:00
|
|
|
screen = gdk_display_get_screen (gdk_display_get_default (),
|
|
|
|
screen_number);
|
|
|
|
|
2002-05-11 02:59:54 -04:00
|
|
|
gtk_window_set_screen (GTK_WINDOW (popup->window),
|
2003-09-29 19:42:45 -04:00
|
|
|
screen);
|
2002-05-11 02:59:54 -04:00
|
|
|
|
2001-08-19 14:09:10 -04:00
|
|
|
gtk_window_set_position (GTK_WINDOW (popup->window),
|
|
|
|
GTK_WIN_POS_CENTER_ALWAYS);
|
|
|
|
/* enable resizing, to get never-shrink behavior */
|
|
|
|
gtk_window_set_resizable (GTK_WINDOW (popup->window),
|
|
|
|
TRUE);
|
2001-08-19 02:23:59 -04:00
|
|
|
popup->current = NULL;
|
|
|
|
popup->entries = NULL;
|
2001-08-29 01:07:39 -04:00
|
|
|
popup->current_selected_entry = NULL;
|
2002-06-08 23:44:16 -04:00
|
|
|
popup->outline = outline;
|
2003-09-29 19:42:45 -04:00
|
|
|
|
|
|
|
/* make max title size some random relationship to the screen,
|
|
|
|
* avg char width of our font would be a better number.
|
|
|
|
*/
|
|
|
|
max_chars_per_title = gdk_screen_get_width (screen) / 15;
|
2005-01-18 11:48:53 -05:00
|
|
|
|
2001-08-19 02:23:59 -04:00
|
|
|
tab_entries = NULL;
|
2002-06-08 23:44:16 -04:00
|
|
|
for (i = 0; i < entry_count; ++i)
|
2001-08-19 02:23:59 -04:00
|
|
|
{
|
|
|
|
TabEntry *te;
|
|
|
|
|
|
|
|
te = g_new (TabEntry, 1);
|
2002-06-08 23:44:16 -04:00
|
|
|
te->key = entries[i].key;
|
2005-01-18 11:48:53 -05:00
|
|
|
te->title = NULL;
|
|
|
|
if (entries[i].title)
|
|
|
|
{
|
2005-01-20 11:41:29 -05:00
|
|
|
gchar *tmp;
|
2005-11-11 19:34:32 -05:00
|
|
|
if (entries[i].hidden)
|
2005-01-18 11:48:53 -05:00
|
|
|
{
|
2005-12-27 11:40:47 -05:00
|
|
|
tmp = g_markup_printf_escaped ("[%s]", entries[i].title);
|
2005-01-18 11:48:53 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-12-27 11:40:47 -05:00
|
|
|
tmp = g_markup_printf_escaped ("%s", entries[i].title);
|
2005-01-20 11:41:29 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (entries[i].demands_attention)
|
|
|
|
{
|
|
|
|
gchar *escaped, *markup;
|
|
|
|
escaped = g_markup_escape_text (tmp, -1);
|
|
|
|
markup = g_strdup_printf ("<b>%s</b>", escaped);
|
|
|
|
g_free (escaped);
|
|
|
|
g_free (tmp);
|
|
|
|
tmp = markup;
|
2005-01-18 11:48:53 -05:00
|
|
|
}
|
2005-01-20 11:41:29 -05:00
|
|
|
|
2005-10-03 14:13:45 -04:00
|
|
|
te->title = meta_g_utf8_strndup (tmp, max_chars_per_title);
|
2005-01-20 11:41:29 -05:00
|
|
|
g_free (tmp);
|
2005-01-18 11:48:53 -05:00
|
|
|
}
|
2001-08-19 02:23:59 -04:00
|
|
|
te->widget = NULL;
|
2002-07-06 15:05:37 -04:00
|
|
|
te->icon = entries[i].icon;
|
2003-01-05 13:36:01 -05:00
|
|
|
te->blank = entries[i].blank;
|
2005-01-18 11:48:53 -05:00
|
|
|
te->dimmed_icon = NULL;
|
2002-07-06 15:05:37 -04:00
|
|
|
if (te->icon)
|
2005-01-18 11:48:53 -05:00
|
|
|
{
|
|
|
|
g_object_ref (G_OBJECT (te->icon));
|
2005-11-11 19:34:32 -05:00
|
|
|
if (entries[i].hidden)
|
2005-01-18 11:48:53 -05:00
|
|
|
te->dimmed_icon = dimm_icon (entries[i].icon);
|
|
|
|
}
|
2001-08-19 02:23:59 -04:00
|
|
|
|
2002-06-08 23:44:16 -04:00
|
|
|
if (outline)
|
|
|
|
{
|
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 09:58:50 -05:00
|
|
|
te->rect.x = entries[i].rect.x;
|
|
|
|
te->rect.y = entries[i].rect.y;
|
|
|
|
te->rect.width = entries[i].rect.width;
|
|
|
|
te->rect.height = entries[i].rect.height;
|
|
|
|
|
|
|
|
te->inner_rect.x = entries[i].inner_rect.x;
|
|
|
|
te->inner_rect.y = entries[i].inner_rect.y;
|
|
|
|
te->inner_rect.width = entries[i].inner_rect.width;
|
|
|
|
te->inner_rect.height = entries[i].inner_rect.height;
|
2002-06-08 23:44:16 -04:00
|
|
|
}
|
2001-08-30 00:01:38 -04:00
|
|
|
|
2001-08-19 02:23:59 -04:00
|
|
|
tab_entries = g_list_prepend (tab_entries, te);
|
|
|
|
}
|
|
|
|
|
|
|
|
popup->entries = g_list_reverse (tab_entries);
|
|
|
|
|
2002-06-08 23:44:16 -04:00
|
|
|
g_assert (width > 0);
|
2001-08-19 02:23:59 -04:00
|
|
|
height = i / width;
|
|
|
|
if (i % width)
|
|
|
|
height += 1;
|
|
|
|
|
2001-08-30 00:01:38 -04:00
|
|
|
table = gtk_table_new (height, width, FALSE);
|
|
|
|
vbox = gtk_vbox_new (FALSE, 0);
|
2001-08-19 14:09:10 -04:00
|
|
|
|
|
|
|
frame = gtk_frame_new (NULL);
|
|
|
|
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (table), 1);
|
|
|
|
gtk_container_add (GTK_CONTAINER (popup->window),
|
|
|
|
frame);
|
|
|
|
gtk_container_add (GTK_CONTAINER (frame),
|
2001-08-30 00:01:38 -04:00
|
|
|
vbox);
|
2001-08-19 02:23:59 -04:00
|
|
|
|
2001-08-31 02:13:07 -04:00
|
|
|
align = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
|
2005-01-18 11:48:53 -05:00
|
|
|
|
2001-08-30 00:01:38 -04:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), align, TRUE, TRUE, 0);
|
|
|
|
|
|
|
|
gtk_container_add (GTK_CONTAINER (align),
|
|
|
|
table);
|
2005-01-18 11:48:53 -05:00
|
|
|
|
2001-08-30 00:01:38 -04:00
|
|
|
popup->label = gtk_label_new ("");
|
2003-09-26 13:04:37 -04:00
|
|
|
obj = gtk_widget_get_accessible (popup->label);
|
|
|
|
atk_object_set_role (obj, ATK_ROLE_STATUSBAR);
|
|
|
|
|
2001-08-30 00:01:38 -04:00
|
|
|
gtk_misc_set_padding (GTK_MISC (popup->label), 3, 3);
|
|
|
|
|
|
|
|
gtk_box_pack_end (GTK_BOX (vbox), popup->label, FALSE, FALSE, 0);
|
2001-08-19 14:09:10 -04:00
|
|
|
|
2001-08-28 23:37:03 -04:00
|
|
|
max_label_width = 0;
|
2001-08-19 02:23:59 -04:00
|
|
|
top = 0;
|
|
|
|
bottom = 1;
|
|
|
|
tmp = popup->entries;
|
2005-01-18 11:48:53 -05:00
|
|
|
|
2001-08-19 02:23:59 -04:00
|
|
|
while (tmp && top < height)
|
2001-08-19 14:09:10 -04:00
|
|
|
{
|
|
|
|
left = 0;
|
|
|
|
right = 1;
|
|
|
|
|
2001-08-19 02:23:59 -04:00
|
|
|
while (tmp && left < width)
|
|
|
|
{
|
|
|
|
GtkWidget *image;
|
2001-08-28 23:37:03 -04:00
|
|
|
GtkRequisition req;
|
2005-01-18 11:48:53 -05:00
|
|
|
|
2001-08-19 02:23:59 -04:00
|
|
|
TabEntry *te;
|
|
|
|
|
|
|
|
te = tmp->data;
|
2003-01-05 13:36:01 -05:00
|
|
|
|
|
|
|
if (te->blank)
|
|
|
|
{
|
|
|
|
/* just stick a widget here to avoid special cases */
|
|
|
|
image = gtk_alignment_new (0.0, 0.0, 0.0, 0.0);
|
|
|
|
}
|
|
|
|
else if (outline)
|
2002-07-06 15:05:37 -04:00
|
|
|
{
|
2005-01-18 11:48:53 -05:00
|
|
|
if (te->dimmed_icon)
|
|
|
|
{
|
|
|
|
image = selectable_image_new (te->dimmed_icon);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
image = selectable_image_new (te->icon);
|
|
|
|
}
|
2002-07-06 15:05:37 -04:00
|
|
|
|
|
|
|
gtk_misc_set_padding (GTK_MISC (image),
|
|
|
|
INSIDE_SELECT_RECT + OUTSIDE_SELECT_RECT + 1,
|
|
|
|
INSIDE_SELECT_RECT + OUTSIDE_SELECT_RECT + 1);
|
|
|
|
gtk_misc_set_alignment (GTK_MISC (image), 0.5, 0.5);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
image = selectable_workspace_new ((MetaWorkspace *) te->key);
|
|
|
|
}
|
2005-01-18 11:48:53 -05:00
|
|
|
|
2001-08-22 23:24:51 -04:00
|
|
|
te->widget = image;
|
2001-08-19 02:23:59 -04:00
|
|
|
|
|
|
|
gtk_table_attach (GTK_TABLE (table),
|
|
|
|
te->widget,
|
2001-08-22 23:24:51 -04:00
|
|
|
left, right, top, bottom,
|
2001-08-30 00:01:38 -04:00
|
|
|
0, 0,
|
2001-08-22 23:24:51 -04:00
|
|
|
0, 0);
|
2001-08-28 23:37:03 -04:00
|
|
|
|
|
|
|
/* Efficiency rules! */
|
2005-01-20 11:41:29 -05:00
|
|
|
gtk_label_set_markup (GTK_LABEL (popup->label),
|
2001-08-28 23:37:03 -04:00
|
|
|
te->title);
|
|
|
|
gtk_widget_size_request (popup->label, &req);
|
|
|
|
max_label_width = MAX (max_label_width, req.width);
|
2001-08-19 02:23:59 -04:00
|
|
|
|
|
|
|
tmp = tmp->next;
|
|
|
|
|
|
|
|
++left;
|
2001-08-19 14:09:10 -04:00
|
|
|
++right;
|
2001-08-19 02:23:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
++top;
|
2001-08-19 14:09:10 -04:00
|
|
|
++bottom;
|
2001-08-19 02:23:59 -04:00
|
|
|
}
|
2001-08-28 23:37:03 -04:00
|
|
|
|
|
|
|
/* remove all the temporary text */
|
|
|
|
gtk_label_set_text (GTK_LABEL (popup->label), "");
|
|
|
|
|
2001-08-30 00:01:38 -04:00
|
|
|
max_label_width += 20; /* add random padding */
|
|
|
|
|
2001-08-28 23:37:03 -04:00
|
|
|
gtk_window_set_default_size (GTK_WINDOW (popup->window),
|
2001-08-30 00:01:38 -04:00
|
|
|
max_label_width,
|
2001-08-28 23:37:03 -04:00
|
|
|
-1);
|
|
|
|
|
2001-08-19 02:23:59 -04:00
|
|
|
return popup;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
free_entry (gpointer data, gpointer user_data)
|
|
|
|
{
|
|
|
|
TabEntry *te;
|
|
|
|
|
|
|
|
te = data;
|
|
|
|
|
|
|
|
g_free (te->title);
|
2002-07-06 15:05:37 -04:00
|
|
|
if (te->icon)
|
|
|
|
g_object_unref (G_OBJECT (te->icon));
|
2005-01-18 11:48:53 -05:00
|
|
|
if (te->dimmed_icon)
|
|
|
|
g_object_unref (G_OBJECT (te->dimmed_icon));
|
2001-08-19 02:23:59 -04:00
|
|
|
|
|
|
|
g_free (te);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_ui_tab_popup_free (MetaTabPopup *popup)
|
|
|
|
{
|
2002-03-02 10:26:07 -05:00
|
|
|
meta_verbose ("Destroying tab popup window\n");
|
|
|
|
|
2001-08-29 00:53:48 -04:00
|
|
|
gtk_widget_destroy (popup->outline_window);
|
2001-08-19 02:23:59 -04:00
|
|
|
gtk_widget_destroy (popup->window);
|
|
|
|
|
|
|
|
g_list_foreach (popup->entries, free_entry, NULL);
|
|
|
|
|
|
|
|
g_list_free (popup->entries);
|
|
|
|
|
|
|
|
g_free (popup);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_ui_tab_popup_set_showing (MetaTabPopup *popup,
|
|
|
|
gboolean showing)
|
|
|
|
{
|
|
|
|
if (showing)
|
2002-03-02 10:26:07 -05:00
|
|
|
{
|
|
|
|
gtk_widget_show_all (popup->window);
|
|
|
|
}
|
2001-08-19 02:23:59 -04:00
|
|
|
else
|
2001-08-30 00:01:38 -04:00
|
|
|
{
|
2002-07-06 12:50:48 -04:00
|
|
|
if (GTK_WIDGET_VISIBLE (popup->window))
|
|
|
|
{
|
|
|
|
meta_verbose ("Hiding tab popup window\n");
|
|
|
|
gtk_widget_hide (popup->window);
|
|
|
|
meta_core_increment_event_serial (gdk_display);
|
|
|
|
}
|
2001-08-30 00:01:38 -04:00
|
|
|
}
|
2001-08-19 02:23:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
display_entry (MetaTabPopup *popup,
|
|
|
|
TabEntry *te)
|
|
|
|
{
|
2001-08-29 00:53:48 -04:00
|
|
|
GdkRectangle rect;
|
2001-08-30 00:01:38 -04:00
|
|
|
GdkRegion *region;
|
|
|
|
GdkRegion *inner_region;
|
|
|
|
|
2001-08-29 00:53:48 -04:00
|
|
|
|
2001-08-29 01:07:39 -04:00
|
|
|
if (popup->current_selected_entry)
|
2002-07-06 15:05:37 -04:00
|
|
|
{
|
|
|
|
if (popup->outline)
|
|
|
|
unselect_image (popup->current_selected_entry->widget);
|
|
|
|
else
|
|
|
|
unselect_workspace (popup->current_selected_entry->widget);
|
|
|
|
}
|
2001-08-19 14:09:10 -04:00
|
|
|
|
2005-01-20 11:41:29 -05:00
|
|
|
gtk_label_set_markup (GTK_LABEL (popup->label), te->title);
|
2002-07-06 15:05:37 -04:00
|
|
|
|
|
|
|
if (popup->outline)
|
|
|
|
select_image (te->widget);
|
|
|
|
else
|
|
|
|
select_workspace (te->widget);
|
|
|
|
|
2002-06-08 23:44:16 -04:00
|
|
|
if (popup->outline)
|
|
|
|
{
|
|
|
|
/* Do stuff behind gtk's back */
|
|
|
|
gdk_window_hide (popup->outline_window->window);
|
|
|
|
meta_core_increment_event_serial (gdk_display);
|
2001-08-30 00:01:38 -04:00
|
|
|
|
2002-06-08 23:44:16 -04:00
|
|
|
rect = te->rect;
|
|
|
|
rect.x = 0;
|
|
|
|
rect.y = 0;
|
2001-08-30 00:01:38 -04:00
|
|
|
|
2002-06-08 23:44:16 -04:00
|
|
|
gdk_window_move_resize (popup->outline_window->window,
|
|
|
|
te->rect.x, te->rect.y,
|
|
|
|
te->rect.width, te->rect.height);
|
2001-08-29 00:53:48 -04:00
|
|
|
|
2002-06-08 23:44:16 -04:00
|
|
|
gdk_window_set_background (popup->outline_window->window,
|
|
|
|
&popup->outline_window->style->black);
|
2001-08-30 00:01:38 -04:00
|
|
|
|
2002-06-08 23:44:16 -04:00
|
|
|
region = gdk_region_rectangle (&rect);
|
|
|
|
inner_region = gdk_region_rectangle (&te->inner_rect);
|
|
|
|
gdk_region_subtract (region, inner_region);
|
|
|
|
gdk_region_destroy (inner_region);
|
2001-08-30 00:01:38 -04:00
|
|
|
|
2002-06-08 23:44:16 -04:00
|
|
|
gdk_window_shape_combine_region (popup->outline_window->window,
|
|
|
|
region,
|
|
|
|
0, 0);
|
2001-08-29 00:53:48 -04:00
|
|
|
|
2002-06-08 23:44:16 -04:00
|
|
|
gdk_region_destroy (region);
|
2001-08-30 00:01:38 -04:00
|
|
|
|
2002-06-08 23:44:16 -04:00
|
|
|
/* This should piss off gtk a bit, but we don't want to raise
|
2005-10-03 13:11:49 -04:00
|
|
|
* above the tab popup. So, instead of calling gtk_widget_show,
|
|
|
|
* we manually set the window as mapped and then manually map it
|
|
|
|
* with gdk functions.
|
2002-06-08 23:44:16 -04:00
|
|
|
*/
|
2005-10-03 13:11:49 -04:00
|
|
|
GTK_WIDGET_SET_FLAGS (popup->outline_window, GTK_MAPPED);
|
2002-06-08 23:44:16 -04:00
|
|
|
gdk_window_show_unraised (popup->outline_window->window);
|
|
|
|
}
|
2001-08-29 00:53:48 -04:00
|
|
|
|
2001-08-29 01:07:39 -04:00
|
|
|
/* Must be before we handle an expose for the outline window */
|
|
|
|
popup->current_selected_entry = te;
|
2001-08-19 02:23:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_ui_tab_popup_forward (MetaTabPopup *popup)
|
|
|
|
{
|
|
|
|
if (popup->current != NULL)
|
|
|
|
popup->current = popup->current->next;
|
|
|
|
|
|
|
|
if (popup->current == NULL)
|
|
|
|
popup->current = popup->entries;
|
|
|
|
|
|
|
|
if (popup->current != NULL)
|
|
|
|
{
|
|
|
|
TabEntry *te;
|
|
|
|
|
|
|
|
te = popup->current->data;
|
|
|
|
|
|
|
|
display_entry (popup, te);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_ui_tab_popup_backward (MetaTabPopup *popup)
|
|
|
|
{
|
|
|
|
if (popup->current != NULL)
|
|
|
|
popup->current = popup->current->prev;
|
|
|
|
|
|
|
|
if (popup->current == NULL)
|
|
|
|
popup->current = g_list_last (popup->entries);
|
|
|
|
|
|
|
|
if (popup->current != NULL)
|
|
|
|
{
|
|
|
|
TabEntry *te;
|
|
|
|
|
|
|
|
te = popup->current->data;
|
|
|
|
|
|
|
|
display_entry (popup, te);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-06-08 23:44:16 -04:00
|
|
|
MetaTabEntryKey
|
2001-08-19 02:23:59 -04:00
|
|
|
meta_ui_tab_popup_get_selected (MetaTabPopup *popup)
|
|
|
|
{
|
|
|
|
if (popup->current)
|
|
|
|
{
|
|
|
|
TabEntry *te;
|
|
|
|
|
|
|
|
te = popup->current->data;
|
|
|
|
|
2002-06-08 23:44:16 -04:00
|
|
|
return te->key;
|
2001-08-19 02:23:59 -04:00
|
|
|
}
|
|
|
|
else
|
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 19:18:22 -04:00
|
|
|
return (MetaTabEntryKey)None;
|
2001-08-19 02:23:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_ui_tab_popup_select (MetaTabPopup *popup,
|
2002-06-08 23:44:16 -04:00
|
|
|
MetaTabEntryKey key)
|
2001-08-19 02:23:59 -04:00
|
|
|
{
|
|
|
|
GList *tmp;
|
|
|
|
|
2002-09-04 00:15:46 -04:00
|
|
|
/* Note, "key" may not be in the list of entries; other code assumes
|
|
|
|
* it's OK to pass in a key that isn't.
|
|
|
|
*/
|
|
|
|
|
2001-08-19 02:23:59 -04:00
|
|
|
tmp = popup->entries;
|
|
|
|
while (tmp != NULL)
|
|
|
|
{
|
|
|
|
TabEntry *te;
|
|
|
|
|
|
|
|
te = tmp->data;
|
|
|
|
|
2002-06-08 23:44:16 -04:00
|
|
|
if (te->key == key)
|
2001-08-19 02:23:59 -04:00
|
|
|
{
|
|
|
|
popup->current = tmp;
|
|
|
|
|
|
|
|
display_entry (popup, te);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
tmp = tmp->next;
|
|
|
|
}
|
|
|
|
}
|
2001-08-22 23:24:51 -04:00
|
|
|
|
|
|
|
#define META_TYPE_SELECT_IMAGE (meta_select_image_get_type ())
|
|
|
|
#define META_SELECT_IMAGE(obj) (GTK_CHECK_CAST ((obj), META_TYPE_SELECT_IMAGE, MetaSelectImage))
|
|
|
|
|
|
|
|
typedef struct _MetaSelectImage MetaSelectImage;
|
|
|
|
typedef struct _MetaSelectImageClass MetaSelectImageClass;
|
|
|
|
|
|
|
|
struct _MetaSelectImage
|
|
|
|
{
|
|
|
|
GtkImage parent_instance;
|
|
|
|
guint selected : 1;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct _MetaSelectImageClass
|
|
|
|
{
|
|
|
|
GtkImageClass parent_class;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static GType meta_select_image_get_type (void) G_GNUC_CONST;
|
|
|
|
|
|
|
|
static GtkWidget*
|
|
|
|
selectable_image_new (GdkPixbuf *pixbuf)
|
|
|
|
{
|
|
|
|
GtkWidget *w;
|
|
|
|
|
|
|
|
w = g_object_new (meta_select_image_get_type (), NULL);
|
|
|
|
gtk_image_set_from_pixbuf (GTK_IMAGE (w), pixbuf);
|
|
|
|
|
|
|
|
return w;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
select_image (GtkWidget *widget)
|
|
|
|
{
|
|
|
|
META_SELECT_IMAGE (widget)->selected = TRUE;
|
|
|
|
gtk_widget_queue_draw (widget);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
unselect_image (GtkWidget *widget)
|
|
|
|
{
|
|
|
|
META_SELECT_IMAGE (widget)->selected = FALSE;
|
|
|
|
gtk_widget_queue_draw (widget);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void meta_select_image_class_init (MetaSelectImageClass *klass);
|
|
|
|
static gboolean meta_select_image_expose_event (GtkWidget *widget,
|
|
|
|
GdkEventExpose *event);
|
|
|
|
|
|
|
|
static GtkImageClass *parent_class;
|
|
|
|
|
|
|
|
GType
|
|
|
|
meta_select_image_get_type (void)
|
|
|
|
{
|
|
|
|
static GtkType image_type = 0;
|
|
|
|
|
|
|
|
if (!image_type)
|
|
|
|
{
|
|
|
|
static const GTypeInfo image_info =
|
|
|
|
{
|
|
|
|
sizeof (MetaSelectImageClass),
|
|
|
|
NULL, /* base_init */
|
|
|
|
NULL, /* base_finalize */
|
|
|
|
(GClassInitFunc) meta_select_image_class_init,
|
|
|
|
NULL, /* class_finalize */
|
|
|
|
NULL, /* class_data */
|
|
|
|
sizeof (MetaSelectImage),
|
|
|
|
16, /* n_preallocs */
|
|
|
|
(GInstanceInitFunc) NULL,
|
|
|
|
};
|
|
|
|
|
|
|
|
image_type = g_type_register_static (GTK_TYPE_IMAGE, "MetaSelectImage", &image_info, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
return image_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_select_image_class_init (MetaSelectImageClass *klass)
|
|
|
|
{
|
|
|
|
GtkWidgetClass *widget_class;
|
|
|
|
|
|
|
|
parent_class = gtk_type_class (gtk_image_get_type ());
|
|
|
|
|
|
|
|
widget_class = GTK_WIDGET_CLASS (klass);
|
|
|
|
|
|
|
|
widget_class->expose_event = meta_select_image_expose_event;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
meta_select_image_expose_event (GtkWidget *widget,
|
|
|
|
GdkEventExpose *event)
|
|
|
|
{
|
|
|
|
if (META_SELECT_IMAGE (widget)->selected)
|
|
|
|
{
|
|
|
|
int x, y, w, h;
|
|
|
|
GtkMisc *misc;
|
|
|
|
|
|
|
|
misc = GTK_MISC (widget);
|
|
|
|
|
|
|
|
x = (widget->allocation.x * (1.0 - misc->xalign) +
|
|
|
|
(widget->allocation.x + widget->allocation.width
|
|
|
|
- (widget->requisition.width - misc->xpad * 2)) *
|
|
|
|
misc->xalign) + 0.5;
|
|
|
|
y = (widget->allocation.y * (1.0 - misc->yalign) +
|
|
|
|
(widget->allocation.y + widget->allocation.height
|
|
|
|
- (widget->requisition.height - misc->ypad * 2)) *
|
|
|
|
misc->yalign) + 0.5;
|
|
|
|
|
2001-08-23 20:32:17 -04:00
|
|
|
x -= INSIDE_SELECT_RECT + 1;
|
|
|
|
y -= INSIDE_SELECT_RECT + 1;
|
2001-08-22 23:24:51 -04:00
|
|
|
|
|
|
|
w = widget->requisition.width - OUTSIDE_SELECT_RECT * 2 - 1;
|
|
|
|
h = widget->requisition.height - OUTSIDE_SELECT_RECT * 2 - 1;
|
2002-07-06 15:05:37 -04:00
|
|
|
|
2001-08-22 23:24:51 -04:00
|
|
|
gdk_draw_rectangle (widget->window,
|
|
|
|
widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
|
|
|
|
FALSE,
|
|
|
|
x, y, w, h);
|
|
|
|
gdk_draw_rectangle (widget->window,
|
|
|
|
widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
|
|
|
|
FALSE,
|
|
|
|
x - 1, y - 1, w + 2, h + 2);
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
gdk_draw_rectangle (widget->window,
|
|
|
|
widget->style->bg_gc[GTK_STATE_SELECTED],
|
|
|
|
TRUE,
|
|
|
|
x, y, w, h);
|
|
|
|
#endif
|
|
|
|
#if 0
|
|
|
|
gtk_paint_focus (widget->style, widget->window,
|
|
|
|
&event->area, widget, "meta-tab-image",
|
|
|
|
x, y, w, h);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
return GTK_WIDGET_CLASS (parent_class)->expose_event (widget, event);
|
|
|
|
}
|
2002-07-06 15:05:37 -04:00
|
|
|
|
|
|
|
#define META_TYPE_SELECT_WORKSPACE (meta_select_workspace_get_type ())
|
|
|
|
#define META_SELECT_WORKSPACE(obj) (GTK_CHECK_CAST ((obj), META_TYPE_SELECT_WORKSPACE, MetaSelectWorkspace))
|
|
|
|
|
|
|
|
typedef struct _MetaSelectWorkspace MetaSelectWorkspace;
|
|
|
|
typedef struct _MetaSelectWorkspaceClass MetaSelectWorkspaceClass;
|
|
|
|
|
|
|
|
struct _MetaSelectWorkspace
|
|
|
|
{
|
|
|
|
GtkDrawingArea parent_instance;
|
|
|
|
MetaWorkspace *workspace;
|
|
|
|
guint selected : 1;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct _MetaSelectWorkspaceClass
|
|
|
|
{
|
|
|
|
GtkDrawingAreaClass parent_class;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static GType meta_select_workspace_get_type (void) G_GNUC_CONST;
|
|
|
|
|
|
|
|
#define SELECT_OUTLINE_WIDTH 2
|
2002-07-06 15:11:57 -04:00
|
|
|
#define MINI_WORKSPACE_WIDTH 48
|
2002-07-06 15:05:37 -04:00
|
|
|
|
|
|
|
static GtkWidget*
|
|
|
|
selectable_workspace_new (MetaWorkspace *workspace)
|
|
|
|
{
|
|
|
|
GtkWidget *widget;
|
|
|
|
double screen_aspect;
|
|
|
|
|
|
|
|
widget = g_object_new (meta_select_workspace_get_type (), NULL);
|
|
|
|
|
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 09:58:50 -05:00
|
|
|
screen_aspect = (double) workspace->screen->rect.height /
|
|
|
|
(double) workspace->screen->rect.width;
|
2002-07-06 15:05:37 -04:00
|
|
|
|
|
|
|
/* account for select rect */
|
|
|
|
gtk_widget_set_size_request (widget,
|
2002-07-06 15:11:57 -04:00
|
|
|
MINI_WORKSPACE_WIDTH + SELECT_OUTLINE_WIDTH * 2,
|
|
|
|
MINI_WORKSPACE_WIDTH * screen_aspect + SELECT_OUTLINE_WIDTH * 2);
|
2002-07-06 15:05:37 -04:00
|
|
|
|
|
|
|
META_SELECT_WORKSPACE (widget)->workspace = workspace;
|
|
|
|
|
|
|
|
return widget;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
select_workspace (GtkWidget *widget)
|
|
|
|
{
|
|
|
|
META_SELECT_WORKSPACE(widget)->selected = TRUE;
|
|
|
|
gtk_widget_queue_draw (widget);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
unselect_workspace (GtkWidget *widget)
|
|
|
|
{
|
|
|
|
META_SELECT_WORKSPACE (widget)->selected = FALSE;
|
|
|
|
gtk_widget_queue_draw (widget);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void meta_select_workspace_class_init (MetaSelectWorkspaceClass *klass);
|
|
|
|
|
|
|
|
static gboolean meta_select_workspace_expose_event (GtkWidget *widget,
|
|
|
|
GdkEventExpose *event);
|
|
|
|
|
|
|
|
GType
|
|
|
|
meta_select_workspace_get_type (void)
|
|
|
|
{
|
|
|
|
static GtkType workspace_type = 0;
|
|
|
|
|
|
|
|
if (!workspace_type)
|
|
|
|
{
|
|
|
|
static const GTypeInfo workspace_info =
|
|
|
|
{
|
|
|
|
sizeof (MetaSelectWorkspaceClass),
|
|
|
|
NULL, /* base_init */
|
|
|
|
NULL, /* base_finalize */
|
|
|
|
(GClassInitFunc) meta_select_workspace_class_init,
|
|
|
|
NULL, /* class_finalize */
|
|
|
|
NULL, /* class_data */
|
|
|
|
sizeof (MetaSelectWorkspace),
|
|
|
|
16, /* n_preallocs */
|
|
|
|
(GInstanceInitFunc) NULL,
|
|
|
|
};
|
|
|
|
|
|
|
|
workspace_type = g_type_register_static (GTK_TYPE_DRAWING_AREA,
|
|
|
|
"MetaSelectWorkspace",
|
|
|
|
&workspace_info,
|
|
|
|
0);
|
|
|
|
}
|
|
|
|
|
|
|
|
return workspace_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_select_workspace_class_init (MetaSelectWorkspaceClass *klass)
|
|
|
|
{
|
|
|
|
GtkWidgetClass *widget_class;
|
|
|
|
|
|
|
|
widget_class = GTK_WIDGET_CLASS (klass);
|
|
|
|
|
|
|
|
widget_class->expose_event = meta_select_workspace_expose_event;
|
|
|
|
}
|
|
|
|
|
2005-10-03 15:06:17 -04:00
|
|
|
/**
|
|
|
|
* meta_convert_meta_to_wnck() converts a MetaWindow to a
|
|
|
|
* WnckWindowDisplayInfo window that is used to build a thumbnail of a
|
|
|
|
* workspace.
|
|
|
|
**/
|
|
|
|
static WnckWindowDisplayInfo
|
|
|
|
meta_convert_meta_to_wnck (MetaWindow *window, MetaScreen *screen)
|
|
|
|
{
|
|
|
|
WnckWindowDisplayInfo wnck_window;
|
|
|
|
wnck_window.icon = window->icon;
|
|
|
|
wnck_window.mini_icon = window->mini_icon;
|
|
|
|
|
|
|
|
wnck_window.is_active = FALSE;
|
|
|
|
if (window == window->display->expected_focus_window)
|
|
|
|
wnck_window.is_active = TRUE;
|
|
|
|
|
|
|
|
if (window->frame)
|
|
|
|
{
|
|
|
|
wnck_window.x = window->frame->rect.x;
|
|
|
|
wnck_window.y = window->frame->rect.y;
|
|
|
|
wnck_window.width = window->frame->rect.width;
|
|
|
|
wnck_window.height = window->frame->rect.height;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
wnck_window.x = window->rect.x;
|
|
|
|
wnck_window.y = window->rect.y;
|
|
|
|
wnck_window.width = window->rect.width;
|
|
|
|
wnck_window.height = window->rect.height;
|
|
|
|
}
|
|
|
|
return wnck_window;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-07-06 15:05:37 -04:00
|
|
|
static gboolean
|
|
|
|
meta_select_workspace_expose_event (GtkWidget *widget,
|
|
|
|
GdkEventExpose *event)
|
|
|
|
{
|
|
|
|
MetaWorkspace *workspace;
|
|
|
|
WnckWindowDisplayInfo *windows;
|
|
|
|
int i, n_windows;
|
|
|
|
GList *tmp, *list;
|
|
|
|
|
|
|
|
workspace = META_SELECT_WORKSPACE (widget)->workspace;
|
|
|
|
|
|
|
|
list = meta_stack_list_windows (workspace->screen->stack, workspace);
|
|
|
|
n_windows = g_list_length (list);
|
|
|
|
windows = g_new (WnckWindowDisplayInfo, n_windows);
|
|
|
|
|
|
|
|
tmp = list;
|
|
|
|
i = 0;
|
|
|
|
while (tmp != NULL)
|
|
|
|
{
|
|
|
|
MetaWindow *window;
|
2005-01-25 21:51:31 -05:00
|
|
|
gboolean ignoreable_sticky;
|
2002-07-06 15:05:37 -04:00
|
|
|
|
|
|
|
window = tmp->data;
|
|
|
|
|
2005-01-25 21:51:31 -05:00
|
|
|
ignoreable_sticky = window->on_all_workspaces &&
|
|
|
|
workspace != workspace->screen->active_workspace;
|
|
|
|
|
2002-07-06 15:05:37 -04:00
|
|
|
if (window->skip_pager ||
|
2005-10-03 15:06:17 -04:00
|
|
|
!meta_window_showing_on_its_workspace (window) ||
|
2005-01-25 21:51:31 -05:00
|
|
|
window->unmaps_pending ||
|
|
|
|
ignoreable_sticky)
|
2002-07-06 15:05:37 -04:00
|
|
|
{
|
|
|
|
--n_windows;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-10-03 15:06:17 -04:00
|
|
|
windows[i] = meta_convert_meta_to_wnck (window, workspace->screen);
|
2002-07-06 15:05:37 -04:00
|
|
|
i++;
|
|
|
|
}
|
|
|
|
tmp = tmp->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_list_free (list);
|
|
|
|
|
|
|
|
wnck_draw_workspace (widget,
|
|
|
|
widget->window,
|
|
|
|
SELECT_OUTLINE_WIDTH,
|
|
|
|
SELECT_OUTLINE_WIDTH,
|
|
|
|
widget->allocation.width - SELECT_OUTLINE_WIDTH * 2,
|
|
|
|
widget->allocation.height - SELECT_OUTLINE_WIDTH * 2,
|
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 09:58:50 -05:00
|
|
|
workspace->screen->rect.width,
|
|
|
|
workspace->screen->rect.height,
|
2002-07-06 15:05:37 -04:00
|
|
|
NULL,
|
|
|
|
(workspace->screen->active_workspace == workspace),
|
|
|
|
windows,
|
|
|
|
n_windows);
|
|
|
|
|
|
|
|
g_free (windows);
|
|
|
|
|
|
|
|
if (META_SELECT_WORKSPACE (widget)->selected)
|
|
|
|
{
|
|
|
|
i = SELECT_OUTLINE_WIDTH - 1;
|
|
|
|
while (i >= 0)
|
|
|
|
{
|
|
|
|
gdk_draw_rectangle (widget->window,
|
|
|
|
widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
|
|
|
|
FALSE,
|
|
|
|
i,
|
|
|
|
i,
|
|
|
|
widget->allocation.width - i * 2 - 1,
|
|
|
|
widget->allocation.height - i * 2 - 1);
|
|
|
|
|
|
|
|
--i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|