1 /* A Gtk Widget that inherits GtkFixed, but can be shrunk.
2 This file is only use when compiling with Gtk+ 3.
4 Copyright (C) 2011-2012 Free Software Foundation, Inc.
6 This file is part of GNU Emacs.
8 GNU Emacs is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
13 GNU Emacs is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
23 #include "emacsgtkfixed.h"
31 struct _EmacsFixedPrivate
37 static void emacs_fixed_get_preferred_width (GtkWidget
*widget
,
40 static void emacs_fixed_get_preferred_height (GtkWidget
*widget
,
43 G_DEFINE_TYPE (EmacsFixed
, emacs_fixed
, GTK_TYPE_FIXED
)
46 emacs_fixed_class_init (EmacsFixedClass
*klass
)
48 GtkWidgetClass
*widget_class
;
49 GtkFixedClass
*fixed_class
;
51 widget_class
= (GtkWidgetClass
*) klass
;
52 fixed_class
= (GtkFixedClass
*) klass
;
54 widget_class
->get_preferred_width
= emacs_fixed_get_preferred_width
;
55 widget_class
->get_preferred_height
= emacs_fixed_get_preferred_height
;
56 g_type_class_add_private (klass
, sizeof (EmacsFixedPrivate
));
60 emacs_fixed_child_type (GtkFixed
*container
)
62 return GTK_TYPE_WIDGET
;
66 emacs_fixed_init (EmacsFixed
*fixed
)
68 fixed
->priv
= G_TYPE_INSTANCE_GET_PRIVATE (fixed
, EMACS_TYPE_FIXED
,
76 * Creates a new #EmacsFixed.
78 * Returns: a new #EmacsFixed.
81 emacs_fixed_new (struct frame
*f
)
83 EmacsFixed
*fixed
= g_object_new (EMACS_TYPE_FIXED
, NULL
);
84 EmacsFixedPrivate
*priv
= fixed
->priv
;
86 return GTK_WIDGET (fixed
);
90 emacs_fixed_get_preferred_width (GtkWidget
*widget
,
94 EmacsFixed
*fixed
= EMACS_FIXED (widget
);
95 EmacsFixedPrivate
*priv
= fixed
->priv
;
96 int w
= priv
->f
->output_data
.x
->size_hints
.min_width
;
97 if (minimum
) *minimum
= w
;
98 if (natural
) *natural
= w
;
102 emacs_fixed_get_preferred_height (GtkWidget
*widget
,
106 EmacsFixed
*fixed
= EMACS_FIXED (widget
);
107 EmacsFixedPrivate
*priv
= fixed
->priv
;
108 int h
= priv
->f
->output_data
.x
->size_hints
.min_height
;
109 if (minimum
) *minimum
= h
;
110 if (natural
) *natural
= h
;
114 /* Override the X function so we can intercept Gtk+ 3 calls.
115 Use our values for min_width/height so that KDE don't freak out
116 (Bug#8919), and so users can resize our frames as they wish. */
119 XSetWMSizeHints (Display
* d
,
124 struct x_display_info
*dpyinfo
= x_display_info_for_display (d
);
125 struct frame
*f
= x_top_window_to_frame (dpyinfo
, w
);
127 data
[0] = hints
->flags
;
130 data
[3] = hints
->width
;
131 data
[4] = hints
->height
;
132 data
[5] = hints
->min_width
;
133 data
[6] = hints
->min_height
;
134 data
[7] = hints
->max_width
;
135 data
[8] = hints
->max_height
;
136 data
[9] = hints
->width_inc
;
137 data
[10] = hints
->height_inc
;
138 data
[11] = hints
->min_aspect
.x
;
139 data
[12] = hints
->min_aspect
.y
;
140 data
[13] = hints
->max_aspect
.x
;
141 data
[14] = hints
->max_aspect
.y
;
142 data
[15] = hints
->base_width
;
143 data
[16] = hints
->base_height
;
144 data
[17] = hints
->win_gravity
;
146 if ((hints
->flags
& PMinSize
) && f
)
148 int w
= f
->output_data
.x
->size_hints
.min_width
;
149 int h
= f
->output_data
.x
->size_hints
.min_height
;
154 XChangeProperty (d
, w
, prop
, XA_WM_SIZE_HINTS
, 32, PropModeReplace
,
155 (unsigned char *) data
, 18);
158 /* Override this X11 function.
159 This function is in the same X11 file as the one above. So we must
163 XSetWMNormalHints (Display
*d
, Window w
, XSizeHints
*hints
)
165 XSetWMSizeHints (d
, w
, hints
, XA_WM_NORMAL_HINTS
);