2001-06-12 00:38:24 -04:00
|
|
|
/* Metacity window frame manager widget */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (C) 2001 Havoc Pennington
|
|
|
|
*
|
|
|
|
* 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 17:41:12 -05:00
|
|
|
#include <config.h>
|
2001-06-12 00:38:24 -04:00
|
|
|
#include "frames.h"
|
2001-06-18 02:11:53 -04:00
|
|
|
#include "util.h"
|
|
|
|
#include "core.h"
|
2001-06-21 01:23:24 -04:00
|
|
|
#include "menu.h"
|
2001-06-30 19:17:52 -04:00
|
|
|
#include "fixedtip.h"
|
2002-01-05 23:51:53 -05:00
|
|
|
#include "theme.h"
|
2002-05-23 22:55:54 -04:00
|
|
|
#include "prefs.h"
|
2001-06-21 01:23:24 -04:00
|
|
|
|
2002-05-30 20:02:54 -04:00
|
|
|
#ifdef HAVE_SHAPE
|
|
|
|
#include <X11/extensions/shape.h>
|
|
|
|
#endif
|
|
|
|
|
2001-06-21 01:23:24 -04:00
|
|
|
#define DEFAULT_INNER_BUTTON_BORDER 3
|
2001-06-12 00:38:24 -04:00
|
|
|
|
|
|
|
static void meta_frames_class_init (MetaFramesClass *klass);
|
|
|
|
static void meta_frames_init (MetaFrames *frames);
|
|
|
|
static void meta_frames_destroy (GtkObject *object);
|
|
|
|
static void meta_frames_finalize (GObject *object);
|
|
|
|
static void meta_frames_style_set (GtkWidget *widget,
|
|
|
|
GtkStyle *prev_style);
|
2001-07-02 21:45:43 -04:00
|
|
|
static void meta_frames_realize (GtkWidget *widget);
|
|
|
|
static void meta_frames_unrealize (GtkWidget *widget);
|
|
|
|
|
|
|
|
static gboolean meta_frames_button_press_event (GtkWidget *widget,
|
|
|
|
GdkEventButton *event);
|
|
|
|
static gboolean meta_frames_button_release_event (GtkWidget *widget,
|
|
|
|
GdkEventButton *event);
|
|
|
|
static gboolean meta_frames_motion_notify_event (GtkWidget *widget,
|
|
|
|
GdkEventMotion *event);
|
|
|
|
static gboolean meta_frames_destroy_event (GtkWidget *widget,
|
|
|
|
GdkEventAny *event);
|
|
|
|
static gboolean meta_frames_expose_event (GtkWidget *widget,
|
|
|
|
GdkEventExpose *event);
|
|
|
|
static gboolean meta_frames_enter_notify_event (GtkWidget *widget,
|
|
|
|
GdkEventCrossing *event);
|
|
|
|
static gboolean meta_frames_leave_notify_event (GtkWidget *widget,
|
|
|
|
GdkEventCrossing *event);
|
2001-06-12 00:38:24 -04:00
|
|
|
|
2002-01-27 00:27:11 -05:00
|
|
|
static void meta_frames_paint_to_drawable (MetaFrames *frames,
|
|
|
|
MetaUIFrame *frame,
|
|
|
|
GdkDrawable *drawable,
|
2002-05-04 20:21:17 -04:00
|
|
|
GdkRegion *region);
|
2001-06-15 00:33:21 -04:00
|
|
|
|
|
|
|
static void meta_frames_calc_geometry (MetaFrames *frames,
|
2001-06-18 02:11:53 -04:00
|
|
|
MetaUIFrame *frame,
|
2001-06-15 00:33:21 -04:00
|
|
|
MetaFrameGeometry *fgeom);
|
|
|
|
|
2002-02-09 12:02:38 -05:00
|
|
|
static void meta_frames_ensure_layout (MetaFrames *frames,
|
|
|
|
MetaUIFrame *frame);
|
|
|
|
|
2001-06-18 02:11:53 -04:00
|
|
|
static MetaUIFrame* meta_frames_lookup_window (MetaFrames *frames,
|
|
|
|
Window xwindow);
|
|
|
|
|
2002-05-23 22:55:54 -04:00
|
|
|
static void meta_frames_font_changed (MetaFrames *frames);
|
2001-06-20 00:29:28 -04:00
|
|
|
|
|
|
|
static GdkRectangle* control_rect (MetaFrameControl control,
|
|
|
|
MetaFrameGeometry *fgeom);
|
|
|
|
static MetaFrameControl get_control (MetaFrames *frames,
|
|
|
|
MetaUIFrame *frame,
|
|
|
|
int x,
|
|
|
|
int y);
|
2001-06-30 19:17:52 -04:00
|
|
|
static void clear_tip (MetaFrames *frames);
|
2001-06-20 00:29:28 -04:00
|
|
|
|
2001-06-12 00:38:24 -04:00
|
|
|
static GtkWidgetClass *parent_class = NULL;
|
|
|
|
|
|
|
|
GtkType
|
|
|
|
meta_frames_get_type (void)
|
|
|
|
{
|
|
|
|
static GtkType frames_type = 0;
|
|
|
|
|
|
|
|
if (!frames_type)
|
|
|
|
{
|
|
|
|
static const GtkTypeInfo frames_info =
|
|
|
|
{
|
|
|
|
"MetaFrames",
|
|
|
|
sizeof (MetaFrames),
|
|
|
|
sizeof (MetaFramesClass),
|
|
|
|
(GtkClassInitFunc) meta_frames_class_init,
|
|
|
|
(GtkObjectInitFunc) meta_frames_init,
|
|
|
|
/* reserved_1 */ NULL,
|
|
|
|
/* reserved_2 */ NULL,
|
|
|
|
(GtkClassInitFunc) NULL,
|
|
|
|
};
|
|
|
|
|
2001-06-19 23:01:26 -04:00
|
|
|
frames_type = gtk_type_unique (GTK_TYPE_WINDOW, &frames_info);
|
2001-06-12 00:38:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return frames_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_frames_class_init (MetaFramesClass *class)
|
|
|
|
{
|
|
|
|
GObjectClass *gobject_class;
|
|
|
|
GtkObjectClass *object_class;
|
|
|
|
GtkWidgetClass *widget_class;
|
|
|
|
|
|
|
|
gobject_class = G_OBJECT_CLASS (class);
|
|
|
|
object_class = (GtkObjectClass*) class;
|
|
|
|
widget_class = (GtkWidgetClass*) class;
|
|
|
|
|
|
|
|
parent_class = g_type_class_peek_parent (class);
|
|
|
|
|
|
|
|
gobject_class->finalize = meta_frames_finalize;
|
|
|
|
object_class->destroy = meta_frames_destroy;
|
|
|
|
|
|
|
|
widget_class->style_set = meta_frames_style_set;
|
2001-06-15 00:33:21 -04:00
|
|
|
|
2001-07-02 21:45:43 -04:00
|
|
|
widget_class->realize = meta_frames_realize;
|
|
|
|
widget_class->unrealize = meta_frames_unrealize;
|
|
|
|
|
2001-06-18 02:11:53 -04:00
|
|
|
widget_class->expose_event = meta_frames_expose_event;
|
2002-02-07 22:34:26 -05:00
|
|
|
widget_class->destroy_event = meta_frames_destroy_event;
|
2001-06-20 00:29:28 -04:00
|
|
|
widget_class->button_press_event = meta_frames_button_press_event;
|
|
|
|
widget_class->button_release_event = meta_frames_button_release_event;
|
|
|
|
widget_class->motion_notify_event = meta_frames_motion_notify_event;
|
2002-02-07 22:34:26 -05:00
|
|
|
widget_class->enter_notify_event = meta_frames_enter_notify_event;
|
2001-07-25 23:14:45 -04:00
|
|
|
widget_class->leave_notify_event = meta_frames_leave_notify_event;
|
2001-06-15 00:33:21 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
|
|
|
unsigned_long_equal (gconstpointer v1,
|
|
|
|
gconstpointer v2)
|
|
|
|
{
|
|
|
|
return *((const gulong*) v1) == *((const gulong*) v2);
|
|
|
|
}
|
2001-06-12 00:38:24 -04:00
|
|
|
|
2001-06-15 00:33:21 -04:00
|
|
|
static guint
|
|
|
|
unsigned_long_hash (gconstpointer v)
|
|
|
|
{
|
|
|
|
gulong val = * (const gulong *) v;
|
|
|
|
|
|
|
|
/* I'm not sure this works so well. */
|
|
|
|
#if G_SIZEOF_LONG > 4
|
|
|
|
return (guint) (val ^ (val >> 32));
|
|
|
|
#else
|
|
|
|
return val;
|
|
|
|
#endif
|
2001-06-12 00:38:24 -04:00
|
|
|
}
|
|
|
|
|
2002-05-23 22:55:54 -04:00
|
|
|
static void
|
|
|
|
font_changed_callback (MetaPreference pref,
|
|
|
|
void *data)
|
|
|
|
{
|
|
|
|
if (pref == META_PREF_TITLEBAR_FONT)
|
|
|
|
{
|
|
|
|
meta_frames_font_changed (META_FRAMES (data));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-06-12 00:38:24 -04:00
|
|
|
static void
|
|
|
|
meta_frames_init (MetaFrames *frames)
|
|
|
|
{
|
|
|
|
GTK_WINDOW (frames)->type = GTK_WINDOW_POPUP;
|
2001-06-15 00:33:21 -04:00
|
|
|
|
2002-02-09 12:02:38 -05:00
|
|
|
frames->text_heights = g_hash_table_new (g_int_hash, g_int_equal);
|
|
|
|
|
2001-06-15 00:33:21 -04:00
|
|
|
frames->frames = g_hash_table_new (unsigned_long_hash, unsigned_long_equal);
|
2001-06-20 00:29:28 -04:00
|
|
|
|
2001-06-30 19:17:52 -04:00
|
|
|
frames->tooltip_timeout = 0;
|
2001-08-18 21:19:54 -04:00
|
|
|
|
|
|
|
frames->expose_delay_count = 0;
|
2002-05-04 20:21:17 -04:00
|
|
|
|
|
|
|
gtk_widget_set_double_buffered (GTK_WIDGET (frames), FALSE);
|
2002-05-23 22:55:54 -04:00
|
|
|
|
|
|
|
meta_prefs_add_listener (font_changed_callback, frames);
|
2001-06-12 00:38:24 -04:00
|
|
|
}
|
|
|
|
|
2001-06-15 00:33:21 -04:00
|
|
|
static void
|
|
|
|
listify_func (gpointer key, gpointer value, gpointer data)
|
|
|
|
{
|
|
|
|
GSList **listp;
|
2001-06-12 00:38:24 -04:00
|
|
|
|
2001-06-15 00:33:21 -04:00
|
|
|
listp = data;
|
|
|
|
*listp = g_slist_prepend (*listp, value);
|
2001-06-12 00:38:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-06-17 23:24:25 -04:00
|
|
|
meta_frames_destroy (GtkObject *object)
|
2001-06-12 00:38:24 -04:00
|
|
|
{
|
2001-06-15 00:33:21 -04:00
|
|
|
GSList *winlist;
|
|
|
|
GSList *tmp;
|
2001-06-17 23:24:25 -04:00
|
|
|
MetaFrames *frames;
|
2001-06-15 00:33:21 -04:00
|
|
|
|
|
|
|
frames = META_FRAMES (object);
|
2002-05-23 22:55:54 -04:00
|
|
|
|
2001-06-30 19:17:52 -04:00
|
|
|
clear_tip (frames);
|
2001-06-17 23:24:25 -04:00
|
|
|
|
2001-06-15 00:33:21 -04:00
|
|
|
winlist = NULL;
|
|
|
|
g_hash_table_foreach (frames->frames,
|
|
|
|
listify_func,
|
|
|
|
&winlist);
|
|
|
|
|
|
|
|
/* Unmanage all frames */
|
|
|
|
tmp = winlist;
|
|
|
|
while (tmp != NULL)
|
|
|
|
{
|
2001-06-18 02:11:53 -04:00
|
|
|
MetaUIFrame *frame;
|
2001-06-15 00:33:21 -04:00
|
|
|
|
|
|
|
frame = tmp->data;
|
|
|
|
|
|
|
|
meta_frames_unmanage_window (frames, frame->xwindow);
|
|
|
|
|
|
|
|
tmp = tmp->next;
|
|
|
|
}
|
|
|
|
g_slist_free (winlist);
|
|
|
|
|
2001-06-17 23:24:25 -04:00
|
|
|
GTK_OBJECT_CLASS (parent_class)->destroy (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_frames_finalize (GObject *object)
|
|
|
|
{
|
|
|
|
MetaFrames *frames;
|
|
|
|
|
|
|
|
frames = META_FRAMES (object);
|
|
|
|
|
2002-06-01 20:24:31 -04:00
|
|
|
meta_prefs_remove_listener (font_changed_callback, frames);
|
|
|
|
|
2002-02-09 12:02:38 -05:00
|
|
|
g_hash_table_destroy (frames->text_heights);
|
|
|
|
|
2001-06-15 00:33:21 -04:00
|
|
|
g_assert (g_hash_table_size (frames->frames) == 0);
|
|
|
|
g_hash_table_destroy (frames->frames);
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
2001-06-18 02:11:53 -04:00
|
|
|
static void
|
|
|
|
queue_recalc_func (gpointer key, gpointer value, gpointer data)
|
|
|
|
{
|
|
|
|
MetaUIFrame *frame;
|
|
|
|
MetaFrames *frames;
|
|
|
|
|
|
|
|
frames = META_FRAMES (data);
|
|
|
|
frame = value;
|
|
|
|
|
|
|
|
/* If a resize occurs it will cause a redraw, but the
|
|
|
|
* resize may not actually be needed so we always redraw
|
|
|
|
* in case of color change.
|
|
|
|
*/
|
|
|
|
gtk_style_set_background (GTK_WIDGET (frames)->style,
|
|
|
|
frame->window, GTK_STATE_NORMAL);
|
|
|
|
gdk_window_invalidate_rect (frame->window, NULL, FALSE);
|
|
|
|
meta_core_queue_frame_resize (gdk_display,
|
|
|
|
frame->xwindow);
|
2001-06-21 02:08:35 -04:00
|
|
|
if (frame->layout)
|
|
|
|
{
|
2002-02-09 12:02:38 -05:00
|
|
|
/* save title to recreate layout */
|
|
|
|
g_free (frame->title);
|
2001-06-21 02:08:35 -04:00
|
|
|
|
2002-02-09 12:02:38 -05:00
|
|
|
frame->title = g_strdup (pango_layout_get_text (frame->layout));
|
2001-06-21 02:08:35 -04:00
|
|
|
|
|
|
|
g_object_unref (G_OBJECT (frame->layout));
|
2002-02-09 12:02:38 -05:00
|
|
|
frame->layout = NULL;
|
2001-06-21 02:08:35 -04:00
|
|
|
}
|
2001-06-18 02:11:53 -04:00
|
|
|
}
|
|
|
|
|
2001-06-15 00:33:21 -04:00
|
|
|
static void
|
2002-05-23 22:55:54 -04:00
|
|
|
meta_frames_font_changed (MetaFrames *frames)
|
2001-06-15 00:33:21 -04:00
|
|
|
{
|
2002-02-09 12:02:38 -05:00
|
|
|
if (g_hash_table_size (frames->text_heights) > 0)
|
2002-02-06 22:07:56 -05:00
|
|
|
{
|
2002-02-09 12:02:38 -05:00
|
|
|
g_hash_table_destroy (frames->text_heights);
|
|
|
|
frames->text_heights = g_hash_table_new (g_int_hash, g_int_equal);
|
2002-02-06 22:07:56 -05:00
|
|
|
}
|
|
|
|
|
2001-06-18 02:11:53 -04:00
|
|
|
/* Queue a draw/resize on all frames */
|
|
|
|
g_hash_table_foreach (frames->frames,
|
|
|
|
queue_recalc_func, frames);
|
2002-02-06 22:07:56 -05:00
|
|
|
|
2002-05-23 22:55:54 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_frames_style_set (GtkWidget *widget,
|
|
|
|
GtkStyle *prev_style)
|
|
|
|
{
|
|
|
|
MetaFrames *frames;
|
|
|
|
|
|
|
|
frames = META_FRAMES (widget);
|
|
|
|
|
|
|
|
meta_frames_font_changed (frames);
|
|
|
|
|
2002-02-06 22:07:56 -05:00
|
|
|
GTK_WIDGET_CLASS (parent_class)->style_set (widget, prev_style);
|
2001-06-15 00:33:21 -04:00
|
|
|
}
|
|
|
|
|
2002-02-09 12:02:38 -05:00
|
|
|
static void
|
|
|
|
meta_frames_ensure_layout (MetaFrames *frames,
|
|
|
|
MetaUIFrame *frame)
|
|
|
|
{
|
|
|
|
GtkWidget *widget;
|
2002-02-14 21:32:48 -05:00
|
|
|
MetaFrameFlags flags;
|
|
|
|
MetaFrameType type;
|
|
|
|
MetaFrameStyle *style;
|
2002-02-09 12:02:38 -05:00
|
|
|
|
|
|
|
g_return_if_fail (GTK_WIDGET_REALIZED (frames));
|
|
|
|
|
|
|
|
widget = GTK_WIDGET (frames);
|
2002-02-14 21:32:48 -05:00
|
|
|
|
|
|
|
flags = meta_core_get_frame_flags (gdk_display, frame->xwindow);
|
|
|
|
type = meta_core_get_frame_type (gdk_display, frame->xwindow);
|
|
|
|
|
|
|
|
style = meta_theme_get_frame_style (meta_theme_get_current (),
|
|
|
|
type, flags);
|
|
|
|
|
|
|
|
if (style != frame->cache_style)
|
|
|
|
{
|
|
|
|
if (frame->layout)
|
|
|
|
{
|
|
|
|
/* save title to recreate layout */
|
|
|
|
g_free (frame->title);
|
|
|
|
|
|
|
|
frame->title = g_strdup (pango_layout_get_text (frame->layout));
|
|
|
|
|
|
|
|
g_object_unref (G_OBJECT (frame->layout));
|
|
|
|
frame->layout = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
frame->cache_style = style;
|
2002-02-09 12:02:38 -05:00
|
|
|
|
|
|
|
if (frame->layout == NULL)
|
|
|
|
{
|
|
|
|
gpointer key, value;
|
|
|
|
PangoFontDescription *font_desc;
|
|
|
|
double scale;
|
|
|
|
int size;
|
|
|
|
|
|
|
|
scale = meta_theme_get_title_scale (meta_theme_get_current (),
|
|
|
|
type,
|
|
|
|
flags);
|
|
|
|
|
|
|
|
frame->layout = gtk_widget_create_pango_layout (widget, frame->title);
|
2002-02-14 21:32:48 -05:00
|
|
|
|
2002-05-23 22:55:54 -04:00
|
|
|
font_desc = meta_gtk_widget_get_font_desc (widget, scale,
|
|
|
|
meta_prefs_get_titlebar_font ());
|
2002-02-09 12:02:38 -05:00
|
|
|
|
|
|
|
size = pango_font_description_get_size (font_desc);
|
|
|
|
|
|
|
|
if (g_hash_table_lookup_extended (frames->text_heights,
|
|
|
|
&size,
|
|
|
|
&key, &value))
|
|
|
|
{
|
|
|
|
frame->text_height = GPOINTER_TO_INT (value);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
frame->text_height =
|
|
|
|
meta_pango_font_desc_get_text_height (font_desc,
|
|
|
|
gtk_widget_get_pango_context (widget));
|
|
|
|
|
2002-03-06 17:27:24 -05:00
|
|
|
g_hash_table_replace (frames->text_heights,
|
|
|
|
&size,
|
|
|
|
GINT_TO_POINTER (frame->text_height));
|
2002-02-09 12:02:38 -05:00
|
|
|
}
|
2002-05-23 22:55:54 -04:00
|
|
|
|
|
|
|
pango_layout_set_font_description (frame->layout,
|
|
|
|
font_desc);
|
2002-02-09 12:02:38 -05:00
|
|
|
|
|
|
|
pango_font_description_free (font_desc);
|
|
|
|
|
2002-02-14 21:32:48 -05:00
|
|
|
/* Save some RAM */
|
2002-02-09 12:02:38 -05:00
|
|
|
g_free (frame->title);
|
|
|
|
frame->title = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-06-15 00:33:21 -04:00
|
|
|
static void
|
|
|
|
meta_frames_calc_geometry (MetaFrames *frames,
|
2002-01-18 22:50:03 -05:00
|
|
|
MetaUIFrame *frame,
|
2001-06-15 00:33:21 -04:00
|
|
|
MetaFrameGeometry *fgeom)
|
|
|
|
{
|
2001-06-17 23:24:25 -04:00
|
|
|
int width, height;
|
2001-06-18 02:11:53 -04:00
|
|
|
MetaFrameFlags flags;
|
2002-02-06 22:07:56 -05:00
|
|
|
MetaFrameType type;
|
2001-06-15 00:33:21 -04:00
|
|
|
|
2002-01-18 22:50:03 -05:00
|
|
|
meta_core_get_client_size (gdk_display, frame->xwindow,
|
|
|
|
&width, &height);
|
2001-06-20 00:29:28 -04:00
|
|
|
|
2001-06-18 02:11:53 -04:00
|
|
|
flags = meta_core_get_frame_flags (gdk_display, frame->xwindow);
|
2002-02-06 22:07:56 -05:00
|
|
|
type = meta_core_get_frame_type (gdk_display, frame->xwindow);
|
2002-02-09 12:02:38 -05:00
|
|
|
|
|
|
|
meta_frames_ensure_layout (frames, frame);
|
2002-02-06 22:07:56 -05:00
|
|
|
|
|
|
|
meta_theme_calc_geometry (meta_theme_get_current (),
|
|
|
|
type,
|
2002-02-09 12:02:38 -05:00
|
|
|
frame->text_height,
|
2002-02-06 22:07:56 -05:00
|
|
|
flags,
|
|
|
|
width, height,
|
|
|
|
fgeom);
|
2001-06-12 00:38:24 -04:00
|
|
|
}
|
|
|
|
|
2001-06-18 02:11:53 -04:00
|
|
|
MetaFrames*
|
2002-05-08 12:24:28 -04:00
|
|
|
meta_frames_new (int screen_number)
|
2001-06-18 02:11:53 -04:00
|
|
|
{
|
2002-05-08 12:24:28 -04:00
|
|
|
#ifdef HAVE_GTK_MULTIHEAD
|
|
|
|
GdkScreen *screen;
|
|
|
|
|
|
|
|
screen = gdk_display_get_screen (gdk_get_default_display (),
|
|
|
|
screen_number);
|
|
|
|
|
|
|
|
return g_object_new (META_TYPE_FRAMES,
|
|
|
|
"screen", screen,
|
|
|
|
NULL);
|
|
|
|
#else
|
|
|
|
return g_object_new (META_TYPE_FRAMES,
|
|
|
|
NULL);
|
|
|
|
#endif
|
|
|
|
|
2001-06-18 02:11:53 -04:00
|
|
|
}
|
|
|
|
|
2001-06-12 00:38:24 -04:00
|
|
|
void
|
|
|
|
meta_frames_manage_window (MetaFrames *frames,
|
2001-06-15 00:33:21 -04:00
|
|
|
Window xwindow)
|
2001-06-12 00:38:24 -04:00
|
|
|
{
|
2001-06-18 02:11:53 -04:00
|
|
|
MetaUIFrame *frame;
|
2001-06-15 00:33:21 -04:00
|
|
|
|
2001-06-18 02:11:53 -04:00
|
|
|
frame = g_new (MetaUIFrame, 1);
|
2001-06-12 00:38:24 -04:00
|
|
|
|
2001-06-15 00:33:21 -04:00
|
|
|
frame->window = gdk_window_foreign_new (xwindow);
|
2001-06-12 00:38:24 -04:00
|
|
|
|
2001-06-15 00:33:21 -04:00
|
|
|
if (frame->window == NULL)
|
|
|
|
{
|
2001-06-17 15:53:45 -04:00
|
|
|
g_free (frame);
|
2001-06-17 23:24:25 -04:00
|
|
|
meta_bug ("Frame 0x%lx doesn't exist\n", xwindow);
|
2001-06-15 00:33:21 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
gdk_window_set_user_data (frame->window, frames);
|
2001-06-19 23:01:26 -04:00
|
|
|
|
2001-07-03 22:10:54 -04:00
|
|
|
/* Don't set event mask here, it's in frame.c */
|
|
|
|
|
2001-06-15 00:33:21 -04:00
|
|
|
frame->xwindow = xwindow;
|
2002-02-14 21:32:48 -05:00
|
|
|
frame->cache_style = NULL;
|
2001-06-15 00:33:21 -04:00
|
|
|
frame->layout = NULL;
|
2002-02-09 12:02:38 -05:00
|
|
|
frame->text_height = -1;
|
|
|
|
frame->title = NULL;
|
2001-08-18 21:19:54 -04:00
|
|
|
frame->expose_delayed = FALSE;
|
2002-02-12 00:01:22 -05:00
|
|
|
frame->prelit_control = META_FRAME_CONTROL_NONE;
|
2001-06-15 00:33:21 -04:00
|
|
|
|
2001-07-25 23:14:45 -04:00
|
|
|
meta_core_grab_buttons (gdk_display, frame->xwindow);
|
|
|
|
|
2002-03-06 17:27:24 -05:00
|
|
|
g_hash_table_replace (frames->frames, &frame->xwindow, frame);
|
2001-06-15 00:33:21 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_frames_unmanage_window (MetaFrames *frames,
|
|
|
|
Window xwindow)
|
|
|
|
{
|
2001-06-18 02:11:53 -04:00
|
|
|
MetaUIFrame *frame;
|
2001-06-15 00:33:21 -04:00
|
|
|
|
2001-06-30 19:17:52 -04:00
|
|
|
clear_tip (frames);
|
|
|
|
|
2001-06-15 00:33:21 -04:00
|
|
|
frame = g_hash_table_lookup (frames->frames, &xwindow);
|
|
|
|
|
|
|
|
if (frame)
|
2002-05-07 10:42:47 -04:00
|
|
|
{
|
|
|
|
/* restore the cursor */
|
|
|
|
meta_core_set_screen_cursor (gdk_display,
|
|
|
|
frame->xwindow,
|
|
|
|
META_CURSOR_DEFAULT);
|
|
|
|
|
2001-06-20 23:40:14 -04:00
|
|
|
gdk_window_set_user_data (frame->window, NULL);
|
2001-06-30 19:17:52 -04:00
|
|
|
|
|
|
|
if (frames->last_motion_frame == frame)
|
|
|
|
frames->last_motion_frame = NULL;
|
2001-06-20 23:40:14 -04:00
|
|
|
|
2001-06-15 00:33:21 -04:00
|
|
|
g_hash_table_remove (frames->frames, &frame->xwindow);
|
2001-06-20 23:40:14 -04:00
|
|
|
|
2001-06-15 00:33:21 -04:00
|
|
|
g_object_unref (G_OBJECT (frame->window));
|
|
|
|
|
|
|
|
if (frame->layout)
|
|
|
|
g_object_unref (G_OBJECT (frame->layout));
|
2002-02-09 12:02:38 -05:00
|
|
|
|
|
|
|
if (frame->title)
|
|
|
|
g_free (frame->title);
|
2001-06-15 00:33:21 -04:00
|
|
|
|
|
|
|
g_free (frame);
|
|
|
|
}
|
|
|
|
else
|
2001-06-18 02:11:53 -04:00
|
|
|
meta_warning ("Frame 0x%lx not managed, can't unmanage\n", xwindow);
|
2001-06-15 00:33:21 -04:00
|
|
|
}
|
|
|
|
|
2001-07-02 21:45:43 -04:00
|
|
|
static void
|
|
|
|
meta_frames_realize (GtkWidget *widget)
|
|
|
|
{
|
|
|
|
MetaFrames *frames;
|
|
|
|
|
|
|
|
frames = META_FRAMES (widget);
|
|
|
|
|
|
|
|
if (GTK_WIDGET_CLASS (parent_class)->realize)
|
|
|
|
GTK_WIDGET_CLASS (parent_class)->realize (widget);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_frames_unrealize (GtkWidget *widget)
|
|
|
|
{
|
|
|
|
MetaFrames *frames;
|
|
|
|
|
|
|
|
frames = META_FRAMES (widget);
|
|
|
|
|
|
|
|
if (GTK_WIDGET_CLASS (parent_class)->unrealize)
|
|
|
|
GTK_WIDGET_CLASS (parent_class)->unrealize (widget);
|
|
|
|
}
|
|
|
|
|
2001-06-18 02:11:53 -04:00
|
|
|
static MetaUIFrame*
|
2001-06-15 00:33:21 -04:00
|
|
|
meta_frames_lookup_window (MetaFrames *frames,
|
|
|
|
Window xwindow)
|
|
|
|
{
|
2001-06-18 02:11:53 -04:00
|
|
|
MetaUIFrame *frame;
|
2001-06-15 00:33:21 -04:00
|
|
|
|
|
|
|
frame = g_hash_table_lookup (frames->frames, &xwindow);
|
|
|
|
|
|
|
|
return frame;
|
|
|
|
}
|
|
|
|
|
2001-06-17 23:24:25 -04:00
|
|
|
void
|
|
|
|
meta_frames_get_geometry (MetaFrames *frames,
|
|
|
|
Window xwindow,
|
|
|
|
int *top_height, int *bottom_height,
|
|
|
|
int *left_width, int *right_width)
|
|
|
|
{
|
2002-02-06 22:07:56 -05:00
|
|
|
MetaFrameFlags flags;
|
2001-06-18 02:11:53 -04:00
|
|
|
MetaUIFrame *frame;
|
2002-02-06 22:07:56 -05:00
|
|
|
MetaFrameType type;
|
|
|
|
|
2001-06-17 23:24:25 -04:00
|
|
|
frame = meta_frames_lookup_window (frames, xwindow);
|
|
|
|
|
|
|
|
if (frame == NULL)
|
|
|
|
meta_bug ("No such frame 0x%lx\n", xwindow);
|
2002-01-18 22:50:03 -05:00
|
|
|
|
2002-02-06 22:07:56 -05:00
|
|
|
flags = meta_core_get_frame_flags (gdk_display, frame->xwindow);
|
|
|
|
type = meta_core_get_frame_type (gdk_display, frame->xwindow);
|
2001-06-17 23:24:25 -04:00
|
|
|
|
2002-02-06 22:07:56 -05:00
|
|
|
g_return_if_fail (type < META_FRAME_TYPE_LAST);
|
2002-02-09 12:02:38 -05:00
|
|
|
|
|
|
|
meta_frames_ensure_layout (frames, frame);
|
2002-02-06 22:07:56 -05:00
|
|
|
|
2002-01-18 22:50:03 -05:00
|
|
|
/* We can't get the full geometry, because that depends on
|
|
|
|
* the client window size and probably we're being called
|
|
|
|
* by the core move/resize code to decide on the client
|
|
|
|
* window size
|
|
|
|
*/
|
2002-02-06 22:07:56 -05:00
|
|
|
meta_theme_get_frame_borders (meta_theme_get_current (),
|
|
|
|
type,
|
2002-02-09 12:02:38 -05:00
|
|
|
frame->text_height,
|
2002-02-06 22:07:56 -05:00
|
|
|
flags,
|
|
|
|
top_height, bottom_height,
|
|
|
|
left_width, right_width);
|
2001-06-17 23:24:25 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_frames_reset_bg (MetaFrames *frames,
|
|
|
|
Window xwindow)
|
|
|
|
{
|
|
|
|
GtkWidget *widget;
|
2001-06-18 02:11:53 -04:00
|
|
|
MetaUIFrame *frame;
|
2001-06-17 23:24:25 -04:00
|
|
|
|
|
|
|
widget = GTK_WIDGET (frames);
|
|
|
|
|
|
|
|
frame = meta_frames_lookup_window (frames, xwindow);
|
|
|
|
|
|
|
|
gtk_style_set_background (widget->style, frame->window, GTK_STATE_NORMAL);
|
|
|
|
}
|
|
|
|
|
2002-01-27 00:27:11 -05:00
|
|
|
static void
|
|
|
|
set_background_none (Display *xdisplay,
|
|
|
|
Window xwindow)
|
|
|
|
{
|
|
|
|
XSetWindowAttributes attrs;
|
|
|
|
|
|
|
|
attrs.background_pixmap = None;
|
|
|
|
XChangeWindowAttributes (xdisplay, xwindow,
|
|
|
|
CWBackPixmap, &attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_frames_unflicker_bg (MetaFrames *frames,
|
|
|
|
Window xwindow,
|
|
|
|
int target_width,
|
|
|
|
int target_height)
|
|
|
|
{
|
|
|
|
GtkWidget *widget;
|
|
|
|
MetaUIFrame *frame;
|
|
|
|
|
|
|
|
widget = GTK_WIDGET (frames);
|
|
|
|
|
|
|
|
frame = meta_frames_lookup_window (frames, xwindow);
|
|
|
|
g_return_if_fail (frame != NULL);
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
pixmap = gdk_pixmap_new (frame->window,
|
|
|
|
width, height,
|
|
|
|
-1);
|
|
|
|
|
|
|
|
/* Oops, no way to get the background here */
|
|
|
|
|
|
|
|
meta_frames_paint_to_drawable (frames, frame, pixmap);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
set_background_none (gdk_display, frame->xwindow);
|
|
|
|
}
|
|
|
|
|
2002-05-30 20:02:54 -04:00
|
|
|
void
|
|
|
|
meta_frames_apply_shapes (MetaFrames *frames,
|
|
|
|
Window xwindow,
|
|
|
|
int new_window_width,
|
|
|
|
int new_window_height)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_SHAPE
|
|
|
|
/* Apply shapes as if window had new_window_width, new_window_height */
|
|
|
|
GtkWidget *widget;
|
|
|
|
MetaUIFrame *frame;
|
|
|
|
MetaFrameGeometry fgeom;
|
|
|
|
XRectangle xrect;
|
|
|
|
Region corners_xregion;
|
|
|
|
Region window_xregion;
|
|
|
|
|
|
|
|
widget = GTK_WIDGET (frames);
|
|
|
|
|
|
|
|
frame = meta_frames_lookup_window (frames, xwindow);
|
|
|
|
g_return_if_fail (frame != NULL);
|
|
|
|
|
|
|
|
meta_frames_calc_geometry (frames, frame, &fgeom);
|
|
|
|
|
|
|
|
if (!(fgeom.top_left_corner_rounded ||
|
|
|
|
fgeom.top_right_corner_rounded ||
|
|
|
|
fgeom.bottom_left_corner_rounded ||
|
|
|
|
fgeom.bottom_right_corner_rounded))
|
|
|
|
{
|
|
|
|
XShapeCombineMask (gdk_display, frame->xwindow,
|
|
|
|
ShapeBounding, 0, 0, None, ShapeSet);
|
|
|
|
|
|
|
|
return; /* nothing to do */
|
|
|
|
}
|
|
|
|
|
|
|
|
corners_xregion = XCreateRegion ();
|
|
|
|
|
|
|
|
if (fgeom.top_left_corner_rounded)
|
|
|
|
{
|
|
|
|
xrect.x = 0;
|
|
|
|
xrect.y = 0;
|
|
|
|
xrect.width = 5;
|
|
|
|
xrect.height = 1;
|
|
|
|
|
|
|
|
XUnionRectWithRegion (&xrect, corners_xregion, corners_xregion);
|
|
|
|
|
|
|
|
xrect.y = 1;
|
|
|
|
xrect.width = 3;
|
|
|
|
XUnionRectWithRegion (&xrect, corners_xregion, corners_xregion);
|
|
|
|
|
|
|
|
xrect.y = 2;
|
|
|
|
xrect.width = 2;
|
|
|
|
XUnionRectWithRegion (&xrect, corners_xregion, corners_xregion);
|
|
|
|
|
|
|
|
xrect.y = 3;
|
|
|
|
xrect.width = 1;
|
|
|
|
xrect.height = 2;
|
|
|
|
XUnionRectWithRegion (&xrect, corners_xregion, corners_xregion);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fgeom.top_right_corner_rounded)
|
|
|
|
{
|
|
|
|
xrect.x = new_window_width - 5;
|
|
|
|
xrect.y = 0;
|
|
|
|
xrect.width = 5;
|
|
|
|
xrect.height = 1;
|
|
|
|
|
|
|
|
XUnionRectWithRegion (&xrect, corners_xregion, corners_xregion);
|
|
|
|
|
|
|
|
xrect.y = 1;
|
|
|
|
xrect.x = new_window_width - 3;
|
|
|
|
xrect.width = 3;
|
|
|
|
XUnionRectWithRegion (&xrect, corners_xregion, corners_xregion);
|
|
|
|
|
|
|
|
xrect.y = 2;
|
|
|
|
xrect.x = new_window_width - 2;
|
|
|
|
xrect.width = 2;
|
|
|
|
XUnionRectWithRegion (&xrect, corners_xregion, corners_xregion);
|
|
|
|
|
|
|
|
xrect.y = 3;
|
|
|
|
xrect.x = new_window_width - 1;
|
|
|
|
xrect.width = 1;
|
|
|
|
xrect.height = 2;
|
|
|
|
XUnionRectWithRegion (&xrect, corners_xregion, corners_xregion);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fgeom.bottom_left_corner_rounded)
|
|
|
|
{
|
|
|
|
xrect.x = 0;
|
|
|
|
xrect.y = new_window_height - 1;
|
|
|
|
xrect.width = 5;
|
|
|
|
xrect.height = 1;
|
|
|
|
|
|
|
|
XUnionRectWithRegion (&xrect, corners_xregion, corners_xregion);
|
|
|
|
|
|
|
|
xrect.y = new_window_height - 2;
|
|
|
|
xrect.width = 3;
|
|
|
|
XUnionRectWithRegion (&xrect, corners_xregion, corners_xregion);
|
|
|
|
|
|
|
|
xrect.y = new_window_height - 3;
|
|
|
|
xrect.width = 2;
|
|
|
|
XUnionRectWithRegion (&xrect, corners_xregion, corners_xregion);
|
|
|
|
|
|
|
|
xrect.y = new_window_height - 5;
|
|
|
|
xrect.width = 1;
|
|
|
|
xrect.height = 2;
|
|
|
|
XUnionRectWithRegion (&xrect, corners_xregion, corners_xregion);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fgeom.bottom_right_corner_rounded)
|
|
|
|
{
|
|
|
|
xrect.x = new_window_width - 5;
|
|
|
|
xrect.y = new_window_height - 1;
|
|
|
|
xrect.width = 5;
|
|
|
|
xrect.height = 1;
|
|
|
|
|
|
|
|
XUnionRectWithRegion (&xrect, corners_xregion, corners_xregion);
|
|
|
|
|
|
|
|
xrect.y = new_window_height - 2;
|
|
|
|
xrect.x = new_window_width - 3;
|
|
|
|
xrect.width = 3;
|
|
|
|
XUnionRectWithRegion (&xrect, corners_xregion, corners_xregion);
|
|
|
|
|
|
|
|
xrect.y = new_window_height - 3;
|
|
|
|
xrect.x = new_window_width - 2;
|
|
|
|
xrect.width = 2;
|
|
|
|
XUnionRectWithRegion (&xrect, corners_xregion, corners_xregion);
|
|
|
|
|
|
|
|
xrect.y = new_window_height - 5;
|
|
|
|
xrect.x = new_window_width - 1;
|
|
|
|
xrect.width = 1;
|
|
|
|
xrect.height = 2;
|
|
|
|
XUnionRectWithRegion (&xrect, corners_xregion, corners_xregion);
|
|
|
|
}
|
|
|
|
|
|
|
|
window_xregion = XCreateRegion ();
|
|
|
|
|
|
|
|
xrect.x = 0;
|
|
|
|
xrect.y = 0;
|
|
|
|
xrect.width = new_window_width;
|
|
|
|
xrect.height = new_window_height;
|
|
|
|
|
|
|
|
XUnionRectWithRegion (&xrect, window_xregion, window_xregion);
|
|
|
|
|
|
|
|
XSubtractRegion (window_xregion, corners_xregion, window_xregion);
|
|
|
|
|
|
|
|
XShapeCombineRegion (gdk_display, frame->xwindow,
|
|
|
|
ShapeBounding, 0, 0, window_xregion, ShapeSet);
|
|
|
|
|
|
|
|
XDestroyRegion (window_xregion);
|
|
|
|
XDestroyRegion (corners_xregion);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2001-06-17 23:24:25 -04:00
|
|
|
void
|
|
|
|
meta_frames_queue_draw (MetaFrames *frames,
|
|
|
|
Window xwindow)
|
|
|
|
{
|
|
|
|
GtkWidget *widget;
|
2001-06-18 02:11:53 -04:00
|
|
|
MetaUIFrame *frame;
|
2001-06-17 23:24:25 -04:00
|
|
|
|
|
|
|
widget = GTK_WIDGET (frames);
|
|
|
|
|
|
|
|
frame = meta_frames_lookup_window (frames, xwindow);
|
|
|
|
|
|
|
|
gdk_window_invalidate_rect (frame->window, NULL, FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_frames_set_title (MetaFrames *frames,
|
|
|
|
Window xwindow,
|
|
|
|
const char *title)
|
|
|
|
{
|
|
|
|
GtkWidget *widget;
|
2001-06-18 02:11:53 -04:00
|
|
|
MetaUIFrame *frame;
|
2001-06-17 23:24:25 -04:00
|
|
|
|
|
|
|
widget = GTK_WIDGET (frames);
|
|
|
|
|
|
|
|
frame = meta_frames_lookup_window (frames, xwindow);
|
2002-02-09 12:02:38 -05:00
|
|
|
|
2002-05-09 18:34:00 -04:00
|
|
|
g_assert (frame);
|
|
|
|
|
2002-02-09 12:02:38 -05:00
|
|
|
g_free (frame->title);
|
|
|
|
frame->title = g_strdup (title);
|
2001-06-17 23:24:25 -04:00
|
|
|
|
2002-02-09 12:02:38 -05:00
|
|
|
if (frame->layout)
|
|
|
|
{
|
|
|
|
g_object_unref (frame->layout);
|
|
|
|
frame->layout = NULL;
|
|
|
|
}
|
2001-06-18 02:11:53 -04:00
|
|
|
|
2001-06-17 23:24:25 -04:00
|
|
|
gdk_window_invalidate_rect (frame->window, NULL, FALSE);
|
|
|
|
}
|
|
|
|
|
2002-05-09 18:34:00 -04:00
|
|
|
void
|
|
|
|
meta_frames_repaint_frame (MetaFrames *frames,
|
|
|
|
Window xwindow)
|
|
|
|
{
|
|
|
|
GtkWidget *widget;
|
|
|
|
MetaUIFrame *frame;
|
|
|
|
|
|
|
|
widget = GTK_WIDGET (frames);
|
|
|
|
|
|
|
|
frame = meta_frames_lookup_window (frames, xwindow);
|
|
|
|
|
|
|
|
g_assert (frame);
|
|
|
|
|
|
|
|
gdk_window_process_updates (frame->window, TRUE);
|
|
|
|
}
|
2001-06-30 19:17:52 -04:00
|
|
|
|
|
|
|
static void
|
|
|
|
show_tip_now (MetaFrames *frames)
|
|
|
|
{
|
|
|
|
const char *tiptext;
|
|
|
|
MetaUIFrame *frame;
|
|
|
|
int x, y, root_x, root_y;
|
|
|
|
Window root, child;
|
|
|
|
guint mask;
|
|
|
|
MetaFrameControl control;
|
|
|
|
|
|
|
|
frame = frames->last_motion_frame;
|
|
|
|
if (frame == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
XQueryPointer (gdk_display,
|
|
|
|
frame->xwindow,
|
|
|
|
&root, &child,
|
|
|
|
&root_x, &root_y,
|
|
|
|
&x, &y,
|
|
|
|
&mask);
|
|
|
|
|
|
|
|
control = get_control (frames, frame, x, y);
|
|
|
|
|
|
|
|
tiptext = NULL;
|
|
|
|
switch (control)
|
|
|
|
{
|
|
|
|
case META_FRAME_CONTROL_TITLE:
|
|
|
|
break;
|
|
|
|
case META_FRAME_CONTROL_DELETE:
|
|
|
|
tiptext = _("Close Window");
|
|
|
|
break;
|
|
|
|
case META_FRAME_CONTROL_MENU:
|
|
|
|
tiptext = _("Window Menu");
|
|
|
|
break;
|
|
|
|
case META_FRAME_CONTROL_MINIMIZE:
|
|
|
|
tiptext = _("Minimize Window");
|
|
|
|
break;
|
|
|
|
case META_FRAME_CONTROL_MAXIMIZE:
|
|
|
|
tiptext = _("Maximize Window");
|
|
|
|
break;
|
2001-09-10 23:54:54 -04:00
|
|
|
case META_FRAME_CONTROL_UNMAXIMIZE:
|
|
|
|
tiptext = _("Unmaximize Window");
|
|
|
|
break;
|
2001-06-30 19:17:52 -04:00
|
|
|
case META_FRAME_CONTROL_RESIZE_SE:
|
|
|
|
break;
|
|
|
|
case META_FRAME_CONTROL_RESIZE_S:
|
|
|
|
break;
|
|
|
|
case META_FRAME_CONTROL_RESIZE_SW:
|
|
|
|
break;
|
|
|
|
case META_FRAME_CONTROL_RESIZE_N:
|
|
|
|
break;
|
|
|
|
case META_FRAME_CONTROL_RESIZE_NE:
|
|
|
|
break;
|
|
|
|
case META_FRAME_CONTROL_RESIZE_NW:
|
|
|
|
break;
|
|
|
|
case META_FRAME_CONTROL_RESIZE_W:
|
|
|
|
break;
|
|
|
|
case META_FRAME_CONTROL_RESIZE_E:
|
|
|
|
break;
|
2001-10-14 00:11:42 -04:00
|
|
|
case META_FRAME_CONTROL_NONE:
|
|
|
|
break;
|
|
|
|
case META_FRAME_CONTROL_CLIENT_AREA:
|
2001-06-30 19:17:52 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tiptext)
|
|
|
|
{
|
|
|
|
MetaFrameGeometry fgeom;
|
|
|
|
GdkRectangle *rect;
|
|
|
|
int dx, dy;
|
2002-05-08 12:24:28 -04:00
|
|
|
int screen_number;
|
2001-06-30 19:17:52 -04:00
|
|
|
|
|
|
|
meta_frames_calc_geometry (frames, frame, &fgeom);
|
|
|
|
|
|
|
|
rect = control_rect (control, &fgeom);
|
|
|
|
|
|
|
|
/* get conversion delta for root-to-frame coords */
|
|
|
|
dx = root_x - x;
|
|
|
|
dy = root_y - y;
|
2002-05-08 12:24:28 -04:00
|
|
|
#ifdef HAVE_GTK_MULTIHEAD
|
|
|
|
screen_number = gdk_screen_get_number (gtk_widget_get_screen (GTK_WIDGET (frames)));
|
|
|
|
#else
|
2002-05-09 18:34:00 -04:00
|
|
|
screen_number = DefaultScreen (gdk_display);
|
2002-05-08 12:24:28 -04:00
|
|
|
#endif
|
2001-06-30 19:17:52 -04:00
|
|
|
meta_fixed_tip_show (gdk_display,
|
2002-05-08 12:24:28 -04:00
|
|
|
screen_number,
|
2001-06-30 19:17:52 -04:00
|
|
|
rect->x + dx,
|
|
|
|
rect->y + rect->height + 2 + dy,
|
|
|
|
tiptext);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
tip_timeout_func (gpointer data)
|
|
|
|
{
|
|
|
|
MetaFrames *frames;
|
|
|
|
|
|
|
|
frames = data;
|
|
|
|
|
|
|
|
show_tip_now (frames);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define TIP_DELAY 450
|
|
|
|
static void
|
|
|
|
queue_tip (MetaFrames *frames)
|
|
|
|
{
|
|
|
|
clear_tip (frames);
|
|
|
|
|
|
|
|
frames->tooltip_timeout = g_timeout_add (TIP_DELAY,
|
|
|
|
tip_timeout_func,
|
|
|
|
frames);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clear_tip (MetaFrames *frames)
|
|
|
|
{
|
|
|
|
if (frames->tooltip_timeout)
|
|
|
|
{
|
|
|
|
g_source_remove (frames->tooltip_timeout);
|
|
|
|
frames->tooltip_timeout = 0;
|
|
|
|
}
|
|
|
|
meta_fixed_tip_hide ();
|
|
|
|
}
|
|
|
|
|
2001-06-20 23:40:14 -04:00
|
|
|
static void
|
|
|
|
redraw_control (MetaFrames *frames,
|
|
|
|
MetaUIFrame *frame,
|
|
|
|
MetaFrameControl control)
|
|
|
|
{
|
|
|
|
MetaFrameGeometry fgeom;
|
|
|
|
GdkRectangle *rect;
|
|
|
|
|
|
|
|
meta_frames_calc_geometry (frames, frame, &fgeom);
|
|
|
|
|
|
|
|
rect = control_rect (control, &fgeom);
|
|
|
|
|
|
|
|
gdk_window_invalidate_rect (frame->window, rect, FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
point_in_control (MetaFrames *frames,
|
|
|
|
MetaUIFrame *frame,
|
|
|
|
MetaFrameControl control,
|
|
|
|
int x, int y)
|
|
|
|
{
|
|
|
|
return control == get_control (frames, frame, x, y);
|
|
|
|
}
|
|
|
|
|
2001-07-02 21:45:43 -04:00
|
|
|
static gboolean
|
2001-06-15 00:33:21 -04:00
|
|
|
meta_frames_button_press_event (GtkWidget *widget,
|
|
|
|
GdkEventButton *event)
|
|
|
|
{
|
2001-06-18 02:11:53 -04:00
|
|
|
MetaUIFrame *frame;
|
2001-06-15 00:33:21 -04:00
|
|
|
MetaFrames *frames;
|
2001-06-20 00:29:28 -04:00
|
|
|
MetaFrameControl control;
|
|
|
|
|
2001-06-15 00:33:21 -04:00
|
|
|
frames = META_FRAMES (widget);
|
2001-07-25 23:14:45 -04:00
|
|
|
|
|
|
|
/* Remember that the display may have already done something with this event.
|
|
|
|
* If so there's probably a GrabOp in effect.
|
|
|
|
*/
|
2001-06-20 00:29:28 -04:00
|
|
|
|
2001-06-15 00:33:21 -04:00
|
|
|
frame = meta_frames_lookup_window (frames, GDK_WINDOW_XID (event->window));
|
|
|
|
if (frame == NULL)
|
|
|
|
return FALSE;
|
2001-06-30 19:17:52 -04:00
|
|
|
|
|
|
|
clear_tip (frames);
|
2001-06-20 00:29:28 -04:00
|
|
|
|
|
|
|
control = get_control (frames, frame, event->x, event->y);
|
2001-06-20 23:40:14 -04:00
|
|
|
|
2001-10-14 00:11:42 -04:00
|
|
|
if (control == META_FRAME_CONTROL_CLIENT_AREA)
|
|
|
|
return FALSE; /* not on the frame, just passed through from client */
|
2001-10-14 23:39:41 -04:00
|
|
|
|
|
|
|
if (event->button == 1)
|
|
|
|
{
|
|
|
|
meta_core_user_raise (gdk_display,
|
|
|
|
frame->xwindow);
|
2002-01-03 18:28:19 -05:00
|
|
|
meta_topic (META_DEBUG_FOCUS,
|
2002-01-05 22:15:49 -05:00
|
|
|
"Focusing window with frame 0x%lx due to button 1 press\n",
|
2002-01-03 18:28:19 -05:00
|
|
|
frame->xwindow);
|
2001-10-14 23:39:41 -04:00
|
|
|
meta_core_user_focus (gdk_display,
|
|
|
|
frame->xwindow,
|
|
|
|
event->time);
|
|
|
|
}
|
2001-10-14 00:11:42 -04:00
|
|
|
|
2001-07-25 23:14:45 -04:00
|
|
|
/* We want to shade even if we have a GrabOp, since we'll have a move grab
|
|
|
|
* if we double click the titlebar.
|
|
|
|
*/
|
2001-06-21 02:08:35 -04:00
|
|
|
if (control == META_FRAME_CONTROL_TITLE &&
|
|
|
|
event->button == 1 &&
|
|
|
|
event->type == GDK_2BUTTON_PRESS)
|
|
|
|
{
|
|
|
|
MetaFrameFlags flags;
|
|
|
|
|
|
|
|
flags = meta_core_get_frame_flags (gdk_display, frame->xwindow);
|
|
|
|
|
2001-06-23 02:54:28 -04:00
|
|
|
if (flags & META_FRAME_ALLOWS_SHADE)
|
|
|
|
{
|
|
|
|
if (flags & META_FRAME_SHADED)
|
|
|
|
meta_core_unshade (gdk_display,
|
|
|
|
frame->xwindow);
|
|
|
|
else
|
|
|
|
meta_core_shade (gdk_display,
|
|
|
|
frame->xwindow);
|
|
|
|
}
|
2001-06-21 02:08:35 -04:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2001-07-25 23:14:45 -04:00
|
|
|
if (meta_core_get_grab_op (gdk_display) !=
|
|
|
|
META_GRAB_OP_NONE)
|
|
|
|
return FALSE; /* already up to something */
|
2001-06-20 23:40:14 -04:00
|
|
|
|
|
|
|
if (event->button == 1 &&
|
|
|
|
(control == META_FRAME_CONTROL_MAXIMIZE ||
|
2001-09-10 23:54:54 -04:00
|
|
|
control == META_FRAME_CONTROL_UNMAXIMIZE ||
|
2001-06-20 23:40:14 -04:00
|
|
|
control == META_FRAME_CONTROL_MINIMIZE ||
|
|
|
|
control == META_FRAME_CONTROL_DELETE ||
|
|
|
|
control == META_FRAME_CONTROL_MENU))
|
|
|
|
{
|
2001-07-25 23:14:45 -04:00
|
|
|
MetaGrabOp op = META_GRAB_OP_NONE;
|
2001-06-20 23:40:14 -04:00
|
|
|
|
|
|
|
switch (control)
|
|
|
|
{
|
|
|
|
case META_FRAME_CONTROL_MINIMIZE:
|
2001-07-25 23:14:45 -04:00
|
|
|
op = META_GRAB_OP_CLICKING_MINIMIZE;
|
2001-06-20 23:40:14 -04:00
|
|
|
break;
|
|
|
|
case META_FRAME_CONTROL_MAXIMIZE:
|
2001-07-25 23:14:45 -04:00
|
|
|
op = META_GRAB_OP_CLICKING_MAXIMIZE;
|
2001-06-20 23:40:14 -04:00
|
|
|
break;
|
2001-09-10 23:54:54 -04:00
|
|
|
case META_FRAME_CONTROL_UNMAXIMIZE:
|
|
|
|
op = META_GRAB_OP_CLICKING_UNMAXIMIZE;
|
|
|
|
break;
|
2001-06-20 23:40:14 -04:00
|
|
|
case META_FRAME_CONTROL_DELETE:
|
2001-07-25 23:14:45 -04:00
|
|
|
op = META_GRAB_OP_CLICKING_DELETE;
|
2001-06-20 23:40:14 -04:00
|
|
|
break;
|
|
|
|
case META_FRAME_CONTROL_MENU:
|
2001-07-25 23:14:45 -04:00
|
|
|
op = META_GRAB_OP_CLICKING_MENU;
|
2001-06-20 23:40:14 -04:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2001-07-25 23:14:45 -04:00
|
|
|
meta_core_begin_grab_op (gdk_display,
|
|
|
|
frame->xwindow,
|
|
|
|
op,
|
|
|
|
TRUE,
|
|
|
|
event->button,
|
|
|
|
0,
|
|
|
|
event->time,
|
|
|
|
event->x_root,
|
|
|
|
event->y_root);
|
2001-07-03 22:10:54 -04:00
|
|
|
|
2001-06-20 23:40:14 -04:00
|
|
|
redraw_control (frames, frame, control);
|
2001-06-21 01:23:24 -04:00
|
|
|
|
2001-07-25 23:14:45 -04:00
|
|
|
if (op == META_GRAB_OP_CLICKING_MENU)
|
2001-06-21 01:23:24 -04:00
|
|
|
{
|
2001-06-30 19:17:52 -04:00
|
|
|
MetaFrameGeometry fgeom;
|
|
|
|
GdkRectangle *rect;
|
|
|
|
int dx, dy;
|
|
|
|
|
|
|
|
meta_frames_calc_geometry (frames, frame, &fgeom);
|
|
|
|
|
|
|
|
rect = control_rect (META_FRAME_CONTROL_MENU, &fgeom);
|
|
|
|
|
|
|
|
/* get delta to convert to root coords */
|
|
|
|
dx = event->x_root - event->x;
|
|
|
|
dy = event->y_root - event->y;
|
|
|
|
|
2001-06-23 01:49:35 -04:00
|
|
|
meta_core_show_window_menu (gdk_display,
|
|
|
|
frame->xwindow,
|
2001-06-30 19:17:52 -04:00
|
|
|
rect->x + dx,
|
|
|
|
rect->y + rect->height + dy,
|
2001-06-23 01:49:35 -04:00
|
|
|
event->button,
|
|
|
|
event->time);
|
2001-06-21 01:23:24 -04:00
|
|
|
}
|
2001-06-20 23:40:14 -04:00
|
|
|
}
|
2001-06-30 19:17:52 -04:00
|
|
|
else if (event->button == 1 &&
|
|
|
|
(control == META_FRAME_CONTROL_RESIZE_SE ||
|
|
|
|
control == META_FRAME_CONTROL_RESIZE_S ||
|
|
|
|
control == META_FRAME_CONTROL_RESIZE_SW ||
|
|
|
|
control == META_FRAME_CONTROL_RESIZE_NE ||
|
|
|
|
control == META_FRAME_CONTROL_RESIZE_N ||
|
|
|
|
control == META_FRAME_CONTROL_RESIZE_NW ||
|
|
|
|
control == META_FRAME_CONTROL_RESIZE_E ||
|
|
|
|
control == META_FRAME_CONTROL_RESIZE_W))
|
2001-06-20 23:40:14 -04:00
|
|
|
{
|
2001-07-25 23:14:45 -04:00
|
|
|
MetaGrabOp op;
|
2001-07-02 21:45:43 -04:00
|
|
|
|
2001-07-25 23:14:45 -04:00
|
|
|
op = META_GRAB_OP_NONE;
|
2001-07-02 21:45:43 -04:00
|
|
|
|
|
|
|
switch (control)
|
|
|
|
{
|
|
|
|
case META_FRAME_CONTROL_RESIZE_SE:
|
2001-07-25 23:14:45 -04:00
|
|
|
op = META_GRAB_OP_RESIZING_SE;
|
2001-07-02 21:45:43 -04:00
|
|
|
break;
|
|
|
|
case META_FRAME_CONTROL_RESIZE_S:
|
2001-07-25 23:14:45 -04:00
|
|
|
op = META_GRAB_OP_RESIZING_S;
|
2001-07-02 21:45:43 -04:00
|
|
|
break;
|
|
|
|
case META_FRAME_CONTROL_RESIZE_SW:
|
2001-07-25 23:14:45 -04:00
|
|
|
op = META_GRAB_OP_RESIZING_SW;
|
2001-07-02 21:45:43 -04:00
|
|
|
break;
|
|
|
|
case META_FRAME_CONTROL_RESIZE_NE:
|
2001-07-25 23:14:45 -04:00
|
|
|
op = META_GRAB_OP_RESIZING_NE;
|
2001-07-02 21:45:43 -04:00
|
|
|
break;
|
|
|
|
case META_FRAME_CONTROL_RESIZE_N:
|
2001-07-25 23:14:45 -04:00
|
|
|
op = META_GRAB_OP_RESIZING_N;
|
2001-07-02 21:45:43 -04:00
|
|
|
break;
|
|
|
|
case META_FRAME_CONTROL_RESIZE_NW:
|
2001-07-25 23:14:45 -04:00
|
|
|
op = META_GRAB_OP_RESIZING_NW;
|
2001-07-02 21:45:43 -04:00
|
|
|
break;
|
|
|
|
case META_FRAME_CONTROL_RESIZE_E:
|
2001-07-25 23:14:45 -04:00
|
|
|
op = META_GRAB_OP_RESIZING_E;
|
2001-07-02 21:45:43 -04:00
|
|
|
break;
|
|
|
|
case META_FRAME_CONTROL_RESIZE_W:
|
2001-07-25 23:14:45 -04:00
|
|
|
op = META_GRAB_OP_RESIZING_W;
|
2001-07-02 21:45:43 -04:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
break;
|
2001-06-23 14:30:27 -04:00
|
|
|
}
|
2001-07-25 23:14:45 -04:00
|
|
|
|
|
|
|
meta_core_begin_grab_op (gdk_display,
|
|
|
|
frame->xwindow,
|
|
|
|
op,
|
|
|
|
TRUE,
|
|
|
|
event->button,
|
|
|
|
0,
|
|
|
|
event->time,
|
|
|
|
event->x_root,
|
|
|
|
event->y_root);
|
2001-06-20 23:40:14 -04:00
|
|
|
}
|
2001-07-25 23:58:24 -04:00
|
|
|
else if ((control == META_FRAME_CONTROL_TITLE ||
|
|
|
|
control == META_FRAME_CONTROL_NONE) &&
|
|
|
|
event->button == 1)
|
2001-06-20 00:29:28 -04:00
|
|
|
{
|
2001-06-23 14:30:27 -04:00
|
|
|
MetaFrameFlags flags;
|
2001-06-20 00:29:28 -04:00
|
|
|
|
2001-06-23 14:30:27 -04:00
|
|
|
flags = meta_core_get_frame_flags (gdk_display, frame->xwindow);
|
|
|
|
|
|
|
|
if (flags & META_FRAME_ALLOWS_MOVE)
|
2001-07-25 23:14:45 -04:00
|
|
|
{
|
|
|
|
meta_core_begin_grab_op (gdk_display,
|
|
|
|
frame->xwindow,
|
|
|
|
META_GRAB_OP_MOVING,
|
|
|
|
TRUE,
|
|
|
|
event->button,
|
|
|
|
0,
|
|
|
|
event->time,
|
|
|
|
event->x_root,
|
|
|
|
event->y_root);
|
2001-06-23 14:30:27 -04:00
|
|
|
}
|
2001-06-20 00:29:28 -04:00
|
|
|
}
|
2001-07-03 22:10:54 -04:00
|
|
|
else if (event->button == 3)
|
|
|
|
{
|
|
|
|
meta_core_show_window_menu (gdk_display,
|
|
|
|
frame->xwindow,
|
|
|
|
event->x_root,
|
|
|
|
event->y_root,
|
|
|
|
event->button,
|
2001-07-25 23:14:45 -04:00
|
|
|
event->time);
|
2001-07-03 22:10:54 -04:00
|
|
|
}
|
2001-06-20 00:29:28 -04:00
|
|
|
|
2001-06-15 00:33:21 -04:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2001-06-21 01:23:24 -04:00
|
|
|
void
|
|
|
|
meta_frames_notify_menu_hide (MetaFrames *frames)
|
|
|
|
{
|
2001-07-25 23:14:45 -04:00
|
|
|
if (meta_core_get_grab_op (gdk_display) ==
|
|
|
|
META_GRAB_OP_CLICKING_MENU)
|
2001-06-21 01:23:24 -04:00
|
|
|
{
|
2001-07-25 23:14:45 -04:00
|
|
|
Window grab_frame;
|
|
|
|
|
|
|
|
grab_frame = meta_core_get_grab_frame (gdk_display);
|
|
|
|
|
|
|
|
if (grab_frame != None)
|
|
|
|
{
|
|
|
|
MetaUIFrame *frame;
|
|
|
|
|
|
|
|
frame = meta_frames_lookup_window (frames, grab_frame);
|
|
|
|
|
|
|
|
if (frame)
|
|
|
|
{
|
|
|
|
redraw_control (frames, frame,
|
|
|
|
META_FRAME_CONTROL_MENU);
|
|
|
|
meta_core_end_grab_op (gdk_display, CurrentTime);
|
|
|
|
}
|
|
|
|
}
|
2001-06-21 01:23:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-07-02 21:45:43 -04:00
|
|
|
static gboolean
|
2001-06-15 00:33:21 -04:00
|
|
|
meta_frames_button_release_event (GtkWidget *widget,
|
|
|
|
GdkEventButton *event)
|
|
|
|
{
|
2001-06-18 02:11:53 -04:00
|
|
|
MetaUIFrame *frame;
|
2001-06-15 00:33:21 -04:00
|
|
|
MetaFrames *frames;
|
2001-07-25 23:14:45 -04:00
|
|
|
MetaGrabOp op;
|
|
|
|
|
2001-06-15 00:33:21 -04:00
|
|
|
frames = META_FRAMES (widget);
|
2001-06-20 00:29:28 -04:00
|
|
|
|
2001-06-15 00:33:21 -04:00
|
|
|
frame = meta_frames_lookup_window (frames, GDK_WINDOW_XID (event->window));
|
|
|
|
if (frame == NULL)
|
|
|
|
return FALSE;
|
|
|
|
|
2001-06-30 19:17:52 -04:00
|
|
|
clear_tip (frames);
|
2001-07-25 23:14:45 -04:00
|
|
|
|
|
|
|
op = meta_core_get_grab_op (gdk_display);
|
|
|
|
|
|
|
|
if (op == META_GRAB_OP_NONE)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
/* We only handle the releases we handled the presses for (things
|
|
|
|
* involving frame controls). Window ops that don't require a
|
|
|
|
* frame are handled in the Xlib part of the code, display.c/window.c
|
|
|
|
*/
|
|
|
|
if (frame->xwindow == meta_core_get_grab_frame (gdk_display) &&
|
2002-02-06 22:07:56 -05:00
|
|
|
((int) event->button) == meta_core_get_grab_button (gdk_display))
|
2001-06-20 00:29:28 -04:00
|
|
|
{
|
2001-07-25 23:14:45 -04:00
|
|
|
gboolean end_grab;
|
2001-06-20 23:40:14 -04:00
|
|
|
|
2001-07-25 23:14:45 -04:00
|
|
|
end_grab = FALSE;
|
2001-06-20 00:29:28 -04:00
|
|
|
|
2001-07-25 23:14:45 -04:00
|
|
|
switch (op)
|
2001-06-20 00:29:28 -04:00
|
|
|
{
|
2001-07-25 23:14:45 -04:00
|
|
|
case META_GRAB_OP_CLICKING_MINIMIZE:
|
2001-06-20 23:40:14 -04:00
|
|
|
if (point_in_control (frames, frame,
|
|
|
|
META_FRAME_CONTROL_MINIMIZE,
|
|
|
|
event->x, event->y))
|
|
|
|
meta_core_minimize (gdk_display, frame->xwindow);
|
|
|
|
|
|
|
|
redraw_control (frames, frame,
|
|
|
|
META_FRAME_CONTROL_MINIMIZE);
|
2001-07-25 23:14:45 -04:00
|
|
|
end_grab = TRUE;
|
2001-06-20 23:40:14 -04:00
|
|
|
break;
|
|
|
|
|
2001-07-25 23:14:45 -04:00
|
|
|
case META_GRAB_OP_CLICKING_MAXIMIZE:
|
2001-06-20 23:40:14 -04:00
|
|
|
if (point_in_control (frames, frame,
|
|
|
|
META_FRAME_CONTROL_MAXIMIZE,
|
|
|
|
event->x, event->y))
|
2001-09-10 23:54:54 -04:00
|
|
|
meta_core_maximize (gdk_display, frame->xwindow);
|
|
|
|
|
2001-06-20 23:40:14 -04:00
|
|
|
redraw_control (frames, frame,
|
|
|
|
META_FRAME_CONTROL_MAXIMIZE);
|
2001-07-25 23:14:45 -04:00
|
|
|
end_grab = TRUE;
|
2001-06-20 23:40:14 -04:00
|
|
|
break;
|
|
|
|
|
2001-09-10 23:54:54 -04:00
|
|
|
case META_GRAB_OP_CLICKING_UNMAXIMIZE:
|
|
|
|
if (point_in_control (frames, frame,
|
|
|
|
META_FRAME_CONTROL_UNMAXIMIZE,
|
|
|
|
event->x, event->y))
|
|
|
|
meta_core_unmaximize (gdk_display, frame->xwindow);
|
|
|
|
|
|
|
|
redraw_control (frames, frame,
|
|
|
|
META_FRAME_CONTROL_MAXIMIZE);
|
|
|
|
end_grab = TRUE;
|
|
|
|
break;
|
|
|
|
|
2001-07-25 23:14:45 -04:00
|
|
|
case META_GRAB_OP_CLICKING_DELETE:
|
2001-06-20 23:40:14 -04:00
|
|
|
if (point_in_control (frames, frame,
|
|
|
|
META_FRAME_CONTROL_DELETE,
|
|
|
|
event->x, event->y))
|
|
|
|
meta_core_delete (gdk_display, frame->xwindow, event->time);
|
|
|
|
redraw_control (frames, frame,
|
|
|
|
META_FRAME_CONTROL_DELETE);
|
2001-07-25 23:14:45 -04:00
|
|
|
end_grab = TRUE;
|
2001-06-20 23:40:14 -04:00
|
|
|
break;
|
|
|
|
|
2001-07-25 23:14:45 -04:00
|
|
|
case META_GRAB_OP_CLICKING_MENU:
|
2001-06-20 23:40:14 -04:00
|
|
|
redraw_control (frames, frame,
|
|
|
|
META_FRAME_CONTROL_MENU);
|
2001-07-25 23:14:45 -04:00
|
|
|
end_grab = TRUE;
|
2001-06-20 23:40:14 -04:00
|
|
|
break;
|
2001-07-25 23:14:45 -04:00
|
|
|
|
|
|
|
default:
|
2001-06-20 00:29:28 -04:00
|
|
|
break;
|
|
|
|
}
|
2001-07-25 23:14:45 -04:00
|
|
|
|
|
|
|
if (end_grab)
|
|
|
|
meta_core_end_grab_op (gdk_display, event->time);
|
2001-06-20 00:29:28 -04:00
|
|
|
}
|
|
|
|
|
2001-06-15 00:33:21 -04:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2002-02-12 00:01:22 -05:00
|
|
|
static void
|
|
|
|
meta_frames_update_prelit_control (MetaFrames *frames,
|
|
|
|
MetaUIFrame *frame,
|
|
|
|
MetaFrameControl control)
|
|
|
|
{
|
|
|
|
MetaFrameControl old_control;
|
|
|
|
|
|
|
|
/* Only prelight buttons */
|
|
|
|
if (control != META_FRAME_CONTROL_MENU &&
|
|
|
|
control != META_FRAME_CONTROL_MINIMIZE &&
|
|
|
|
control != META_FRAME_CONTROL_MAXIMIZE &&
|
|
|
|
control != META_FRAME_CONTROL_DELETE)
|
|
|
|
control = META_FRAME_CONTROL_NONE;
|
|
|
|
|
|
|
|
if (control == frame->prelit_control)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Save the old control so we can unprelight it */
|
|
|
|
old_control = frame->prelit_control;
|
|
|
|
|
|
|
|
frame->prelit_control = control;
|
|
|
|
|
|
|
|
redraw_control (frames, frame, old_control);
|
|
|
|
redraw_control (frames, frame, control);
|
|
|
|
}
|
|
|
|
|
2001-07-02 21:45:43 -04:00
|
|
|
static gboolean
|
2001-06-15 00:33:21 -04:00
|
|
|
meta_frames_motion_notify_event (GtkWidget *widget,
|
|
|
|
GdkEventMotion *event)
|
|
|
|
{
|
2001-06-18 02:11:53 -04:00
|
|
|
MetaUIFrame *frame;
|
2001-06-15 00:33:21 -04:00
|
|
|
MetaFrames *frames;
|
2001-06-20 00:29:28 -04:00
|
|
|
|
2001-06-15 00:33:21 -04:00
|
|
|
frames = META_FRAMES (widget);
|
2001-06-30 19:17:52 -04:00
|
|
|
|
2001-06-15 00:33:21 -04:00
|
|
|
frame = meta_frames_lookup_window (frames, GDK_WINDOW_XID (event->window));
|
|
|
|
if (frame == NULL)
|
|
|
|
return FALSE;
|
|
|
|
|
2001-06-30 19:17:52 -04:00
|
|
|
clear_tip (frames);
|
|
|
|
|
|
|
|
frames->last_motion_frame = frame;
|
|
|
|
|
2001-07-25 23:14:45 -04:00
|
|
|
switch (meta_core_get_grab_op (gdk_display))
|
2001-06-20 00:29:28 -04:00
|
|
|
{
|
2001-07-25 23:14:45 -04:00
|
|
|
case META_GRAB_OP_CLICKING_MENU:
|
|
|
|
case META_GRAB_OP_CLICKING_DELETE:
|
|
|
|
case META_GRAB_OP_CLICKING_MINIMIZE:
|
|
|
|
case META_GRAB_OP_CLICKING_MAXIMIZE:
|
2001-09-10 23:54:54 -04:00
|
|
|
case META_GRAB_OP_CLICKING_UNMAXIMIZE:
|
2001-06-20 23:40:14 -04:00
|
|
|
break;
|
2001-07-25 23:14:45 -04:00
|
|
|
|
|
|
|
case META_GRAB_OP_NONE:
|
2001-07-02 21:45:43 -04:00
|
|
|
{
|
|
|
|
MetaFrameControl control;
|
|
|
|
int x, y;
|
2001-07-25 23:14:45 -04:00
|
|
|
MetaCursor cursor;
|
|
|
|
|
2001-07-02 21:45:43 -04:00
|
|
|
gdk_window_get_pointer (frame->window, &x, &y, NULL);
|
|
|
|
|
|
|
|
control = get_control (frames, frame, x, y);
|
2002-02-12 00:01:22 -05:00
|
|
|
|
|
|
|
/* Update prelit control */
|
|
|
|
meta_frames_update_prelit_control (frames, frame, control);
|
|
|
|
|
2001-07-25 23:14:45 -04:00
|
|
|
cursor = META_CURSOR_DEFAULT;
|
2001-07-02 21:45:43 -04:00
|
|
|
|
|
|
|
switch (control)
|
|
|
|
{
|
2001-10-14 00:11:42 -04:00
|
|
|
case META_FRAME_CONTROL_CLIENT_AREA:
|
|
|
|
break;
|
2001-07-02 21:45:43 -04:00
|
|
|
case META_FRAME_CONTROL_NONE:
|
|
|
|
break;
|
|
|
|
case META_FRAME_CONTROL_TITLE:
|
|
|
|
break;
|
|
|
|
case META_FRAME_CONTROL_DELETE:
|
|
|
|
break;
|
|
|
|
case META_FRAME_CONTROL_MENU:
|
|
|
|
break;
|
|
|
|
case META_FRAME_CONTROL_MINIMIZE:
|
|
|
|
break;
|
|
|
|
case META_FRAME_CONTROL_MAXIMIZE:
|
|
|
|
break;
|
2001-09-10 23:54:54 -04:00
|
|
|
case META_FRAME_CONTROL_UNMAXIMIZE:
|
|
|
|
break;
|
2001-07-02 21:45:43 -04:00
|
|
|
case META_FRAME_CONTROL_RESIZE_SE:
|
2001-07-25 23:14:45 -04:00
|
|
|
cursor = META_CURSOR_SE_RESIZE;
|
2001-07-02 21:45:43 -04:00
|
|
|
break;
|
|
|
|
case META_FRAME_CONTROL_RESIZE_S:
|
2001-07-25 23:14:45 -04:00
|
|
|
cursor = META_CURSOR_SOUTH_RESIZE;
|
2001-07-02 21:45:43 -04:00
|
|
|
break;
|
|
|
|
case META_FRAME_CONTROL_RESIZE_SW:
|
2001-07-25 23:14:45 -04:00
|
|
|
cursor = META_CURSOR_SW_RESIZE;
|
2001-07-02 21:45:43 -04:00
|
|
|
break;
|
|
|
|
case META_FRAME_CONTROL_RESIZE_N:
|
2001-07-25 23:14:45 -04:00
|
|
|
cursor = META_CURSOR_NORTH_RESIZE;
|
2001-07-02 21:45:43 -04:00
|
|
|
break;
|
|
|
|
case META_FRAME_CONTROL_RESIZE_NE:
|
2001-07-25 23:14:45 -04:00
|
|
|
cursor = META_CURSOR_NE_RESIZE;
|
2001-07-02 21:45:43 -04:00
|
|
|
break;
|
|
|
|
case META_FRAME_CONTROL_RESIZE_NW:
|
2001-07-25 23:14:45 -04:00
|
|
|
cursor = META_CURSOR_NW_RESIZE;
|
2001-07-02 21:45:43 -04:00
|
|
|
break;
|
|
|
|
case META_FRAME_CONTROL_RESIZE_W:
|
2001-07-25 23:14:45 -04:00
|
|
|
cursor = META_CURSOR_WEST_RESIZE;
|
2001-07-02 21:45:43 -04:00
|
|
|
break;
|
|
|
|
case META_FRAME_CONTROL_RESIZE_E:
|
2001-07-25 23:14:45 -04:00
|
|
|
cursor = META_CURSOR_EAST_RESIZE;
|
2001-07-02 21:45:43 -04:00
|
|
|
break;
|
2001-07-25 23:14:45 -04:00
|
|
|
}
|
2001-07-02 21:45:43 -04:00
|
|
|
|
2001-07-25 23:14:45 -04:00
|
|
|
/* set/unset the prelight cursor */
|
|
|
|
meta_core_set_screen_cursor (gdk_display,
|
|
|
|
frame->xwindow,
|
|
|
|
cursor);
|
2001-07-02 21:45:43 -04:00
|
|
|
|
|
|
|
queue_tip (frames);
|
|
|
|
}
|
2001-06-20 23:40:14 -04:00
|
|
|
break;
|
2001-07-25 23:14:45 -04:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2001-06-20 00:29:28 -04:00
|
|
|
}
|
|
|
|
|
2001-06-15 00:33:21 -04:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2001-07-02 21:45:43 -04:00
|
|
|
static gboolean
|
2001-06-15 00:33:21 -04:00
|
|
|
meta_frames_destroy_event (GtkWidget *widget,
|
|
|
|
GdkEventAny *event)
|
|
|
|
{
|
2001-06-18 02:11:53 -04:00
|
|
|
MetaUIFrame *frame;
|
2001-06-15 00:33:21 -04:00
|
|
|
MetaFrames *frames;
|
|
|
|
|
|
|
|
frames = META_FRAMES (widget);
|
|
|
|
|
|
|
|
frame = meta_frames_lookup_window (frames, GDK_WINDOW_XID (event->window));
|
|
|
|
if (frame == NULL)
|
|
|
|
return FALSE;
|
2001-06-20 00:29:28 -04:00
|
|
|
|
2001-06-15 00:33:21 -04:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2001-07-02 21:45:43 -04:00
|
|
|
static gboolean
|
2002-01-27 00:27:11 -05:00
|
|
|
meta_frames_expose_event (GtkWidget *widget,
|
|
|
|
GdkEventExpose *event)
|
2001-06-15 00:33:21 -04:00
|
|
|
{
|
2001-06-18 02:11:53 -04:00
|
|
|
MetaUIFrame *frame;
|
2001-06-15 00:33:21 -04:00
|
|
|
MetaFrames *frames;
|
2002-01-27 00:27:11 -05:00
|
|
|
|
2001-06-15 00:33:21 -04:00
|
|
|
frames = META_FRAMES (widget);
|
2002-01-27 00:27:11 -05:00
|
|
|
|
2001-06-15 00:33:21 -04:00
|
|
|
frame = meta_frames_lookup_window (frames, GDK_WINDOW_XID (event->window));
|
|
|
|
if (frame == NULL)
|
|
|
|
return FALSE;
|
|
|
|
|
2001-08-18 21:19:54 -04:00
|
|
|
if (frames->expose_delay_count > 0)
|
|
|
|
{
|
|
|
|
/* Redraw this entire frame later */
|
|
|
|
frame->expose_delayed = TRUE;
|
|
|
|
return TRUE;
|
|
|
|
}
|
2002-01-27 00:27:11 -05:00
|
|
|
|
2002-05-04 20:21:17 -04:00
|
|
|
meta_frames_paint_to_drawable (frames, frame, frame->window, event->region);
|
2002-01-27 00:27:11 -05:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_frames_paint_to_drawable (MetaFrames *frames,
|
|
|
|
MetaUIFrame *frame,
|
|
|
|
GdkDrawable *drawable,
|
2002-05-04 20:21:17 -04:00
|
|
|
GdkRegion *region)
|
2002-01-27 00:27:11 -05:00
|
|
|
{
|
|
|
|
GtkWidget *widget;
|
|
|
|
MetaFrameFlags flags;
|
2002-02-06 22:07:56 -05:00
|
|
|
MetaFrameType type;
|
|
|
|
GdkPixbuf *mini_icon;
|
|
|
|
GdkPixbuf *icon;
|
|
|
|
int w, h;
|
|
|
|
MetaButtonState button_states[META_BUTTON_TYPE_LAST];
|
|
|
|
Window grab_frame;
|
|
|
|
int i;
|
2002-05-04 20:21:17 -04:00
|
|
|
int top, bottom, left, right;
|
|
|
|
GdkRegion *edges;
|
2002-05-04 20:45:01 -04:00
|
|
|
GdkRegion *tmp_region;
|
2002-05-04 20:21:17 -04:00
|
|
|
GdkRectangle area;
|
|
|
|
GdkRectangle *areas;
|
|
|
|
int n_areas;
|
2002-05-04 20:45:01 -04:00
|
|
|
int screen_width, screen_height;
|
2001-06-18 02:11:53 -04:00
|
|
|
|
2002-02-06 22:07:56 -05:00
|
|
|
widget = GTK_WIDGET (frames);
|
2001-06-18 02:11:53 -04:00
|
|
|
|
2002-02-06 22:07:56 -05:00
|
|
|
i = 0;
|
|
|
|
while (i < META_BUTTON_TYPE_LAST)
|
2001-06-18 02:11:53 -04:00
|
|
|
{
|
2002-02-06 22:07:56 -05:00
|
|
|
button_states[i] = META_BUTTON_STATE_NORMAL;
|
2001-06-18 02:11:53 -04:00
|
|
|
|
2002-02-06 22:07:56 -05:00
|
|
|
++i;
|
2001-06-18 02:11:53 -04:00
|
|
|
}
|
2002-02-12 00:01:22 -05:00
|
|
|
|
|
|
|
/* Set prelight state */
|
|
|
|
switch (frame->prelit_control)
|
|
|
|
{
|
|
|
|
case META_FRAME_CONTROL_MENU:
|
|
|
|
button_states[META_BUTTON_TYPE_MENU] = META_BUTTON_STATE_PRELIGHT;
|
|
|
|
break;
|
|
|
|
case META_FRAME_CONTROL_MINIMIZE:
|
|
|
|
button_states[META_BUTTON_TYPE_MINIMIZE] = META_BUTTON_STATE_PRELIGHT;
|
|
|
|
break;
|
|
|
|
case META_FRAME_CONTROL_MAXIMIZE:
|
|
|
|
button_states[META_BUTTON_TYPE_MAXIMIZE] = META_BUTTON_STATE_PRELIGHT;
|
|
|
|
break;
|
|
|
|
case META_FRAME_CONTROL_DELETE:
|
|
|
|
button_states[META_BUTTON_TYPE_CLOSE] = META_BUTTON_STATE_PRELIGHT;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
}
|
2001-06-18 02:11:53 -04:00
|
|
|
|
2002-02-06 22:07:56 -05:00
|
|
|
grab_frame = meta_core_get_grab_frame (gdk_display);
|
2001-06-18 02:11:53 -04:00
|
|
|
|
2002-02-06 22:07:56 -05:00
|
|
|
if (frame->xwindow == grab_frame)
|
2001-06-18 02:11:53 -04:00
|
|
|
{
|
2002-02-06 22:07:56 -05:00
|
|
|
switch (meta_core_get_grab_op (gdk_display))
|
|
|
|
{
|
|
|
|
case META_GRAB_OP_CLICKING_MENU:
|
|
|
|
button_states[META_BUTTON_TYPE_MENU] =
|
|
|
|
META_BUTTON_STATE_PRESSED;
|
|
|
|
break;
|
|
|
|
case META_GRAB_OP_CLICKING_DELETE:
|
|
|
|
button_states[META_BUTTON_TYPE_CLOSE] =
|
|
|
|
META_BUTTON_STATE_PRESSED;
|
|
|
|
break;
|
|
|
|
case META_GRAB_OP_CLICKING_MAXIMIZE:
|
|
|
|
button_states[META_BUTTON_TYPE_MAXIMIZE] =
|
|
|
|
META_BUTTON_STATE_PRESSED;
|
|
|
|
break;
|
|
|
|
case META_GRAB_OP_CLICKING_UNMAXIMIZE:
|
|
|
|
button_states[META_BUTTON_TYPE_MAXIMIZE] =
|
|
|
|
META_BUTTON_STATE_PRESSED;
|
|
|
|
break;
|
|
|
|
case META_GRAB_OP_CLICKING_MINIMIZE:
|
|
|
|
button_states[META_BUTTON_TYPE_MINIMIZE] =
|
|
|
|
META_BUTTON_STATE_PRESSED;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2001-06-18 02:11:53 -04:00
|
|
|
}
|
|
|
|
|
2002-02-06 22:07:56 -05:00
|
|
|
flags = meta_core_get_frame_flags (gdk_display, frame->xwindow);
|
|
|
|
type = meta_core_get_frame_type (gdk_display, frame->xwindow);
|
|
|
|
mini_icon = meta_core_get_mini_icon (gdk_display, frame->xwindow);
|
|
|
|
icon = meta_core_get_icon (gdk_display, frame->xwindow);
|
2001-06-18 02:11:53 -04:00
|
|
|
|
2002-02-06 22:07:56 -05:00
|
|
|
meta_core_get_client_size (gdk_display, frame->xwindow,
|
|
|
|
&w, &h);
|
2002-02-09 12:02:38 -05:00
|
|
|
|
|
|
|
meta_frames_ensure_layout (frames, frame);
|
2002-05-04 20:21:17 -04:00
|
|
|
|
|
|
|
meta_theme_get_frame_borders (meta_theme_get_current (),
|
|
|
|
type, frame->text_height, flags,
|
|
|
|
&top, &bottom, &left, &right);
|
|
|
|
|
|
|
|
/* Repaint each side of the frame */
|
|
|
|
|
|
|
|
edges = gdk_region_copy (region);
|
2002-05-04 20:45:01 -04:00
|
|
|
|
|
|
|
/* Punch out the client area */
|
2002-05-04 20:21:17 -04:00
|
|
|
area.x = left;
|
|
|
|
area.y = top;
|
|
|
|
area.width = w;
|
|
|
|
area.height = h;
|
2002-05-04 20:45:01 -04:00
|
|
|
tmp_region = gdk_region_rectangle (&area);
|
|
|
|
gdk_region_subtract (edges, tmp_region);
|
|
|
|
gdk_region_destroy (tmp_region);
|
|
|
|
|
|
|
|
/* Chop off stuff outside the screen; this optimization
|
|
|
|
* is crucial to handle huge client windows,
|
|
|
|
* like "xterm -geometry 1000x1000"
|
|
|
|
*/
|
|
|
|
meta_core_get_frame_extents (gdk_display,
|
|
|
|
frame->xwindow,
|
|
|
|
&area.x, &area.y,
|
|
|
|
&area.width, &area.height);
|
|
|
|
|
|
|
|
meta_core_get_screen_size (gdk_display,
|
|
|
|
frame->xwindow,
|
|
|
|
&screen_width, &screen_height);
|
2002-05-04 20:21:17 -04:00
|
|
|
|
2002-05-04 20:45:01 -04:00
|
|
|
if ((area.x + area.width) > screen_width)
|
|
|
|
area.width = screen_width - area.x;
|
|
|
|
if (area.width < 0)
|
|
|
|
area.width = 0;
|
|
|
|
|
|
|
|
if ((area.y + area.height) > screen_height)
|
|
|
|
area.height = screen_height - area.y;
|
|
|
|
if (area.height < 0)
|
|
|
|
area.height = 0;
|
|
|
|
|
|
|
|
area.x = 0; /* make relative to frame rather than screen */
|
|
|
|
area.y = 0;
|
|
|
|
|
|
|
|
tmp_region = gdk_region_rectangle (&area);
|
|
|
|
gdk_region_intersect (edges, tmp_region);
|
|
|
|
gdk_region_destroy (tmp_region);
|
|
|
|
|
|
|
|
/* Now draw remaining portion of region */
|
2002-05-04 20:21:17 -04:00
|
|
|
gdk_region_get_rectangles (edges, &areas, &n_areas);
|
2002-02-06 22:07:56 -05:00
|
|
|
|
2002-05-04 20:21:17 -04:00
|
|
|
i = 0;
|
|
|
|
while (i < n_areas)
|
2002-05-04 20:45:01 -04:00
|
|
|
{
|
2002-05-04 20:21:17 -04:00
|
|
|
if (GDK_IS_WINDOW (drawable))
|
|
|
|
gdk_window_begin_paint_rect (drawable, &areas[i]);
|
|
|
|
|
|
|
|
meta_theme_draw_frame (meta_theme_get_current (),
|
|
|
|
widget,
|
|
|
|
drawable,
|
|
|
|
&areas[i],
|
|
|
|
0, 0,
|
|
|
|
type,
|
|
|
|
flags,
|
|
|
|
w, h,
|
|
|
|
frame->layout,
|
|
|
|
frame->text_height,
|
|
|
|
button_states,
|
|
|
|
mini_icon, icon);
|
|
|
|
|
|
|
|
if (GDK_IS_WINDOW (drawable))
|
|
|
|
gdk_window_end_paint (drawable);
|
|
|
|
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
|
|
|
|
gdk_region_destroy (edges);
|
|
|
|
g_free (areas);
|
2001-06-15 00:33:21 -04:00
|
|
|
}
|
|
|
|
|
2001-07-02 21:45:43 -04:00
|
|
|
static gboolean
|
2001-06-15 00:33:21 -04:00
|
|
|
meta_frames_enter_notify_event (GtkWidget *widget,
|
|
|
|
GdkEventCrossing *event)
|
|
|
|
{
|
2001-06-18 02:11:53 -04:00
|
|
|
MetaUIFrame *frame;
|
2001-06-15 00:33:21 -04:00
|
|
|
MetaFrames *frames;
|
2002-02-12 00:01:22 -05:00
|
|
|
MetaFrameControl control;
|
|
|
|
|
2001-06-15 00:33:21 -04:00
|
|
|
frames = META_FRAMES (widget);
|
|
|
|
|
|
|
|
frame = meta_frames_lookup_window (frames, GDK_WINDOW_XID (event->window));
|
|
|
|
if (frame == NULL)
|
|
|
|
return FALSE;
|
|
|
|
|
2002-02-12 00:01:22 -05:00
|
|
|
control = get_control (frames, frame, event->x, event->y);
|
|
|
|
meta_frames_update_prelit_control (frames, frame, control);
|
|
|
|
|
2001-06-15 00:33:21 -04:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2001-07-02 21:45:43 -04:00
|
|
|
static gboolean
|
2001-06-15 00:33:21 -04:00
|
|
|
meta_frames_leave_notify_event (GtkWidget *widget,
|
|
|
|
GdkEventCrossing *event)
|
|
|
|
{
|
2001-06-18 02:11:53 -04:00
|
|
|
MetaUIFrame *frame;
|
2001-06-15 00:33:21 -04:00
|
|
|
MetaFrames *frames;
|
|
|
|
|
|
|
|
frames = META_FRAMES (widget);
|
|
|
|
|
|
|
|
frame = meta_frames_lookup_window (frames, GDK_WINDOW_XID (event->window));
|
|
|
|
if (frame == NULL)
|
|
|
|
return FALSE;
|
|
|
|
|
2002-02-12 00:01:22 -05:00
|
|
|
meta_frames_update_prelit_control (frames, frame, META_FRAME_CONTROL_NONE);
|
|
|
|
|
2001-07-25 23:14:45 -04:00
|
|
|
clear_tip (frames);
|
|
|
|
|
|
|
|
meta_core_set_screen_cursor (gdk_display,
|
|
|
|
frame->xwindow,
|
|
|
|
META_CURSOR_DEFAULT);
|
2002-02-12 00:01:22 -05:00
|
|
|
|
2001-06-15 00:33:21 -04:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2001-06-20 00:29:28 -04:00
|
|
|
static GdkRectangle*
|
|
|
|
control_rect (MetaFrameControl control,
|
|
|
|
MetaFrameGeometry *fgeom)
|
|
|
|
{
|
|
|
|
GdkRectangle *rect;
|
|
|
|
|
|
|
|
rect = NULL;
|
|
|
|
switch (control)
|
|
|
|
{
|
|
|
|
case META_FRAME_CONTROL_TITLE:
|
|
|
|
rect = &fgeom->title_rect;
|
|
|
|
break;
|
|
|
|
case META_FRAME_CONTROL_DELETE:
|
|
|
|
rect = &fgeom->close_rect;
|
|
|
|
break;
|
|
|
|
case META_FRAME_CONTROL_MENU:
|
|
|
|
rect = &fgeom->menu_rect;
|
|
|
|
break;
|
|
|
|
case META_FRAME_CONTROL_MINIMIZE:
|
|
|
|
rect = &fgeom->min_rect;
|
|
|
|
break;
|
|
|
|
case META_FRAME_CONTROL_MAXIMIZE:
|
2001-09-10 23:54:54 -04:00
|
|
|
case META_FRAME_CONTROL_UNMAXIMIZE:
|
2001-06-20 00:29:28 -04:00
|
|
|
rect = &fgeom->max_rect;
|
|
|
|
break;
|
|
|
|
case META_FRAME_CONTROL_RESIZE_SE:
|
|
|
|
break;
|
|
|
|
case META_FRAME_CONTROL_RESIZE_S:
|
|
|
|
break;
|
|
|
|
case META_FRAME_CONTROL_RESIZE_SW:
|
|
|
|
break;
|
|
|
|
case META_FRAME_CONTROL_RESIZE_N:
|
|
|
|
break;
|
|
|
|
case META_FRAME_CONTROL_RESIZE_NE:
|
|
|
|
break;
|
|
|
|
case META_FRAME_CONTROL_RESIZE_NW:
|
|
|
|
break;
|
|
|
|
case META_FRAME_CONTROL_RESIZE_W:
|
|
|
|
break;
|
|
|
|
case META_FRAME_CONTROL_RESIZE_E:
|
|
|
|
break;
|
|
|
|
case META_FRAME_CONTROL_NONE:
|
|
|
|
break;
|
2001-10-14 00:11:42 -04:00
|
|
|
case META_FRAME_CONTROL_CLIENT_AREA:
|
|
|
|
break;
|
2001-06-20 00:29:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return rect;
|
|
|
|
}
|
|
|
|
|
2001-06-30 19:17:52 -04:00
|
|
|
#define RESIZE_EXTENDS 15
|
2001-06-20 00:29:28 -04:00
|
|
|
static MetaFrameControl
|
|
|
|
get_control (MetaFrames *frames,
|
|
|
|
MetaUIFrame *frame,
|
|
|
|
int x, int y)
|
|
|
|
{
|
|
|
|
MetaFrameGeometry fgeom;
|
2001-07-02 21:45:43 -04:00
|
|
|
MetaFrameFlags flags;
|
|
|
|
gboolean has_vert, has_horiz;
|
|
|
|
GdkRectangle client;
|
2001-06-20 00:29:28 -04:00
|
|
|
|
|
|
|
meta_frames_calc_geometry (frames, frame, &fgeom);
|
2001-07-02 21:45:43 -04:00
|
|
|
|
|
|
|
client.x = fgeom.left_width;
|
|
|
|
client.y = fgeom.top_height;
|
|
|
|
client.width = fgeom.width - fgeom.left_width - fgeom.right_width;
|
|
|
|
client.height = fgeom.height - fgeom.top_height - fgeom.bottom_height;
|
|
|
|
|
|
|
|
if (POINT_IN_RECT (x, y, client))
|
2001-10-14 00:11:42 -04:00
|
|
|
return META_FRAME_CONTROL_CLIENT_AREA;
|
2001-06-20 00:29:28 -04:00
|
|
|
|
|
|
|
if (POINT_IN_RECT (x, y, fgeom.close_rect))
|
|
|
|
return META_FRAME_CONTROL_DELETE;
|
|
|
|
|
|
|
|
if (POINT_IN_RECT (x, y, fgeom.min_rect))
|
|
|
|
return META_FRAME_CONTROL_MINIMIZE;
|
|
|
|
|
|
|
|
if (POINT_IN_RECT (x, y, fgeom.menu_rect))
|
|
|
|
return META_FRAME_CONTROL_MENU;
|
|
|
|
|
|
|
|
if (POINT_IN_RECT (x, y, fgeom.title_rect))
|
|
|
|
return META_FRAME_CONTROL_TITLE;
|
2001-09-10 23:54:54 -04:00
|
|
|
|
2001-07-02 21:45:43 -04:00
|
|
|
flags = meta_core_get_frame_flags (gdk_display, frame->xwindow);
|
|
|
|
|
2001-09-10 23:54:54 -04:00
|
|
|
if (POINT_IN_RECT (x, y, fgeom.max_rect))
|
|
|
|
{
|
|
|
|
if (flags & META_FRAME_MAXIMIZED)
|
|
|
|
return META_FRAME_CONTROL_UNMAXIMIZE;
|
|
|
|
else
|
|
|
|
return META_FRAME_CONTROL_MAXIMIZE;
|
|
|
|
}
|
|
|
|
|
2001-07-02 21:45:43 -04:00
|
|
|
has_vert = (flags & META_FRAME_ALLOWS_VERTICAL_RESIZE) != 0;
|
|
|
|
has_horiz = (flags & META_FRAME_ALLOWS_HORIZONTAL_RESIZE) != 0;
|
|
|
|
|
|
|
|
if (has_vert || has_horiz)
|
|
|
|
{
|
2002-01-27 03:21:53 -05:00
|
|
|
int bottom_of_titlebar;
|
2002-01-19 18:59:11 -05:00
|
|
|
|
2002-01-27 03:21:53 -05:00
|
|
|
bottom_of_titlebar = fgeom.title_rect.y + fgeom.title_rect.height;
|
2002-01-19 18:59:11 -05:00
|
|
|
|
2002-01-27 03:21:53 -05:00
|
|
|
if (y < bottom_of_titlebar)
|
|
|
|
goto noresize;
|
|
|
|
|
|
|
|
/* South resize always has priority over north resize,
|
|
|
|
* in case of overlap.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (y >= (fgeom.height - fgeom.bottom_height - RESIZE_EXTENDS) &&
|
|
|
|
x >= (fgeom.width - fgeom.right_width - RESIZE_EXTENDS))
|
2001-07-02 21:45:43 -04:00
|
|
|
{
|
|
|
|
if (has_vert && has_horiz)
|
|
|
|
return META_FRAME_CONTROL_RESIZE_SE;
|
|
|
|
else if (has_vert)
|
|
|
|
return META_FRAME_CONTROL_RESIZE_S;
|
|
|
|
else
|
|
|
|
return META_FRAME_CONTROL_RESIZE_E;
|
|
|
|
}
|
|
|
|
else if (y >= (fgeom.height - fgeom.bottom_height - RESIZE_EXTENDS) &&
|
|
|
|
x <= (fgeom.left_width + RESIZE_EXTENDS))
|
|
|
|
{
|
|
|
|
if (has_vert && has_horiz)
|
|
|
|
return META_FRAME_CONTROL_RESIZE_SW;
|
|
|
|
else if (has_vert)
|
|
|
|
return META_FRAME_CONTROL_RESIZE_S;
|
|
|
|
else
|
|
|
|
return META_FRAME_CONTROL_RESIZE_W;
|
|
|
|
}
|
2002-01-27 03:21:53 -05:00
|
|
|
else if (y < (fgeom.top_height + RESIZE_EXTENDS) &&
|
|
|
|
x < RESIZE_EXTENDS)
|
2002-01-19 18:59:11 -05:00
|
|
|
{
|
2002-01-27 03:21:53 -05:00
|
|
|
if (has_vert && has_horiz)
|
|
|
|
return META_FRAME_CONTROL_RESIZE_NW;
|
|
|
|
else if (has_vert)
|
2002-01-19 18:59:11 -05:00
|
|
|
return META_FRAME_CONTROL_RESIZE_N;
|
2002-01-27 03:21:53 -05:00
|
|
|
else
|
|
|
|
return META_FRAME_CONTROL_RESIZE_W;
|
|
|
|
}
|
|
|
|
else if (y < (fgeom.top_height + RESIZE_EXTENDS) &&
|
|
|
|
x >= (fgeom.width - RESIZE_EXTENDS))
|
|
|
|
{
|
|
|
|
if (has_vert && has_horiz)
|
|
|
|
return META_FRAME_CONTROL_RESIZE_NE;
|
|
|
|
else if (has_vert)
|
|
|
|
return META_FRAME_CONTROL_RESIZE_N;
|
|
|
|
else
|
|
|
|
return META_FRAME_CONTROL_RESIZE_E;
|
2002-01-19 18:59:11 -05:00
|
|
|
}
|
2001-07-02 21:45:43 -04:00
|
|
|
else if (y >= (fgeom.height - fgeom.bottom_height - RESIZE_EXTENDS))
|
|
|
|
{
|
|
|
|
if (has_vert)
|
|
|
|
return META_FRAME_CONTROL_RESIZE_S;
|
|
|
|
}
|
2002-01-27 03:21:53 -05:00
|
|
|
else if (y >= bottom_of_titlebar && y < fgeom.top_height)
|
|
|
|
{
|
|
|
|
if (has_vert)
|
|
|
|
return META_FRAME_CONTROL_RESIZE_N;
|
|
|
|
}
|
2001-07-02 21:45:43 -04:00
|
|
|
else if (x <= fgeom.left_width)
|
|
|
|
{
|
|
|
|
if (has_horiz)
|
|
|
|
return META_FRAME_CONTROL_RESIZE_W;
|
|
|
|
}
|
|
|
|
else if (x >= (fgeom.width - fgeom.right_width))
|
|
|
|
{
|
|
|
|
if (has_horiz)
|
|
|
|
return META_FRAME_CONTROL_RESIZE_E;
|
|
|
|
}
|
|
|
|
}
|
2002-01-27 03:21:53 -05:00
|
|
|
|
|
|
|
noresize:
|
2001-06-20 00:29:28 -04:00
|
|
|
|
|
|
|
return META_FRAME_CONTROL_NONE;
|
|
|
|
}
|
2001-08-18 21:19:54 -04:00
|
|
|
|
|
|
|
void
|
|
|
|
meta_frames_push_delay_exposes (MetaFrames *frames)
|
|
|
|
{
|
|
|
|
frames->expose_delay_count += 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
queue_pending_exposes_func (gpointer key, gpointer value, gpointer data)
|
|
|
|
{
|
|
|
|
MetaUIFrame *frame;
|
|
|
|
MetaFrames *frames;
|
|
|
|
|
|
|
|
frames = META_FRAMES (data);
|
|
|
|
frame = value;
|
|
|
|
|
|
|
|
if (frame->expose_delayed)
|
|
|
|
{
|
|
|
|
gdk_window_invalidate_rect (frame->window, NULL, FALSE);
|
|
|
|
frame->expose_delayed = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_frames_pop_delay_exposes (MetaFrames *frames)
|
|
|
|
{
|
|
|
|
g_return_if_fail (frames->expose_delay_count > 0);
|
|
|
|
|
|
|
|
frames->expose_delay_count -= 1;
|
|
|
|
|
|
|
|
if (frames->expose_delay_count == 0)
|
|
|
|
{
|
|
|
|
g_hash_table_foreach (frames->frames,
|
|
|
|
queue_pending_exposes_func,
|
|
|
|
frames);
|
|
|
|
}
|
|
|
|
}
|