aboutsummaryrefslogtreecommitdiffstats
path: root/src/gtkutil.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gtkutil.c')
-rw-r--r--src/gtkutil.c76
1 files changed, 66 insertions, 10 deletions
diff --git a/src/gtkutil.c b/src/gtkutil.c
index dedb39a7a40..45f112ae9e5 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -42,6 +42,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
42 42
43#ifdef HAVE_GTK3 43#ifdef HAVE_GTK3
44#include <gtk/gtkx.h> 44#include <gtk/gtkx.h>
45#include "emacsgtkfixed.h"
45#endif 46#endif
46 47
47#define FRAME_TOTAL_PIXEL_HEIGHT(f) \ 48#define FRAME_TOTAL_PIXEL_HEIGHT(f) \
@@ -88,12 +89,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
88 89
89#define XG_BIN_CHILD(x) gtk_bin_get_child (GTK_BIN (x)) 90#define XG_BIN_CHILD(x) gtk_bin_get_child (GTK_BIN (x))
90 91
91/* Get the current value of the range, truncated to an integer. */ 92static void update_theme_scrollbar_width (void);
92static int
93int_gtk_range_get_value (GtkRange *range)
94{
95 return gtk_range_get_value (range);
96}
97 93
98 94
99/*********************************************************************** 95/***********************************************************************
@@ -1015,6 +1011,7 @@ style_changed_cb (GObject *go,
1015 struct input_event event; 1011 struct input_event event;
1016 GdkDisplay *gdpy = (GdkDisplay *) user_data; 1012 GdkDisplay *gdpy = (GdkDisplay *) user_data;
1017 const char *display_name = gdk_display_get_name (gdpy); 1013 const char *display_name = gdk_display_get_name (gdpy);
1014 Display *dpy = GDK_DISPLAY_XDISPLAY (gdpy);
1018 1015
1019 EVENT_INIT (event); 1016 EVENT_INIT (event);
1020 event.kind = CONFIG_CHANGED_EVENT; 1017 event.kind = CONFIG_CHANGED_EVENT;
@@ -1022,6 +1019,24 @@ style_changed_cb (GObject *go,
1022 /* Theme doesn't change often, so intern is called seldom. */ 1019 /* Theme doesn't change often, so intern is called seldom. */
1023 event.arg = intern ("theme-name"); 1020 event.arg = intern ("theme-name");
1024 kbd_buffer_store_event (&event); 1021 kbd_buffer_store_event (&event);
1022
1023 update_theme_scrollbar_width ();
1024
1025 /* If scroll bar width changed, we need set the new size on all frames
1026 on this display. */
1027 if (dpy)
1028 {
1029 Lisp_Object rest, frame;
1030 FOR_EACH_FRAME (rest, frame)
1031 {
1032 FRAME_PTR f = XFRAME (frame);
1033 if (FRAME_X_DISPLAY (f) == dpy)
1034 {
1035 x_set_scroll_bar_default_width (f);
1036 xg_frame_set_char_size (f, FRAME_COLS (f), FRAME_LINES (f));
1037 }
1038 }
1039 }
1025} 1040}
1026 1041
1027/* Called when a delete-event occurs on WIDGET. */ 1042/* Called when a delete-event occurs on WIDGET. */
@@ -1069,7 +1084,12 @@ xg_create_frame_widgets (FRAME_PTR f)
1069 1084
1070 wvbox = gtk_vbox_new (FALSE, 0); 1085 wvbox = gtk_vbox_new (FALSE, 0);
1071 whbox = gtk_hbox_new (FALSE, 0); 1086 whbox = gtk_hbox_new (FALSE, 0);
1072 wfixed = gtk_fixed_new (); /* Must have this to place scroll bars */ 1087
1088#ifdef HAVE_GTK3
1089 wfixed = emacs_fixed_new ();
1090#else
1091 wfixed = gtk_fixed_new ();
1092#endif
1073 1093
1074 if (! wtop || ! wvbox || ! whbox || ! wfixed) 1094 if (! wtop || ! wvbox || ! whbox || ! wfixed)
1075 { 1095 {
@@ -1162,6 +1182,7 @@ xg_create_frame_widgets (FRAME_PTR f)
1162 gtk_widget_modify_style (wfixed, style); 1182 gtk_widget_modify_style (wfixed, style);
1163#else 1183#else
1164 gtk_widget_set_can_focus (wfixed, TRUE); 1184 gtk_widget_set_can_focus (wfixed, TRUE);
1185 gtk_window_set_resizable (GTK_WINDOW (wtop), TRUE);
1165#endif 1186#endif
1166 1187
1167#ifdef USE_GTK_TOOLTIP 1188#ifdef USE_GTK_TOOLTIP
@@ -1265,6 +1286,18 @@ x_wm_set_size_hint (FRAME_PTR f, long int flags, int user_position)
1265 size_hints.min_width = base_width + min_cols * size_hints.width_inc; 1286 size_hints.min_width = base_width + min_cols * size_hints.width_inc;
1266 size_hints.min_height = base_height + min_rows * size_hints.height_inc; 1287 size_hints.min_height = base_height + min_rows * size_hints.height_inc;
1267 1288
1289#ifdef HAVE_GTK3
1290 /* Gtk3 ignores min width/height and overwrites them with its own idea
1291 of min width/height. Put out min values to the widget so Gtk
1292 gets the same value we want it to be. Without this, a user can't
1293 shrink an Emacs frame.
1294 */
1295 if (FRAME_GTK_WIDGET (f))
1296 emacs_fixed_set_min_size (EMACS_FIXED (FRAME_GTK_WIDGET (f)),
1297 size_hints.min_width,
1298 size_hints.min_height);
1299#endif
1300
1268 /* These currently have a one to one mapping with the X values, but I 1301 /* These currently have a one to one mapping with the X values, but I
1269 don't think we should rely on that. */ 1302 don't think we should rely on that. */
1270 hint_flags |= GDK_HINT_WIN_GRAVITY; 1303 hint_flags |= GDK_HINT_WIN_GRAVITY;
@@ -3250,6 +3283,10 @@ xg_event_is_for_menubar (FRAME_PTR f, XEvent *event)
3250 3283
3251int xg_ignore_gtk_scrollbar; 3284int xg_ignore_gtk_scrollbar;
3252 3285
3286/* The width of the scroll bar for the current theme. */
3287
3288static int scroll_bar_width_for_theme;
3289
3253/* Xlib's `Window' fits in 32 bits. But we want to store pointers, and they 3290/* Xlib's `Window' fits in 32 bits. But we want to store pointers, and they
3254 may be larger than 32 bits. Keep a mapping from integer index to widget 3291 may be larger than 32 bits. Keep a mapping from integer index to widget
3255 pointers to get around the 32 bit limitation. */ 3292 pointers to get around the 32 bit limitation. */
@@ -3326,8 +3363,8 @@ xg_get_widget_from_map (int idx)
3326 return 0; 3363 return 0;
3327} 3364}
3328 3365
3329int 3366static void
3330xg_get_default_scrollbar_width (FRAME_PTR f) 3367update_theme_scrollbar_width (void)
3331{ 3368{
3332#ifdef HAVE_GTK3 3369#ifdef HAVE_GTK3
3333 GtkAdjustment *vadj; 3370 GtkAdjustment *vadj;
@@ -3336,13 +3373,22 @@ xg_get_default_scrollbar_width (FRAME_PTR f)
3336#endif 3373#endif
3337 GtkWidget *wscroll; 3374 GtkWidget *wscroll;
3338 int w = 0, b = 0; 3375 int w = 0, b = 0;
3376
3339 vadj = gtk_adjustment_new (XG_SB_MIN, XG_SB_MIN, XG_SB_MAX, 0.1, 0.1, 0.1); 3377 vadj = gtk_adjustment_new (XG_SB_MIN, XG_SB_MIN, XG_SB_MAX, 0.1, 0.1, 0.1);
3340 wscroll = gtk_vscrollbar_new (GTK_ADJUSTMENT (vadj)); 3378 wscroll = gtk_vscrollbar_new (GTK_ADJUSTMENT (vadj));
3379 g_object_ref_sink (G_OBJECT (wscroll));
3341 gtk_widget_style_get (wscroll, "slider-width", &w, "trough-border", &b, NULL); 3380 gtk_widget_style_get (wscroll, "slider-width", &w, "trough-border", &b, NULL);
3342 gtk_widget_destroy (wscroll); 3381 gtk_widget_destroy (wscroll);
3382 g_object_unref (G_OBJECT (wscroll));
3343 w += 2*b; 3383 w += 2*b;
3344 if (w < 16) w = 16; 3384 if (w < 16) w = 16;
3345 return w; 3385 scroll_bar_width_for_theme = w;
3386}
3387
3388int
3389xg_get_default_scrollbar_width (void)
3390{
3391 return scroll_bar_width_for_theme;
3346} 3392}
3347 3393
3348/* Return the scrollbar id for X Window WID on display DPY. 3394/* Return the scrollbar id for X Window WID on display DPY.
@@ -3528,6 +3574,15 @@ xg_update_scrollbar_pos (FRAME_PTR f,
3528 } 3574 }
3529} 3575}
3530 3576
3577/* Get the current value of the range, truncated to an integer. */
3578
3579static int
3580int_gtk_range_get_value (GtkRange *range)
3581{
3582 return gtk_range_get_value (range);
3583}
3584
3585
3531/* Set the thumb size and position of scroll bar BAR. We are currently 3586/* Set the thumb size and position of scroll bar BAR. We are currently
3532 displaying PORTION out of a whole WHOLE, and our position POSITION. */ 3587 displaying PORTION out of a whole WHOLE, and our position POSITION. */
3533 3588
@@ -4680,6 +4735,7 @@ xg_initialize (void)
4680 (GTK_TYPE_MENU_SHELL)); 4735 (GTK_TYPE_MENU_SHELL));
4681 gtk_binding_entry_add_signal (binding_set, GDK_KEY_g, GDK_CONTROL_MASK, 4736 gtk_binding_entry_add_signal (binding_set, GDK_KEY_g, GDK_CONTROL_MASK,
4682 "cancel", 0); 4737 "cancel", 0);
4738 update_theme_scrollbar_width ();
4683} 4739}
4684 4740
4685#endif /* USE_GTK */ 4741#endif /* USE_GTK */