2011-12-04 00:02:42 -08:00
|
|
|
/* A Gtk Widget that inherits GtkFixed, but can be shrunk.
|
2011-06-26 20:47:07 +02:00
|
|
|
This file is only use when compiling with Gtk+ 3.
|
2011-06-14 23:08:20 +02:00
|
|
|
|
2015-01-01 14:26:41 -08:00
|
|
|
Copyright (C) 2011-2015 Free Software Foundation, Inc.
|
2011-06-14 23:08:20 +02:00
|
|
|
|
|
|
|
This file is part of GNU Emacs.
|
|
|
|
|
|
|
|
GNU Emacs 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 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
GNU Emacs 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 GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
|
|
|
|
|
2011-06-26 20:47:07 +02:00
|
|
|
#include <config.h>
|
2011-06-14 23:08:20 +02:00
|
|
|
|
2011-06-26 20:47:07 +02:00
|
|
|
#include "lisp.h"
|
|
|
|
#include "frame.h"
|
|
|
|
#include "xterm.h"
|
2013-09-10 23:52:26 +02:00
|
|
|
#include "emacsgtkfixed.h"
|
|
|
|
|
2012-09-12 18:22:08 -07:00
|
|
|
/* Silence a bogus diagnostic; see GNOME bug 683906. */
|
2013-07-23 07:38:51 +01:00
|
|
|
#if 4 < __GNUC__ + (7 <= __GNUC_MINOR__)
|
2012-09-12 21:14:33 -07:00
|
|
|
# pragma GCC diagnostic push
|
|
|
|
# pragma GCC diagnostic ignored "-Wunused-local-typedefs"
|
|
|
|
#endif
|
2012-09-12 18:22:08 -07:00
|
|
|
|
2015-02-01 11:39:36 -08:00
|
|
|
#define EMACS_TYPE_FIXED emacs_fixed_get_type ()
|
|
|
|
#define EMACS_FIXED(obj) \
|
|
|
|
G_TYPE_CHECK_INSTANCE_CAST (obj, EMACS_TYPE_FIXED, EmacsFixed)
|
Fix minor GTK3 problems found by static checking.
* emacsgtkfixed.c (EMACS_TYPE_FIXED, EMACS_FIXED, EmacsFixed)
(EmacsFixedPrivate, EmacsFixedClass, struct _EmacsFixed)
(struct _EmacsFixedClass, emacs_fixed_get_type):
Move decls here from emacsgtkfixed.h, since they needn't be public.
(emacs_fixed_get_type): Now static.
(emacs_fixed_class_init): Omit unused local.
(emacs_fixed_child_type): Remove; unused.
* emacsgtkfixed.h (EMACS_TYPE_FIXED, EMACS_FIXED, EmacsFixed)
(EmacsFixedPrivate, EmacsFixedClass, struct _EmacsFixed)
(struct _EmacsFixedClass): Move to emacsgtkfixed.c.
(EMACS_FIXED_CLASS, EMACS_IS_FIXED, EMACS_IS_FIXED_CLASS)
(EMACS_FIXED_GET_CLASS): Remove; unused.
* gtkutil.c (xg_create_frame_widgets) [!HAVE_GTK3]: Omit unused local.
2012-04-23 00:34:29 -07:00
|
|
|
|
|
|
|
typedef struct _EmacsFixed EmacsFixed;
|
|
|
|
typedef struct _EmacsFixedPrivate EmacsFixedPrivate;
|
|
|
|
typedef struct _EmacsFixedClass EmacsFixedClass;
|
|
|
|
|
2015-02-01 11:39:36 -08:00
|
|
|
struct _EmacsFixed
|
|
|
|
{
|
|
|
|
GtkFixed container;
|
Fix minor GTK3 problems found by static checking.
* emacsgtkfixed.c (EMACS_TYPE_FIXED, EMACS_FIXED, EmacsFixed)
(EmacsFixedPrivate, EmacsFixedClass, struct _EmacsFixed)
(struct _EmacsFixedClass, emacs_fixed_get_type):
Move decls here from emacsgtkfixed.h, since they needn't be public.
(emacs_fixed_get_type): Now static.
(emacs_fixed_class_init): Omit unused local.
(emacs_fixed_child_type): Remove; unused.
* emacsgtkfixed.h (EMACS_TYPE_FIXED, EMACS_FIXED, EmacsFixed)
(EmacsFixedPrivate, EmacsFixedClass, struct _EmacsFixed)
(struct _EmacsFixedClass): Move to emacsgtkfixed.c.
(EMACS_FIXED_CLASS, EMACS_IS_FIXED, EMACS_IS_FIXED_CLASS)
(EMACS_FIXED_GET_CLASS): Remove; unused.
* gtkutil.c (xg_create_frame_widgets) [!HAVE_GTK3]: Omit unused local.
2012-04-23 00:34:29 -07:00
|
|
|
|
2015-02-01 11:39:36 -08:00
|
|
|
/*< private >*/
|
|
|
|
EmacsFixedPrivate *priv;
|
|
|
|
};
|
Fix minor GTK3 problems found by static checking.
* emacsgtkfixed.c (EMACS_TYPE_FIXED, EMACS_FIXED, EmacsFixed)
(EmacsFixedPrivate, EmacsFixedClass, struct _EmacsFixed)
(struct _EmacsFixedClass, emacs_fixed_get_type):
Move decls here from emacsgtkfixed.h, since they needn't be public.
(emacs_fixed_get_type): Now static.
(emacs_fixed_class_init): Omit unused local.
(emacs_fixed_child_type): Remove; unused.
* emacsgtkfixed.h (EMACS_TYPE_FIXED, EMACS_FIXED, EmacsFixed)
(EmacsFixedPrivate, EmacsFixedClass, struct _EmacsFixed)
(struct _EmacsFixedClass): Move to emacsgtkfixed.c.
(EMACS_FIXED_CLASS, EMACS_IS_FIXED, EMACS_IS_FIXED_CLASS)
(EMACS_FIXED_GET_CLASS): Remove; unused.
* gtkutil.c (xg_create_frame_widgets) [!HAVE_GTK3]: Omit unused local.
2012-04-23 00:34:29 -07:00
|
|
|
|
2015-02-01 11:39:36 -08:00
|
|
|
struct _EmacsFixedClass
|
|
|
|
{
|
|
|
|
GtkFixedClass parent_class;
|
|
|
|
};
|
Fix minor GTK3 problems found by static checking.
* emacsgtkfixed.c (EMACS_TYPE_FIXED, EMACS_FIXED, EmacsFixed)
(EmacsFixedPrivate, EmacsFixedClass, struct _EmacsFixed)
(struct _EmacsFixedClass, emacs_fixed_get_type):
Move decls here from emacsgtkfixed.h, since they needn't be public.
(emacs_fixed_get_type): Now static.
(emacs_fixed_class_init): Omit unused local.
(emacs_fixed_child_type): Remove; unused.
* emacsgtkfixed.h (EMACS_TYPE_FIXED, EMACS_FIXED, EmacsFixed)
(EmacsFixedPrivate, EmacsFixedClass, struct _EmacsFixed)
(struct _EmacsFixedClass): Move to emacsgtkfixed.c.
(EMACS_FIXED_CLASS, EMACS_IS_FIXED, EMACS_IS_FIXED_CLASS)
(EMACS_FIXED_GET_CLASS): Remove; unused.
* gtkutil.c (xg_create_frame_widgets) [!HAVE_GTK3]: Omit unused local.
2012-04-23 00:34:29 -07:00
|
|
|
|
2011-06-14 23:08:20 +02:00
|
|
|
struct _EmacsFixedPrivate
|
|
|
|
{
|
2011-06-26 20:47:07 +02:00
|
|
|
struct frame *f;
|
2011-06-14 23:08:20 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static void emacs_fixed_get_preferred_width (GtkWidget *widget,
|
|
|
|
gint *minimum,
|
|
|
|
gint *natural);
|
|
|
|
static void emacs_fixed_get_preferred_height (GtkWidget *widget,
|
|
|
|
gint *minimum,
|
|
|
|
gint *natural);
|
2015-02-01 11:39:36 -08:00
|
|
|
static GType emacs_fixed_get_type (void);
|
2011-06-14 23:08:20 +02:00
|
|
|
G_DEFINE_TYPE (EmacsFixed, emacs_fixed, GTK_TYPE_FIXED)
|
|
|
|
|
|
|
|
static void
|
|
|
|
emacs_fixed_class_init (EmacsFixedClass *klass)
|
|
|
|
{
|
|
|
|
GtkWidgetClass *widget_class;
|
|
|
|
|
|
|
|
widget_class = (GtkWidgetClass*) klass;
|
|
|
|
|
|
|
|
widget_class->get_preferred_width = emacs_fixed_get_preferred_width;
|
|
|
|
widget_class->get_preferred_height = emacs_fixed_get_preferred_height;
|
|
|
|
g_type_class_add_private (klass, sizeof (EmacsFixedPrivate));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
emacs_fixed_init (EmacsFixed *fixed)
|
|
|
|
{
|
|
|
|
fixed->priv = G_TYPE_INSTANCE_GET_PRIVATE (fixed, EMACS_TYPE_FIXED,
|
|
|
|
EmacsFixedPrivate);
|
2011-06-26 20:47:07 +02:00
|
|
|
fixed->priv->f = 0;
|
2011-06-14 23:08:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* emacs_fixed_new:
|
|
|
|
*
|
|
|
|
* Creates a new #EmacsFixed.
|
|
|
|
*
|
|
|
|
* Returns: a new #EmacsFixed.
|
|
|
|
*/
|
|
|
|
GtkWidget*
|
2011-06-26 20:47:07 +02:00
|
|
|
emacs_fixed_new (struct frame *f)
|
2011-06-14 23:08:20 +02:00
|
|
|
{
|
2011-06-26 20:47:07 +02:00
|
|
|
EmacsFixed *fixed = g_object_new (EMACS_TYPE_FIXED, NULL);
|
|
|
|
EmacsFixedPrivate *priv = fixed->priv;
|
|
|
|
priv->f = f;
|
|
|
|
return GTK_WIDGET (fixed);
|
2011-06-14 23:08:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
emacs_fixed_get_preferred_width (GtkWidget *widget,
|
|
|
|
gint *minimum,
|
|
|
|
gint *natural)
|
|
|
|
{
|
|
|
|
EmacsFixed *fixed = EMACS_FIXED (widget);
|
|
|
|
EmacsFixedPrivate *priv = fixed->priv;
|
2011-06-26 20:47:07 +02:00
|
|
|
int w = priv->f->output_data.x->size_hints.min_width;
|
|
|
|
if (minimum) *minimum = w;
|
|
|
|
if (natural) *natural = w;
|
2011-06-14 23:08:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
emacs_fixed_get_preferred_height (GtkWidget *widget,
|
|
|
|
gint *minimum,
|
|
|
|
gint *natural)
|
|
|
|
{
|
|
|
|
EmacsFixed *fixed = EMACS_FIXED (widget);
|
|
|
|
EmacsFixedPrivate *priv = fixed->priv;
|
2011-06-26 20:47:07 +02:00
|
|
|
int h = priv->f->output_data.x->size_hints.min_height;
|
|
|
|
if (minimum) *minimum = h;
|
|
|
|
if (natural) *natural = h;
|
2011-06-14 23:08:20 +02:00
|
|
|
}
|
|
|
|
|
2011-06-26 20:47:07 +02:00
|
|
|
|
|
|
|
/* Override the X function so we can intercept Gtk+ 3 calls.
|
|
|
|
Use our values for min_width/height so that KDE don't freak out
|
|
|
|
(Bug#8919), and so users can resize our frames as they wish. */
|
|
|
|
|
2011-06-14 23:08:20 +02:00
|
|
|
void
|
2011-09-09 03:06:52 +02:00
|
|
|
XSetWMSizeHints (Display* d,
|
|
|
|
Window w,
|
|
|
|
XSizeHints* hints,
|
|
|
|
Atom prop)
|
2011-06-14 23:08:20 +02:00
|
|
|
{
|
2011-06-26 20:47:07 +02:00
|
|
|
struct x_display_info *dpyinfo = x_display_info_for_display (d);
|
|
|
|
struct frame *f = x_top_window_to_frame (dpyinfo, w);
|
|
|
|
long data[18];
|
|
|
|
data[0] = hints->flags;
|
|
|
|
data[1] = hints->x;
|
|
|
|
data[2] = hints->y;
|
|
|
|
data[3] = hints->width;
|
|
|
|
data[4] = hints->height;
|
|
|
|
data[5] = hints->min_width;
|
|
|
|
data[6] = hints->min_height;
|
|
|
|
data[7] = hints->max_width;
|
|
|
|
data[8] = hints->max_height;
|
|
|
|
data[9] = hints->width_inc;
|
|
|
|
data[10] = hints->height_inc;
|
|
|
|
data[11] = hints->min_aspect.x;
|
|
|
|
data[12] = hints->min_aspect.y;
|
|
|
|
data[13] = hints->max_aspect.x;
|
|
|
|
data[14] = hints->max_aspect.y;
|
|
|
|
data[15] = hints->base_width;
|
|
|
|
data[16] = hints->base_height;
|
|
|
|
data[17] = hints->win_gravity;
|
|
|
|
|
|
|
|
if ((hints->flags & PMinSize) && f)
|
|
|
|
{
|
|
|
|
int w = f->output_data.x->size_hints.min_width;
|
|
|
|
int h = f->output_data.x->size_hints.min_height;
|
|
|
|
data[5] = w;
|
|
|
|
data[6] = h;
|
|
|
|
}
|
|
|
|
|
|
|
|
XChangeProperty (d, w, prop, XA_WM_SIZE_HINTS, 32, PropModeReplace,
|
|
|
|
(unsigned char *) data, 18);
|
|
|
|
}
|
2011-06-14 23:08:20 +02:00
|
|
|
|
2011-06-26 20:47:07 +02:00
|
|
|
/* Override this X11 function.
|
|
|
|
This function is in the same X11 file as the one above. So we must
|
|
|
|
provide it also. */
|
2011-09-09 03:06:52 +02:00
|
|
|
|
2011-06-26 20:47:07 +02:00
|
|
|
void
|
|
|
|
XSetWMNormalHints (Display *d, Window w, XSizeHints *hints)
|
|
|
|
{
|
|
|
|
XSetWMSizeHints (d, w, hints, XA_WM_NORMAL_HINTS);
|
2011-06-14 23:08:20 +02:00
|
|
|
}
|