2008-07-01 22:57:50 +00:00
|
|
|
/* GTK - The GIMP Toolkit
|
2001-01-08 17:04:17 +00:00
|
|
|
* Copyright (C) 2001 Red Hat, Inc.
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library 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
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Authors: Alexander Larsson <alexl@redhat.com>
|
|
|
|
*/
|
|
|
|
|
2008-06-22 14:28:52 +00:00
|
|
|
#include "config.h"
|
2001-01-08 17:04:17 +00:00
|
|
|
#include "gtkprivate.h"
|
|
|
|
#include "gtkwindow.h"
|
|
|
|
#include "gtkmain.h"
|
2005-03-20 07:01:23 +00:00
|
|
|
#include "gtkwindow-decorate.h"
|
2008-03-11 17:14:00 +00:00
|
|
|
#include "gtkintl.h"
|
2001-01-08 17:04:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
#ifdef DECORATE_WINDOWS
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
GTK_WINDOW_REGION_TITLE,
|
implement maximize for linux-fb
Thu Oct 3 16:40:18 2002 Eric Warmenhoven <eric@warmenhoven.org>
* gdk/gdkevents.c, gdk/linux-fb/gdkwindow-fb.c,
gtk/gtkwindow-decorate.c: implement maximize for linux-fb
* gdk/linux-fb/gdkkeyboard-fb.c: implement raw keyboard mode
* gdk/linux-fb/Makefile.am, gdk/linux-fb/gdkdnd-fb.c,
gdk/linux-fb/gdkmain-fb.c, gdk/linux-fb/gdkselection-fb.c,
gdk/linux-fb/miarc.c, gdk/linux-fb/mifpolycon.c,
gdk/linux-fb/miwideline.c, gdk/linux-fb/mizerclip.c,
gdk/linux-fb/mizerline.c: small cleanups
2002-10-03 23:45:03 +00:00
|
|
|
GTK_WINDOW_REGION_MAXIMIZE,
|
2001-01-08 17:04:17 +00:00
|
|
|
GTK_WINDOW_REGION_CLOSE,
|
|
|
|
GTK_WINDOW_REGION_BR_RESIZE
|
|
|
|
} GtkWindowRegionType;
|
|
|
|
|
|
|
|
typedef struct _GtkWindowRegion GtkWindowRegion;
|
|
|
|
typedef struct _GtkWindowDecoration GtkWindowDecoration;
|
|
|
|
|
|
|
|
struct _GtkWindowRegion
|
|
|
|
{
|
|
|
|
GdkRectangle rect;
|
|
|
|
GtkWindowRegionType type;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
RESIZE_TOP_LEFT,
|
|
|
|
RESIZE_TOP,
|
|
|
|
RESIZE_TOP_RIGHT,
|
|
|
|
RESIZE_RIGHT,
|
|
|
|
RESIZE_BOTTOM_RIGHT,
|
|
|
|
RESIZE_BOTTOM,
|
|
|
|
RESIZE_BOTTOM_LEFT,
|
|
|
|
RESIZE_LEFT,
|
|
|
|
RESIZE_NONE,
|
|
|
|
} GtkWindowResizeType;
|
|
|
|
|
|
|
|
struct _GtkWindowDecoration
|
|
|
|
{
|
|
|
|
gint n_regions;
|
|
|
|
GtkWindowRegion *regions;
|
|
|
|
|
|
|
|
gint last_x, last_y;
|
implement maximize for linux-fb
Thu Oct 3 16:40:18 2002 Eric Warmenhoven <eric@warmenhoven.org>
* gdk/gdkevents.c, gdk/linux-fb/gdkwindow-fb.c,
gtk/gtkwindow-decorate.c: implement maximize for linux-fb
* gdk/linux-fb/gdkkeyboard-fb.c: implement raw keyboard mode
* gdk/linux-fb/Makefile.am, gdk/linux-fb/gdkdnd-fb.c,
gdk/linux-fb/gdkmain-fb.c, gdk/linux-fb/gdkselection-fb.c,
gdk/linux-fb/miarc.c, gdk/linux-fb/mifpolycon.c,
gdk/linux-fb/miwideline.c, gdk/linux-fb/mizerclip.c,
gdk/linux-fb/mizerline.c: small cleanups
2002-10-03 23:45:03 +00:00
|
|
|
gint last_w, last_h;
|
2001-01-08 17:04:17 +00:00
|
|
|
|
|
|
|
PangoLayout *title_layout;
|
|
|
|
|
|
|
|
GtkWindowResizeType resize;
|
|
|
|
|
2003-05-27 21:21:00 +00:00
|
|
|
guint moving : 1;
|
|
|
|
guint closing : 1;
|
|
|
|
guint maximizing : 1;
|
|
|
|
guint maximized : 1;
|
|
|
|
guint maximizable : 1;
|
|
|
|
guint decorated : 1;
|
|
|
|
guint real_inner_move : 1;
|
|
|
|
guint focused : 1;
|
2001-01-08 17:04:17 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#define DECORATION_BORDER_TOP 15
|
|
|
|
#define DECORATION_BORDER_LEFT 3
|
|
|
|
#define DECORATION_BORDER_RIGHT 3
|
|
|
|
#define DECORATION_BORDER_BOTTOM 3
|
|
|
|
#define DECORATION_BORDER_TOT_X (DECORATION_BORDER_LEFT + DECORATION_BORDER_RIGHT)
|
|
|
|
#define DECORATION_BORDER_TOT_Y (DECORATION_BORDER_TOP + DECORATION_BORDER_BOTTOM)
|
|
|
|
#define DECORATION_BUTTON_SIZE 9
|
|
|
|
#define DECORATION_BUTTON_Y_OFFSET 2
|
|
|
|
#define DECORATION_TITLE_FONT "Sans 9"
|
|
|
|
|
|
|
|
static void gtk_decorated_window_recalculate_regions (GtkWindow *window);
|
|
|
|
static GtkWindowRegionType gtk_decorated_window_region_type (GtkWindow *window,
|
|
|
|
gint x,
|
|
|
|
gint y);
|
2001-11-03 23:02:40 +00:00
|
|
|
static gint gtk_decorated_window_frame_event (GtkWindow *window,
|
2001-01-08 17:04:17 +00:00
|
|
|
GdkEvent *event);
|
|
|
|
static gint gtk_decorated_window_button_press (GtkWidget *widget,
|
|
|
|
GdkEventButton *event);
|
|
|
|
static gint gtk_decorated_window_button_release (GtkWidget *widget,
|
|
|
|
GdkEventButton *event);
|
|
|
|
static gint gtk_decorated_window_motion_notify (GtkWidget *widget,
|
|
|
|
GdkEventMotion *event);
|
implement maximize for linux-fb
Thu Oct 3 16:40:18 2002 Eric Warmenhoven <eric@warmenhoven.org>
* gdk/gdkevents.c, gdk/linux-fb/gdkwindow-fb.c,
gtk/gtkwindow-decorate.c: implement maximize for linux-fb
* gdk/linux-fb/gdkkeyboard-fb.c: implement raw keyboard mode
* gdk/linux-fb/Makefile.am, gdk/linux-fb/gdkdnd-fb.c,
gdk/linux-fb/gdkmain-fb.c, gdk/linux-fb/gdkselection-fb.c,
gdk/linux-fb/miarc.c, gdk/linux-fb/mifpolycon.c,
gdk/linux-fb/miwideline.c, gdk/linux-fb/mizerclip.c,
gdk/linux-fb/mizerline.c: small cleanups
2002-10-03 23:45:03 +00:00
|
|
|
static gint gtk_decorated_window_window_state (GtkWidget *widget,
|
|
|
|
GdkEventWindowState *event);
|
2001-01-08 17:04:17 +00:00
|
|
|
static void gtk_decorated_window_paint (GtkWidget *widget,
|
|
|
|
GdkRectangle *area);
|
|
|
|
static gint gtk_decorated_window_focus_change (GtkWidget *widget,
|
|
|
|
GdkEventFocus *event);
|
|
|
|
static void gtk_decorated_window_realize (GtkWindow *window);
|
|
|
|
static void gtk_decorated_window_unrealize (GtkWindow *window);
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_decoration_free (GtkWindowDecoration *deco)
|
|
|
|
{
|
|
|
|
g_free (deco->regions);
|
|
|
|
deco->regions = NULL;
|
|
|
|
deco->n_regions = 0;
|
|
|
|
|
|
|
|
g_free (deco);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gtk_decorated_window_init (GtkWindow *window)
|
|
|
|
{
|
|
|
|
GtkWindowDecoration *deco;
|
|
|
|
|
|
|
|
deco = g_new (GtkWindowDecoration, 1);
|
|
|
|
|
|
|
|
deco->n_regions = 0;
|
|
|
|
deco->regions = NULL;
|
|
|
|
deco->title_layout = NULL;
|
|
|
|
deco->resize = RESIZE_NONE;
|
|
|
|
deco->moving = FALSE;
|
|
|
|
deco->decorated = TRUE;
|
|
|
|
deco->closing = FALSE;
|
implement maximize for linux-fb
Thu Oct 3 16:40:18 2002 Eric Warmenhoven <eric@warmenhoven.org>
* gdk/gdkevents.c, gdk/linux-fb/gdkwindow-fb.c,
gtk/gtkwindow-decorate.c: implement maximize for linux-fb
* gdk/linux-fb/gdkkeyboard-fb.c: implement raw keyboard mode
* gdk/linux-fb/Makefile.am, gdk/linux-fb/gdkdnd-fb.c,
gdk/linux-fb/gdkmain-fb.c, gdk/linux-fb/gdkselection-fb.c,
gdk/linux-fb/miarc.c, gdk/linux-fb/mifpolycon.c,
gdk/linux-fb/miwideline.c, gdk/linux-fb/mizerclip.c,
gdk/linux-fb/mizerline.c: small cleanups
2002-10-03 23:45:03 +00:00
|
|
|
deco->maximizing = FALSE;
|
|
|
|
deco->maximized = FALSE;
|
|
|
|
deco->maximizable = FALSE;
|
2001-01-08 17:04:17 +00:00
|
|
|
deco->real_inner_move = FALSE;
|
|
|
|
|
2005-09-01 05:11:46 +00:00
|
|
|
g_object_set_data_full (G_OBJECT (window), I_("gtk-window-decoration"), deco,
|
2001-01-08 17:04:17 +00:00
|
|
|
(GDestroyNotify) gtk_decoration_free);
|
|
|
|
|
2001-06-15 15:58:26 +00:00
|
|
|
gtk_window_set_has_frame (window, TRUE);
|
2001-01-08 17:04:17 +00:00
|
|
|
|
2002-10-01 19:55:08 +00:00
|
|
|
g_signal_connect (window,
|
2008-08-12 14:37:03 +00:00
|
|
|
"frame-event",
|
2002-10-01 19:55:08 +00:00
|
|
|
G_CALLBACK (gtk_decorated_window_frame_event),
|
|
|
|
window);
|
|
|
|
g_signal_connect (window,
|
2008-08-12 14:37:03 +00:00
|
|
|
"focus-in-event",
|
2002-10-01 19:55:08 +00:00
|
|
|
G_CALLBACK (gtk_decorated_window_focus_change),
|
|
|
|
window);
|
|
|
|
g_signal_connect (window,
|
2008-08-12 14:37:03 +00:00
|
|
|
"focus-out-event",
|
2002-10-01 19:55:08 +00:00
|
|
|
G_CALLBACK (gtk_decorated_window_focus_change),
|
|
|
|
window);
|
|
|
|
g_signal_connect (window,
|
|
|
|
"realize",
|
|
|
|
G_CALLBACK (gtk_decorated_window_realize),
|
|
|
|
window);
|
|
|
|
g_signal_connect (window,
|
|
|
|
"unrealize",
|
|
|
|
G_CALLBACK (gtk_decorated_window_unrealize),
|
|
|
|
window);
|
2001-01-08 17:04:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline GtkWindowDecoration *
|
|
|
|
get_decoration (GtkWindow *window)
|
|
|
|
{
|
|
|
|
return (GtkWindowDecoration *)g_object_get_data (G_OBJECT (window), "gtk-window-decoration");
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gtk_decorated_window_set_title (GtkWindow *window,
|
|
|
|
const gchar *title)
|
|
|
|
{
|
|
|
|
GtkWindowDecoration *deco = get_decoration (window);
|
|
|
|
|
|
|
|
if (deco->title_layout)
|
|
|
|
pango_layout_set_text (deco->title_layout, title, -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gtk_decorated_window_calculate_frame_size (GtkWindow *window)
|
|
|
|
{
|
|
|
|
GdkWMDecoration decorations;
|
|
|
|
GtkWindowDecoration *deco = get_decoration (window);
|
|
|
|
|
|
|
|
if (gdk_window_get_decorations (GTK_WIDGET (window)->window,
|
|
|
|
&decorations))
|
|
|
|
{
|
|
|
|
if ((decorations & GDK_DECOR_BORDER) &&
|
|
|
|
(decorations & GDK_DECOR_TITLE))
|
implement maximize for linux-fb
Thu Oct 3 16:40:18 2002 Eric Warmenhoven <eric@warmenhoven.org>
* gdk/gdkevents.c, gdk/linux-fb/gdkwindow-fb.c,
gtk/gtkwindow-decorate.c: implement maximize for linux-fb
* gdk/linux-fb/gdkkeyboard-fb.c: implement raw keyboard mode
* gdk/linux-fb/Makefile.am, gdk/linux-fb/gdkdnd-fb.c,
gdk/linux-fb/gdkmain-fb.c, gdk/linux-fb/gdkselection-fb.c,
gdk/linux-fb/miarc.c, gdk/linux-fb/mifpolycon.c,
gdk/linux-fb/miwideline.c, gdk/linux-fb/mizerclip.c,
gdk/linux-fb/mizerline.c: small cleanups
2002-10-03 23:45:03 +00:00
|
|
|
{
|
|
|
|
deco->decorated = TRUE;
|
|
|
|
if ((decorations & GDK_DECOR_MAXIMIZE) &&
|
|
|
|
(gtk_window_get_type_hint (window) == GDK_WINDOW_TYPE_HINT_NORMAL))
|
|
|
|
deco->maximizable = TRUE;
|
|
|
|
}
|
2001-01-08 17:04:17 +00:00
|
|
|
else
|
|
|
|
deco->decorated = FALSE;
|
|
|
|
}
|
|
|
|
else
|
implement maximize for linux-fb
Thu Oct 3 16:40:18 2002 Eric Warmenhoven <eric@warmenhoven.org>
* gdk/gdkevents.c, gdk/linux-fb/gdkwindow-fb.c,
gtk/gtkwindow-decorate.c: implement maximize for linux-fb
* gdk/linux-fb/gdkkeyboard-fb.c: implement raw keyboard mode
* gdk/linux-fb/Makefile.am, gdk/linux-fb/gdkdnd-fb.c,
gdk/linux-fb/gdkmain-fb.c, gdk/linux-fb/gdkselection-fb.c,
gdk/linux-fb/miarc.c, gdk/linux-fb/mifpolycon.c,
gdk/linux-fb/miwideline.c, gdk/linux-fb/mizerclip.c,
gdk/linux-fb/mizerline.c: small cleanups
2002-10-03 23:45:03 +00:00
|
|
|
{
|
|
|
|
deco->decorated = (window->type != GTK_WINDOW_POPUP);
|
|
|
|
deco->maximizable = (gtk_window_get_type_hint (window) == GDK_WINDOW_TYPE_HINT_NORMAL);
|
|
|
|
}
|
2001-01-08 17:04:17 +00:00
|
|
|
|
|
|
|
if (deco->decorated)
|
|
|
|
gtk_window_set_frame_dimensions (window,
|
|
|
|
DECORATION_BORDER_LEFT,
|
|
|
|
DECORATION_BORDER_TOP,
|
|
|
|
DECORATION_BORDER_RIGHT,
|
|
|
|
DECORATION_BORDER_BOTTOM);
|
|
|
|
else
|
|
|
|
gtk_window_set_frame_dimensions (window, 0, 0, 0, 0);
|
|
|
|
|
|
|
|
gtk_decorated_window_recalculate_regions (window);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gtk_decorated_window_inner_change (GdkWindow *win,
|
|
|
|
gint x, gint y,
|
|
|
|
gint width, gint height,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
GtkWindow *window = (GtkWindow *)user_data;
|
|
|
|
GtkWidget *widget = GTK_WIDGET (window);
|
|
|
|
GtkWindowDecoration *deco = get_decoration (window);
|
|
|
|
|
|
|
|
if (deco->real_inner_move)
|
|
|
|
{
|
|
|
|
deco->real_inner_move = FALSE;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
deco->real_inner_move = TRUE;
|
|
|
|
gdk_window_move_resize (widget->window,
|
|
|
|
window->frame_left, window->frame_top,
|
|
|
|
width, height);
|
|
|
|
|
|
|
|
gdk_window_move_resize (window->frame,
|
|
|
|
x - window->frame_left, y - window->frame_top,
|
|
|
|
width + window->frame_left + window->frame_right,
|
|
|
|
height + window->frame_top + window->frame_bottom);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_decorated_window_inner_get_pos (GdkWindow *win,
|
|
|
|
gint *x, gint *y,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
GtkWindow *window = (GtkWindow *)user_data;
|
|
|
|
|
|
|
|
gdk_window_get_position (window->frame, x, y);
|
|
|
|
|
|
|
|
*x += window->frame_left;
|
|
|
|
*y += window->frame_top;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_decorated_window_realize (GtkWindow *window)
|
|
|
|
{
|
|
|
|
GtkWindowDecoration *deco = get_decoration (window);
|
|
|
|
GtkWidget *widget = GTK_WIDGET (window);
|
2001-01-22 12:40:35 +00:00
|
|
|
PangoFontDescription *font_desc;
|
2001-01-08 17:04:17 +00:00
|
|
|
|
|
|
|
deco->title_layout = gtk_widget_create_pango_layout (widget,
|
|
|
|
(window->title)?window->title:"");
|
2001-01-22 12:40:35 +00:00
|
|
|
|
|
|
|
font_desc = pango_font_description_from_string(DECORATION_TITLE_FONT);
|
|
|
|
pango_layout_set_font_description (deco->title_layout, font_desc);
|
|
|
|
pango_font_description_free (font_desc);
|
2001-01-08 17:04:17 +00:00
|
|
|
}
|
|
|
|
|
2001-01-12 15:45:26 +00:00
|
|
|
|
2001-01-08 17:04:17 +00:00
|
|
|
static void
|
|
|
|
gtk_decorated_window_unrealize (GtkWindow *window)
|
|
|
|
{
|
|
|
|
GtkWindowDecoration *deco = get_decoration (window);
|
|
|
|
|
|
|
|
if (deco->title_layout)
|
|
|
|
{
|
2002-10-01 19:55:08 +00:00
|
|
|
g_object_unref (deco->title_layout);
|
2001-01-08 17:04:17 +00:00
|
|
|
deco->title_layout = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
2001-11-03 23:02:40 +00:00
|
|
|
gtk_decorated_window_frame_event (GtkWindow *window, GdkEvent *event)
|
2001-01-08 17:04:17 +00:00
|
|
|
{
|
2001-11-03 23:02:40 +00:00
|
|
|
GtkWindowDecoration *deco = get_decoration (window);
|
|
|
|
GtkWidget *widget = GTK_WIDGET (window);
|
2001-01-08 17:04:17 +00:00
|
|
|
GdkEventExpose *expose_event;
|
|
|
|
|
|
|
|
switch (event->type)
|
|
|
|
{
|
|
|
|
case GDK_EXPOSE:
|
|
|
|
expose_event = (GdkEventExpose *)event;
|
|
|
|
if (deco->decorated)
|
|
|
|
gtk_decorated_window_paint (widget, &expose_event->area);
|
|
|
|
return TRUE;
|
|
|
|
break;
|
|
|
|
case GDK_CONFIGURE:
|
2001-11-03 23:02:40 +00:00
|
|
|
gtk_decorated_window_recalculate_regions (window);
|
2001-01-08 17:04:17 +00:00
|
|
|
break;
|
|
|
|
case GDK_MOTION_NOTIFY:
|
|
|
|
return gtk_decorated_window_motion_notify (widget, (GdkEventMotion *)event);
|
|
|
|
break;
|
|
|
|
case GDK_BUTTON_PRESS:
|
|
|
|
return gtk_decorated_window_button_press (widget, (GdkEventButton *)event);
|
|
|
|
break;
|
|
|
|
case GDK_BUTTON_RELEASE:
|
|
|
|
return gtk_decorated_window_button_release (widget, (GdkEventButton *)event);
|
implement maximize for linux-fb
Thu Oct 3 16:40:18 2002 Eric Warmenhoven <eric@warmenhoven.org>
* gdk/gdkevents.c, gdk/linux-fb/gdkwindow-fb.c,
gtk/gtkwindow-decorate.c: implement maximize for linux-fb
* gdk/linux-fb/gdkkeyboard-fb.c: implement raw keyboard mode
* gdk/linux-fb/Makefile.am, gdk/linux-fb/gdkdnd-fb.c,
gdk/linux-fb/gdkmain-fb.c, gdk/linux-fb/gdkselection-fb.c,
gdk/linux-fb/miarc.c, gdk/linux-fb/mifpolycon.c,
gdk/linux-fb/miwideline.c, gdk/linux-fb/mizerclip.c,
gdk/linux-fb/mizerline.c: small cleanups
2002-10-03 23:45:03 +00:00
|
|
|
case GDK_WINDOW_STATE:
|
|
|
|
return gtk_decorated_window_window_state (widget, (GdkEventWindowState *)event);
|
2001-01-08 17:04:17 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
|
|
|
gtk_decorated_window_focus_change (GtkWidget *widget,
|
|
|
|
GdkEventFocus *event)
|
|
|
|
{
|
|
|
|
GtkWindow *window = GTK_WINDOW(widget);
|
|
|
|
GtkWindowDecoration *deco = get_decoration (window);
|
|
|
|
deco->focused = event->in;
|
|
|
|
gdk_window_invalidate_rect (window->frame, NULL, FALSE);
|
2001-05-11 21:57:33 +00:00
|
|
|
return FALSE;
|
2001-01-08 17:04:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
|
|
|
gtk_decorated_window_motion_notify (GtkWidget *widget,
|
|
|
|
GdkEventMotion *event)
|
|
|
|
{
|
|
|
|
GtkWindow *window;
|
|
|
|
GtkWindowDecoration *deco;
|
|
|
|
GdkModifierType mask;
|
|
|
|
GdkWindow *win;
|
|
|
|
gint x, y;
|
|
|
|
gint win_x, win_y, win_w, win_h;
|
|
|
|
|
|
|
|
window = GTK_WINDOW (widget);
|
|
|
|
deco = get_decoration (window);
|
|
|
|
|
|
|
|
if (!deco->decorated)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
win = widget->window;
|
|
|
|
gdk_window_get_pointer (window->frame, &x, &y, &mask);
|
|
|
|
|
|
|
|
gdk_window_get_position (window->frame, &win_x, &win_y);
|
|
|
|
win_x += DECORATION_BORDER_LEFT;
|
|
|
|
win_y += DECORATION_BORDER_TOP;
|
|
|
|
|
|
|
|
gdk_window_get_geometry (win, NULL, NULL, &win_w, &win_h, NULL);
|
|
|
|
|
|
|
|
if (deco->moving)
|
|
|
|
{
|
|
|
|
int dx, dy;
|
|
|
|
dx = x - deco->last_x;
|
|
|
|
dy = y - deco->last_y;
|
|
|
|
|
2001-04-02 07:15:30 +00:00
|
|
|
_gtk_window_reposition (window, win_x + dx, win_y + dy);
|
2001-01-08 17:04:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (deco->resize != RESIZE_NONE)
|
|
|
|
{
|
|
|
|
int w, h;
|
|
|
|
|
|
|
|
w = win_w;
|
|
|
|
h = win_h;
|
|
|
|
|
|
|
|
switch(deco->resize) {
|
|
|
|
case RESIZE_BOTTOM_RIGHT:
|
|
|
|
w = x - DECORATION_BORDER_TOT_X;
|
|
|
|
h = y - DECORATION_BORDER_TOT_Y;
|
|
|
|
break;
|
|
|
|
case RESIZE_RIGHT:
|
|
|
|
w = x - DECORATION_BORDER_TOT_X;
|
|
|
|
break;
|
|
|
|
case RESIZE_BOTTOM:
|
|
|
|
h = y - DECORATION_BORDER_TOT_Y;
|
|
|
|
break;
|
|
|
|
case RESIZE_TOP_LEFT:
|
|
|
|
case RESIZE_TOP:
|
|
|
|
case RESIZE_TOP_RIGHT:
|
|
|
|
case RESIZE_BOTTOM_LEFT:
|
|
|
|
case RESIZE_LEFT:
|
|
|
|
default:
|
|
|
|
g_warning ("Resize mode %d not handled yet.\n", deco->resize);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((w > 0) && (h > 0))
|
|
|
|
{
|
|
|
|
_gtk_window_constrain_size (window, w,h, &w, &h);
|
|
|
|
|
|
|
|
if ((w != win_w) || (h != win_h))
|
|
|
|
gdk_window_resize (widget->window, w, h);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GtkWindowRegionType
|
|
|
|
gtk_decorated_window_region_type (GtkWindow *window, gint x, gint y)
|
|
|
|
{
|
|
|
|
GtkWindowDecoration *deco = get_decoration (window);
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i=0;i<deco->n_regions;i++)
|
|
|
|
{
|
|
|
|
if ((x > deco->regions[i].rect.x) &&
|
|
|
|
(x - deco->regions[i].rect.x < deco->regions[i].rect.width) &&
|
|
|
|
(y > deco->regions[i].rect.y) &&
|
|
|
|
(y - deco->regions[i].rect.y < deco->regions[i].rect.height))
|
|
|
|
return deco->regions[i].type;
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
|
|
|
gtk_decorated_window_button_press (GtkWidget *widget,
|
|
|
|
GdkEventButton *event)
|
|
|
|
{
|
|
|
|
GtkWindow *window;
|
|
|
|
GtkWindowRegionType type;
|
|
|
|
GtkWindowDecoration *deco;
|
|
|
|
gint x, y;
|
|
|
|
|
|
|
|
window = GTK_WINDOW (widget);
|
|
|
|
deco = get_decoration (window);
|
|
|
|
|
|
|
|
if (!deco->decorated)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
x = event->x;
|
|
|
|
y = event->y;
|
|
|
|
|
|
|
|
type = gtk_decorated_window_region_type (window, x, y);
|
|
|
|
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case GTK_WINDOW_REGION_TITLE:
|
implement maximize for linux-fb
Thu Oct 3 16:40:18 2002 Eric Warmenhoven <eric@warmenhoven.org>
* gdk/gdkevents.c, gdk/linux-fb/gdkwindow-fb.c,
gtk/gtkwindow-decorate.c: implement maximize for linux-fb
* gdk/linux-fb/gdkkeyboard-fb.c: implement raw keyboard mode
* gdk/linux-fb/Makefile.am, gdk/linux-fb/gdkdnd-fb.c,
gdk/linux-fb/gdkmain-fb.c, gdk/linux-fb/gdkselection-fb.c,
gdk/linux-fb/miarc.c, gdk/linux-fb/mifpolycon.c,
gdk/linux-fb/miwideline.c, gdk/linux-fb/mizerclip.c,
gdk/linux-fb/mizerline.c: small cleanups
2002-10-03 23:45:03 +00:00
|
|
|
if (!deco->maximized && event->state & GDK_BUTTON1_MASK)
|
|
|
|
{
|
|
|
|
deco->last_x = x;
|
|
|
|
deco->last_y = y;
|
|
|
|
deco->moving = TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GTK_WINDOW_REGION_MAXIMIZE:
|
2001-01-08 17:04:17 +00:00
|
|
|
if (event->state & GDK_BUTTON1_MASK)
|
implement maximize for linux-fb
Thu Oct 3 16:40:18 2002 Eric Warmenhoven <eric@warmenhoven.org>
* gdk/gdkevents.c, gdk/linux-fb/gdkwindow-fb.c,
gtk/gtkwindow-decorate.c: implement maximize for linux-fb
* gdk/linux-fb/gdkkeyboard-fb.c: implement raw keyboard mode
* gdk/linux-fb/Makefile.am, gdk/linux-fb/gdkdnd-fb.c,
gdk/linux-fb/gdkmain-fb.c, gdk/linux-fb/gdkselection-fb.c,
gdk/linux-fb/miarc.c, gdk/linux-fb/mifpolycon.c,
gdk/linux-fb/miwideline.c, gdk/linux-fb/mizerclip.c,
gdk/linux-fb/mizerline.c: small cleanups
2002-10-03 23:45:03 +00:00
|
|
|
deco->maximizing = TRUE;
|
2001-01-08 17:04:17 +00:00
|
|
|
break;
|
|
|
|
case GTK_WINDOW_REGION_CLOSE:
|
|
|
|
if (event->state & GDK_BUTTON1_MASK)
|
|
|
|
deco->closing = TRUE;
|
|
|
|
break;
|
|
|
|
case GTK_WINDOW_REGION_BR_RESIZE:
|
implement maximize for linux-fb
Thu Oct 3 16:40:18 2002 Eric Warmenhoven <eric@warmenhoven.org>
* gdk/gdkevents.c, gdk/linux-fb/gdkwindow-fb.c,
gtk/gtkwindow-decorate.c: implement maximize for linux-fb
* gdk/linux-fb/gdkkeyboard-fb.c: implement raw keyboard mode
* gdk/linux-fb/Makefile.am, gdk/linux-fb/gdkdnd-fb.c,
gdk/linux-fb/gdkmain-fb.c, gdk/linux-fb/gdkselection-fb.c,
gdk/linux-fb/miarc.c, gdk/linux-fb/mifpolycon.c,
gdk/linux-fb/miwideline.c, gdk/linux-fb/mizerclip.c,
gdk/linux-fb/mizerline.c: small cleanups
2002-10-03 23:45:03 +00:00
|
|
|
if (!deco->maximized)
|
|
|
|
{
|
|
|
|
if (event->state & GDK_BUTTON1_MASK)
|
|
|
|
deco->resize = RESIZE_BOTTOM_RIGHT;
|
|
|
|
deco->last_x = x;
|
|
|
|
deco->last_y = y;
|
|
|
|
}
|
2001-01-08 17:04:17 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
|
|
|
gtk_decorated_window_button_release (GtkWidget *widget,
|
|
|
|
GdkEventButton *event)
|
|
|
|
{
|
|
|
|
GtkWindow *window;
|
|
|
|
GtkWindowRegionType type;
|
|
|
|
GtkWindowDecoration *deco;
|
|
|
|
|
|
|
|
window = GTK_WINDOW (widget);
|
|
|
|
deco = get_decoration (window);
|
|
|
|
|
|
|
|
if (deco->closing)
|
|
|
|
{
|
|
|
|
type = gtk_decorated_window_region_type (window, event->x, event->y);
|
|
|
|
if (type == GTK_WINDOW_REGION_CLOSE)
|
|
|
|
{
|
2002-10-03 20:53:30 +00:00
|
|
|
GdkEvent *event = gdk_event_new (GDK_DELETE);
|
2001-01-08 17:04:17 +00:00
|
|
|
|
2002-10-03 20:53:30 +00:00
|
|
|
event->any.type = GDK_DELETE;
|
|
|
|
event->any.window = g_object_ref (widget->window);
|
|
|
|
event->any.send_event = TRUE;
|
2001-01-08 17:04:17 +00:00
|
|
|
|
2002-10-03 20:53:30 +00:00
|
|
|
gtk_main_do_event (event);
|
|
|
|
gdk_event_free (event);
|
2001-01-08 17:04:17 +00:00
|
|
|
}
|
|
|
|
}
|
implement maximize for linux-fb
Thu Oct 3 16:40:18 2002 Eric Warmenhoven <eric@warmenhoven.org>
* gdk/gdkevents.c, gdk/linux-fb/gdkwindow-fb.c,
gtk/gtkwindow-decorate.c: implement maximize for linux-fb
* gdk/linux-fb/gdkkeyboard-fb.c: implement raw keyboard mode
* gdk/linux-fb/Makefile.am, gdk/linux-fb/gdkdnd-fb.c,
gdk/linux-fb/gdkmain-fb.c, gdk/linux-fb/gdkselection-fb.c,
gdk/linux-fb/miarc.c, gdk/linux-fb/mifpolycon.c,
gdk/linux-fb/miwideline.c, gdk/linux-fb/mizerclip.c,
gdk/linux-fb/mizerline.c: small cleanups
2002-10-03 23:45:03 +00:00
|
|
|
else if (deco->maximizing)
|
|
|
|
{
|
|
|
|
type = gtk_decorated_window_region_type (window, event->x, event->y);
|
|
|
|
if (type == GTK_WINDOW_REGION_MAXIMIZE)
|
|
|
|
{
|
|
|
|
if (deco->maximized)
|
|
|
|
gtk_window_unmaximize (window);
|
|
|
|
else
|
|
|
|
gtk_window_maximize (window);
|
|
|
|
}
|
|
|
|
}
|
2001-01-08 17:04:17 +00:00
|
|
|
|
|
|
|
deco->closing = FALSE;
|
implement maximize for linux-fb
Thu Oct 3 16:40:18 2002 Eric Warmenhoven <eric@warmenhoven.org>
* gdk/gdkevents.c, gdk/linux-fb/gdkwindow-fb.c,
gtk/gtkwindow-decorate.c: implement maximize for linux-fb
* gdk/linux-fb/gdkkeyboard-fb.c: implement raw keyboard mode
* gdk/linux-fb/Makefile.am, gdk/linux-fb/gdkdnd-fb.c,
gdk/linux-fb/gdkmain-fb.c, gdk/linux-fb/gdkselection-fb.c,
gdk/linux-fb/miarc.c, gdk/linux-fb/mifpolycon.c,
gdk/linux-fb/miwideline.c, gdk/linux-fb/mizerclip.c,
gdk/linux-fb/mizerline.c: small cleanups
2002-10-03 23:45:03 +00:00
|
|
|
deco->maximizing = FALSE;
|
2001-01-08 17:04:17 +00:00
|
|
|
deco->moving = FALSE;
|
|
|
|
deco->resize = RESIZE_NONE;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
implement maximize for linux-fb
Thu Oct 3 16:40:18 2002 Eric Warmenhoven <eric@warmenhoven.org>
* gdk/gdkevents.c, gdk/linux-fb/gdkwindow-fb.c,
gtk/gtkwindow-decorate.c: implement maximize for linux-fb
* gdk/linux-fb/gdkkeyboard-fb.c: implement raw keyboard mode
* gdk/linux-fb/Makefile.am, gdk/linux-fb/gdkdnd-fb.c,
gdk/linux-fb/gdkmain-fb.c, gdk/linux-fb/gdkselection-fb.c,
gdk/linux-fb/miarc.c, gdk/linux-fb/mifpolycon.c,
gdk/linux-fb/miwideline.c, gdk/linux-fb/mizerclip.c,
gdk/linux-fb/mizerline.c: small cleanups
2002-10-03 23:45:03 +00:00
|
|
|
static gint
|
|
|
|
gtk_decorated_window_window_state (GtkWidget *widget,
|
|
|
|
GdkEventWindowState *event)
|
|
|
|
{
|
|
|
|
GtkWindow *window;
|
|
|
|
GtkWindowDecoration *deco;
|
|
|
|
GdkWindowObject *priv;
|
|
|
|
|
|
|
|
window = GTK_WINDOW (widget);
|
|
|
|
deco = get_decoration (window);
|
|
|
|
priv = GDK_WINDOW_OBJECT (window->frame);
|
|
|
|
|
|
|
|
if (event->changed_mask & GDK_WINDOW_STATE_MAXIMIZED)
|
|
|
|
{
|
|
|
|
if (event->new_window_state & GDK_WINDOW_STATE_MAXIMIZED)
|
|
|
|
{
|
|
|
|
int w, h;
|
|
|
|
gdk_window_get_geometry (widget->window, NULL, NULL,
|
|
|
|
&deco->last_w, &deco->last_h, NULL);
|
|
|
|
gdk_window_get_origin (widget->window, &deco->last_x, &deco->last_y);
|
|
|
|
w = gdk_screen_get_width(gdk_screen_get_default()) - DECORATION_BORDER_TOT_X;
|
|
|
|
h = gdk_screen_get_height(gdk_screen_get_default()) - DECORATION_BORDER_TOT_Y;
|
|
|
|
_gtk_window_constrain_size (window, w, h, &w, &h);
|
|
|
|
if (w != deco->last_w || h != deco->last_h)
|
|
|
|
{
|
|
|
|
_gtk_window_reposition (window, DECORATION_BORDER_LEFT, DECORATION_BORDER_TOP);
|
|
|
|
gdk_window_resize (widget->window, w, h);
|
|
|
|
deco->maximized = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
_gtk_window_reposition (window, deco->last_x, deco->last_y);
|
|
|
|
_gtk_window_constrain_size (window, deco->last_w, deco->last_h,
|
|
|
|
&deco->last_w, &deco->last_h);
|
|
|
|
gdk_window_resize (widget->window, deco->last_w, deco->last_h);
|
|
|
|
deco->maximized = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2001-01-08 17:04:17 +00:00
|
|
|
static void
|
|
|
|
gtk_decorated_window_paint (GtkWidget *widget,
|
|
|
|
GdkRectangle *area)
|
|
|
|
{
|
|
|
|
GtkWindow *window = GTK_WINDOW (widget);
|
|
|
|
GtkWindowDecoration *deco = get_decoration (window);
|
|
|
|
gint x1, y1, x2, y2;
|
|
|
|
GtkStateType border_state;
|
2010-07-15 11:05:57 +00:00
|
|
|
cairo_t *cr;
|
2001-01-08 17:04:17 +00:00
|
|
|
|
|
|
|
if (deco->decorated)
|
|
|
|
{
|
|
|
|
GdkWindow *frame;
|
|
|
|
gint width, height;
|
|
|
|
|
|
|
|
frame = window->frame;
|
2002-11-19 01:16:36 +00:00
|
|
|
gdk_drawable_get_size (frame, &width, &height);
|
2001-01-08 17:04:17 +00:00
|
|
|
|
|
|
|
/* Top */
|
|
|
|
gtk_paint_flat_box (widget->style, frame, GTK_STATE_NORMAL,
|
|
|
|
GTK_SHADOW_NONE, area, widget, "base",
|
|
|
|
0, 0,
|
|
|
|
width, DECORATION_BORDER_TOP);
|
|
|
|
/* Bottom */
|
|
|
|
gtk_paint_flat_box (widget->style, frame, GTK_STATE_NORMAL,
|
|
|
|
GTK_SHADOW_NONE, area, widget, "base",
|
|
|
|
0, height - DECORATION_BORDER_BOTTOM,
|
|
|
|
width, DECORATION_BORDER_BOTTOM);
|
|
|
|
/* Left */
|
|
|
|
gtk_paint_flat_box (widget->style, frame, GTK_STATE_NORMAL,
|
|
|
|
GTK_SHADOW_NONE, area, widget, "base",
|
|
|
|
0, DECORATION_BORDER_TOP,
|
|
|
|
DECORATION_BORDER_LEFT, height - DECORATION_BORDER_TOT_Y);
|
|
|
|
/* Right */
|
|
|
|
gtk_paint_flat_box (widget->style, frame, GTK_STATE_NORMAL,
|
|
|
|
GTK_SHADOW_NONE, area, widget, "base",
|
|
|
|
width - DECORATION_BORDER_RIGHT, DECORATION_BORDER_TOP,
|
|
|
|
DECORATION_BORDER_RIGHT, height - DECORATION_BORDER_TOT_Y);
|
|
|
|
|
|
|
|
/* Border: */
|
|
|
|
if (deco->focused)
|
|
|
|
border_state = GTK_STATE_SELECTED;
|
|
|
|
else
|
|
|
|
border_state = GTK_STATE_PRELIGHT;
|
|
|
|
|
|
|
|
gtk_paint_box (widget->style, frame, border_state,
|
|
|
|
GTK_SHADOW_OUT, area, widget, "base",
|
|
|
|
0, 0, width, height);
|
|
|
|
|
|
|
|
gtk_paint_box (widget->style, frame, border_state,
|
|
|
|
GTK_SHADOW_IN, area, widget, "base",
|
|
|
|
DECORATION_BORDER_LEFT - 2, DECORATION_BORDER_TOP - 2,
|
|
|
|
width - (DECORATION_BORDER_LEFT + DECORATION_BORDER_RIGHT) + 3,
|
|
|
|
height - (DECORATION_BORDER_TOP + DECORATION_BORDER_BOTTOM) + 3);
|
2010-07-15 11:05:57 +00:00
|
|
|
|
|
|
|
cr = gdk_cairo_create (frame);
|
|
|
|
cairo_set_line_width (cr, 1.0);
|
|
|
|
cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
|
|
|
|
|
|
|
|
if (area)
|
|
|
|
{
|
|
|
|
gdk_cairo_rectangle (cr, &area);
|
|
|
|
cairo_clip (cr);
|
|
|
|
}
|
implement maximize for linux-fb
Thu Oct 3 16:40:18 2002 Eric Warmenhoven <eric@warmenhoven.org>
* gdk/gdkevents.c, gdk/linux-fb/gdkwindow-fb.c,
gtk/gtkwindow-decorate.c: implement maximize for linux-fb
* gdk/linux-fb/gdkkeyboard-fb.c: implement raw keyboard mode
* gdk/linux-fb/Makefile.am, gdk/linux-fb/gdkdnd-fb.c,
gdk/linux-fb/gdkmain-fb.c, gdk/linux-fb/gdkselection-fb.c,
gdk/linux-fb/miarc.c, gdk/linux-fb/mifpolycon.c,
gdk/linux-fb/miwideline.c, gdk/linux-fb/mizerclip.c,
gdk/linux-fb/mizerline.c: small cleanups
2002-10-03 23:45:03 +00:00
|
|
|
|
|
|
|
if (deco->maximizable)
|
|
|
|
{
|
|
|
|
/* Maximize button: */
|
|
|
|
|
|
|
|
x1 = width - (DECORATION_BORDER_LEFT * 2) - (DECORATION_BUTTON_SIZE * 2);
|
|
|
|
y1 = DECORATION_BUTTON_Y_OFFSET;
|
|
|
|
x2 = x1 + DECORATION_BUTTON_SIZE;
|
|
|
|
y2 = y1 + DECORATION_BUTTON_SIZE;
|
|
|
|
|
2010-07-15 11:05:57 +00:00
|
|
|
gdk_cairo_set_source_color (cr, &widget->style->bg[widget->state]);
|
|
|
|
cairo_rectangle (cr, x1, y1, x2 - x1, y2 - y1);
|
|
|
|
cairo_fill (cr);
|
implement maximize for linux-fb
Thu Oct 3 16:40:18 2002 Eric Warmenhoven <eric@warmenhoven.org>
* gdk/gdkevents.c, gdk/linux-fb/gdkwindow-fb.c,
gtk/gtkwindow-decorate.c: implement maximize for linux-fb
* gdk/linux-fb/gdkkeyboard-fb.c: implement raw keyboard mode
* gdk/linux-fb/Makefile.am, gdk/linux-fb/gdkdnd-fb.c,
gdk/linux-fb/gdkmain-fb.c, gdk/linux-fb/gdkselection-fb.c,
gdk/linux-fb/miarc.c, gdk/linux-fb/mifpolycon.c,
gdk/linux-fb/miwideline.c, gdk/linux-fb/mizerclip.c,
gdk/linux-fb/mizerline.c: small cleanups
2002-10-03 23:45:03 +00:00
|
|
|
|
2010-07-15 11:05:57 +00:00
|
|
|
gdk_cairo_set_source_rgb (cr, 0, 0, 0);
|
|
|
|
cairo_rectangle (cr, x1 + 1, y1 + 1, x2 - x1 - 3, 1);
|
|
|
|
cairo_move_to (cr, x1 + 1.5, y1 + 1.5);
|
|
|
|
cairo_line_to (cr, x2 - 1.5, y1 + 1.5);
|
|
|
|
cairo_rectangle (cr, x1 + 1.5, y1 + 2.5, DECORATION_BUTTON_SIZE - 3, DECORATION_BUTTON_SIZE - 4);
|
|
|
|
cairo_stroke (cr);
|
implement maximize for linux-fb
Thu Oct 3 16:40:18 2002 Eric Warmenhoven <eric@warmenhoven.org>
* gdk/gdkevents.c, gdk/linux-fb/gdkwindow-fb.c,
gtk/gtkwindow-decorate.c: implement maximize for linux-fb
* gdk/linux-fb/gdkkeyboard-fb.c: implement raw keyboard mode
* gdk/linux-fb/Makefile.am, gdk/linux-fb/gdkdnd-fb.c,
gdk/linux-fb/gdkmain-fb.c, gdk/linux-fb/gdkselection-fb.c,
gdk/linux-fb/miarc.c, gdk/linux-fb/mifpolycon.c,
gdk/linux-fb/miwideline.c, gdk/linux-fb/mizerclip.c,
gdk/linux-fb/mizerline.c: small cleanups
2002-10-03 23:45:03 +00:00
|
|
|
}
|
2001-01-08 17:04:17 +00:00
|
|
|
|
|
|
|
/* Close button: */
|
|
|
|
|
|
|
|
x1 = width - DECORATION_BORDER_LEFT - DECORATION_BUTTON_SIZE;
|
|
|
|
y1 = DECORATION_BUTTON_Y_OFFSET;
|
|
|
|
x2 = width - DECORATION_BORDER_LEFT;
|
|
|
|
y2 = DECORATION_BUTTON_Y_OFFSET + DECORATION_BUTTON_SIZE;
|
|
|
|
|
2010-07-15 11:05:57 +00:00
|
|
|
gdk_cairo_set_source_color (cr, &widget->style->bg[widget->state]);
|
|
|
|
cairo_rectangle (cr, x1, y1, x2 - x1, y2 - y1);
|
|
|
|
cairo_fill (cr);
|
2001-01-08 17:04:17 +00:00
|
|
|
|
2010-07-15 11:05:57 +00:00
|
|
|
/* draw an X */
|
|
|
|
cairo_move_to (cr, x1 + 0.5, y1 + 0.5);
|
|
|
|
cairo_line_to (cr, x2 - 0.5, y2 - 0.5);
|
|
|
|
cairo_move_to (cr, x1 + 0.5, y2 - 0.5);
|
|
|
|
cairo_line_to (cr, x2 - 0.5, y1 + 0.5);
|
|
|
|
cairo_stroke (cr);
|
2001-01-08 17:04:17 +00:00
|
|
|
|
|
|
|
/* Title */
|
|
|
|
if (deco->title_layout)
|
|
|
|
{
|
2010-07-21 11:20:22 +00:00
|
|
|
gdk_cairo_set_source_color (cr, widget->style->fg [border_state]);
|
|
|
|
pango_cairo_show_layout (cr, deco->title_layout);
|
2001-01-08 17:04:17 +00:00
|
|
|
}
|
2010-07-15 11:05:57 +00:00
|
|
|
|
|
|
|
cairo_destroy (cr);
|
2001-01-08 17:04:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_decorated_window_recalculate_regions (GtkWindow *window)
|
|
|
|
{
|
|
|
|
gint n_regions;
|
|
|
|
gint width, height;
|
|
|
|
GtkWindowRegion *region;
|
|
|
|
GtkWindowDecoration *deco = get_decoration (window);
|
|
|
|
|
|
|
|
n_regions = 0;
|
|
|
|
|
|
|
|
if (!deco->decorated)
|
|
|
|
return;
|
|
|
|
|
|
|
|
n_regions += 2; /* close, Title */
|
implement maximize for linux-fb
Thu Oct 3 16:40:18 2002 Eric Warmenhoven <eric@warmenhoven.org>
* gdk/gdkevents.c, gdk/linux-fb/gdkwindow-fb.c,
gtk/gtkwindow-decorate.c: implement maximize for linux-fb
* gdk/linux-fb/gdkkeyboard-fb.c: implement raw keyboard mode
* gdk/linux-fb/Makefile.am, gdk/linux-fb/gdkdnd-fb.c,
gdk/linux-fb/gdkmain-fb.c, gdk/linux-fb/gdkselection-fb.c,
gdk/linux-fb/miarc.c, gdk/linux-fb/mifpolycon.c,
gdk/linux-fb/miwideline.c, gdk/linux-fb/mizerclip.c,
gdk/linux-fb/mizerline.c: small cleanups
2002-10-03 23:45:03 +00:00
|
|
|
if (deco->maximizable)
|
|
|
|
n_regions += 1;
|
2010-08-07 15:07:17 +00:00
|
|
|
if (gtk_window_get_resizable (window))
|
2001-01-08 17:04:17 +00:00
|
|
|
n_regions += 2;
|
|
|
|
|
|
|
|
if (deco->n_regions != n_regions)
|
|
|
|
{
|
|
|
|
g_free (deco->regions);
|
|
|
|
deco->regions = g_new (GtkWindowRegion, n_regions);
|
|
|
|
deco->n_regions = n_regions;
|
|
|
|
}
|
|
|
|
|
|
|
|
width = GTK_WIDGET (window)->allocation.width + DECORATION_BORDER_TOT_X;
|
|
|
|
height = GTK_WIDGET (window)->allocation.height + DECORATION_BORDER_TOT_Y;
|
|
|
|
|
|
|
|
region = deco->regions;
|
|
|
|
|
implement maximize for linux-fb
Thu Oct 3 16:40:18 2002 Eric Warmenhoven <eric@warmenhoven.org>
* gdk/gdkevents.c, gdk/linux-fb/gdkwindow-fb.c,
gtk/gtkwindow-decorate.c: implement maximize for linux-fb
* gdk/linux-fb/gdkkeyboard-fb.c: implement raw keyboard mode
* gdk/linux-fb/Makefile.am, gdk/linux-fb/gdkdnd-fb.c,
gdk/linux-fb/gdkmain-fb.c, gdk/linux-fb/gdkselection-fb.c,
gdk/linux-fb/miarc.c, gdk/linux-fb/mifpolycon.c,
gdk/linux-fb/miwideline.c, gdk/linux-fb/mizerclip.c,
gdk/linux-fb/mizerline.c: small cleanups
2002-10-03 23:45:03 +00:00
|
|
|
/* Maximize button */
|
|
|
|
if (deco->maximizable)
|
|
|
|
{
|
|
|
|
region->rect.x = width - (DECORATION_BORDER_LEFT * 2) - (DECORATION_BUTTON_SIZE * 2);
|
|
|
|
region->rect.y = DECORATION_BUTTON_Y_OFFSET;
|
|
|
|
region->rect.width = DECORATION_BUTTON_SIZE;
|
|
|
|
region->rect.height = DECORATION_BUTTON_SIZE;
|
|
|
|
region->type = GTK_WINDOW_REGION_MAXIMIZE;
|
|
|
|
region++;
|
|
|
|
}
|
|
|
|
|
2001-01-08 17:04:17 +00:00
|
|
|
/* Close button */
|
|
|
|
region->rect.x = width - DECORATION_BORDER_LEFT - DECORATION_BUTTON_SIZE;
|
implement maximize for linux-fb
Thu Oct 3 16:40:18 2002 Eric Warmenhoven <eric@warmenhoven.org>
* gdk/gdkevents.c, gdk/linux-fb/gdkwindow-fb.c,
gtk/gtkwindow-decorate.c: implement maximize for linux-fb
* gdk/linux-fb/gdkkeyboard-fb.c: implement raw keyboard mode
* gdk/linux-fb/Makefile.am, gdk/linux-fb/gdkdnd-fb.c,
gdk/linux-fb/gdkmain-fb.c, gdk/linux-fb/gdkselection-fb.c,
gdk/linux-fb/miarc.c, gdk/linux-fb/mifpolycon.c,
gdk/linux-fb/miwideline.c, gdk/linux-fb/mizerclip.c,
gdk/linux-fb/mizerline.c: small cleanups
2002-10-03 23:45:03 +00:00
|
|
|
region->rect.y = DECORATION_BUTTON_Y_OFFSET;
|
2001-01-08 17:04:17 +00:00
|
|
|
region->rect.width = DECORATION_BUTTON_SIZE;
|
|
|
|
region->rect.height = DECORATION_BUTTON_SIZE;
|
|
|
|
region->type = GTK_WINDOW_REGION_CLOSE;
|
|
|
|
region++;
|
|
|
|
|
|
|
|
/* title bar */
|
|
|
|
region->rect.x = 0;
|
|
|
|
region->rect.y = 0;
|
|
|
|
region->rect.width = width;
|
|
|
|
region->rect.height = DECORATION_BORDER_TOP;
|
|
|
|
region->type = GTK_WINDOW_REGION_TITLE;
|
|
|
|
region++;
|
|
|
|
|
2010-08-07 15:07:17 +00:00
|
|
|
if (gtk_window_get_resizable (window))
|
2001-01-08 17:04:17 +00:00
|
|
|
{
|
|
|
|
region->rect.x = width - (DECORATION_BORDER_RIGHT + 10);
|
|
|
|
region->rect.y = height - DECORATION_BORDER_BOTTOM;
|
|
|
|
region->rect.width = DECORATION_BORDER_RIGHT + 10;
|
|
|
|
region->rect.height = DECORATION_BORDER_BOTTOM;
|
|
|
|
region->type = GTK_WINDOW_REGION_BR_RESIZE;
|
|
|
|
region++;
|
|
|
|
|
|
|
|
region->rect.x = width - DECORATION_BORDER_RIGHT;
|
|
|
|
region->rect.y = height - (DECORATION_BORDER_BOTTOM + 10);
|
|
|
|
region->rect.width = DECORATION_BORDER_RIGHT;
|
|
|
|
region->rect.height = DECORATION_BORDER_BOTTOM + 10;
|
|
|
|
region->type = GTK_WINDOW_REGION_BR_RESIZE;
|
|
|
|
region++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gtk_decorated_window_move_resize_window (GtkWindow *window,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint width,
|
|
|
|
gint height)
|
|
|
|
{
|
|
|
|
GtkWidget *widget = GTK_WIDGET (window);
|
|
|
|
GtkWindowDecoration *deco = get_decoration (window);
|
|
|
|
|
|
|
|
deco->real_inner_move = TRUE;
|
2001-01-22 12:40:35 +00:00
|
|
|
gdk_window_move_resize (widget->window,
|
2001-01-08 17:04:17 +00:00
|
|
|
x, y, width, height);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
|
|
|
|
void
|
|
|
|
gtk_decorated_window_init (GtkWindow *window)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gtk_decorated_window_calculate_frame_size (GtkWindow *window)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gtk_decorated_window_set_title (GtkWindow *window,
|
|
|
|
const gchar *title)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gtk_decorated_window_move_resize_window (GtkWindow *window,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint width,
|
|
|
|
gint height)
|
|
|
|
{
|
2010-08-11 20:03:51 +00:00
|
|
|
gdk_window_move_resize (gtk_widget_get_window (GTK_WIDGET (window)),
|
2001-01-08 17:04:17 +00:00
|
|
|
x, y, width, height);
|
|
|
|
}
|
|
|
|
#endif
|