diff options
| author | Chong Yidong | 2008-10-06 16:17:14 +0000 |
|---|---|---|
| committer | Chong Yidong | 2008-10-06 16:17:14 +0000 |
| commit | 3e5fc571bd5a9bdbed786b43a7971c41f87c6ad8 (patch) | |
| tree | 210954d7d3d104b89de83ecfbaeb77ea52ac2ff6 | |
| parent | 90503d9633729365554f465f8e6f59c9f68bd95d (diff) | |
| download | emacs-3e5fc571bd5a9bdbed786b43a7971c41f87c6ad8.tar.gz emacs-3e5fc571bd5a9bdbed786b43a7971c41f87c6ad8.zip | |
(x_wm_set_size_hint): Return immediately if called during
initialization.
| -rw-r--r-- | src/gtkutil.c | 174 |
1 files changed, 86 insertions, 88 deletions
diff --git a/src/gtkutil.c b/src/gtkutil.c index 140796a015e..16c34325644 100644 --- a/src/gtkutil.c +++ b/src/gtkutil.c | |||
| @@ -934,97 +934,95 @@ x_wm_set_size_hint (f, flags, user_position) | |||
| 934 | long flags; | 934 | long flags; |
| 935 | int user_position; | 935 | int user_position; |
| 936 | { | 936 | { |
| 937 | if (FRAME_GTK_OUTER_WIDGET (f)) | 937 | /* Don't set size hints during initialization; that apparently leads |
| 938 | { | 938 | to a race condition. See the thread at |
| 939 | /* Must use GTK routines here, otherwise GTK resets the size hints | 939 | http://lists.gnu.org/archive/html/emacs-devel/2008-10/msg00033.html */ |
| 940 | to its own defaults. */ | 940 | if (NILP (Vafter_init_time) || !FRAME_GTK_OUTER_WIDGET (f)) |
| 941 | GdkGeometry size_hints; | 941 | return; |
| 942 | gint hint_flags = 0; | ||
| 943 | int base_width, base_height; | ||
| 944 | int min_rows = 0, min_cols = 0; | ||
| 945 | int win_gravity = f->win_gravity; | ||
| 946 | |||
| 947 | if (flags) | ||
| 948 | { | ||
| 949 | memset (&size_hints, 0, sizeof (size_hints)); | ||
| 950 | f->output_data.x->size_hints = size_hints; | ||
| 951 | f->output_data.x->hint_flags = hint_flags; | ||
| 952 | } | ||
| 953 | else | ||
| 954 | flags = f->size_hint_flags; | ||
| 955 | |||
| 956 | size_hints = f->output_data.x->size_hints; | ||
| 957 | hint_flags = f->output_data.x->hint_flags; | ||
| 958 | |||
| 959 | hint_flags |= GDK_HINT_RESIZE_INC | GDK_HINT_MIN_SIZE; | ||
| 960 | size_hints.width_inc = FRAME_COLUMN_WIDTH (f); | ||
| 961 | size_hints.height_inc = FRAME_LINE_HEIGHT (f); | ||
| 962 | |||
| 963 | hint_flags |= GDK_HINT_BASE_SIZE; | ||
| 964 | base_width = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, 0); | ||
| 965 | base_height = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, 0) | ||
| 966 | + FRAME_MENUBAR_HEIGHT (f) + FRAME_TOOLBAR_HEIGHT (f); | ||
| 967 | |||
| 968 | check_frame_size (f, &min_rows, &min_cols); | ||
| 969 | |||
| 970 | size_hints.base_width = base_width; | ||
| 971 | size_hints.base_height = base_height; | ||
| 972 | size_hints.min_width = base_width + min_cols * size_hints.width_inc; | ||
| 973 | size_hints.min_height = base_height + min_rows * size_hints.height_inc; | ||
| 974 | |||
| 975 | |||
| 976 | /* These currently have a one to one mapping with the X values, but I | ||
| 977 | don't think we should rely on that. */ | ||
| 978 | hint_flags |= GDK_HINT_WIN_GRAVITY; | ||
| 979 | size_hints.win_gravity = 0; | ||
| 980 | if (win_gravity == NorthWestGravity) | ||
| 981 | size_hints.win_gravity = GDK_GRAVITY_NORTH_WEST; | ||
| 982 | else if (win_gravity == NorthGravity) | ||
| 983 | size_hints.win_gravity = GDK_GRAVITY_NORTH; | ||
| 984 | else if (win_gravity == NorthEastGravity) | ||
| 985 | size_hints.win_gravity = GDK_GRAVITY_NORTH_EAST; | ||
| 986 | else if (win_gravity == WestGravity) | ||
| 987 | size_hints.win_gravity = GDK_GRAVITY_WEST; | ||
| 988 | else if (win_gravity == CenterGravity) | ||
| 989 | size_hints.win_gravity = GDK_GRAVITY_CENTER; | ||
| 990 | else if (win_gravity == EastGravity) | ||
| 991 | size_hints.win_gravity = GDK_GRAVITY_EAST; | ||
| 992 | else if (win_gravity == SouthWestGravity) | ||
| 993 | size_hints.win_gravity = GDK_GRAVITY_SOUTH_WEST; | ||
| 994 | else if (win_gravity == SouthGravity) | ||
| 995 | size_hints.win_gravity = GDK_GRAVITY_SOUTH; | ||
| 996 | else if (win_gravity == SouthEastGravity) | ||
| 997 | size_hints.win_gravity = GDK_GRAVITY_SOUTH_EAST; | ||
| 998 | else if (win_gravity == StaticGravity) | ||
| 999 | size_hints.win_gravity = GDK_GRAVITY_STATIC; | ||
| 1000 | |||
| 1001 | if (flags & PPosition) hint_flags |= GDK_HINT_POS; | ||
| 1002 | if (flags & USPosition) hint_flags |= GDK_HINT_USER_POS; | ||
| 1003 | if (flags & USSize) hint_flags |= GDK_HINT_USER_SIZE; | ||
| 1004 | |||
| 1005 | if (user_position) | ||
| 1006 | { | ||
| 1007 | hint_flags &= ~GDK_HINT_POS; | ||
| 1008 | hint_flags |= GDK_HINT_USER_POS; | ||
| 1009 | } | ||
| 1010 | 942 | ||
| 1011 | if (hint_flags != f->output_data.x->hint_flags | 943 | /* Must use GTK routines here, otherwise GTK resets the size hints |
| 1012 | || memcmp (&size_hints, | 944 | to its own defaults. */ |
| 1013 | &f->output_data.x->size_hints, | 945 | GdkGeometry size_hints; |
| 1014 | sizeof (size_hints)) != 0) | 946 | gint hint_flags = 0; |
| 1015 | { | 947 | int base_width, base_height; |
| 1016 | BLOCK_INPUT; | 948 | int min_rows = 0, min_cols = 0; |
| 949 | int win_gravity = f->win_gravity; | ||
| 1017 | 950 | ||
| 1018 | gtk_window_set_geometry_hints (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)), | 951 | if (flags) |
| 1019 | NULL, | 952 | { |
| 1020 | &size_hints, | 953 | memset (&size_hints, 0, sizeof (size_hints)); |
| 1021 | hint_flags); | 954 | f->output_data.x->size_hints = size_hints; |
| 955 | f->output_data.x->hint_flags = hint_flags; | ||
| 956 | } | ||
| 957 | else | ||
| 958 | flags = f->size_hint_flags; | ||
| 1022 | 959 | ||
| 1023 | f->output_data.x->size_hints = size_hints; | 960 | size_hints = f->output_data.x->size_hints; |
| 1024 | f->output_data.x->hint_flags = hint_flags; | 961 | hint_flags = f->output_data.x->hint_flags; |
| 1025 | UNBLOCK_INPUT; | 962 | |
| 1026 | } | 963 | hint_flags |= GDK_HINT_RESIZE_INC | GDK_HINT_MIN_SIZE; |
| 1027 | } | 964 | size_hints.width_inc = FRAME_COLUMN_WIDTH (f); |
| 965 | size_hints.height_inc = FRAME_LINE_HEIGHT (f); | ||
| 966 | |||
| 967 | hint_flags |= GDK_HINT_BASE_SIZE; | ||
| 968 | base_width = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, 0); | ||
| 969 | base_height = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, 0) | ||
| 970 | + FRAME_MENUBAR_HEIGHT (f) + FRAME_TOOLBAR_HEIGHT (f); | ||
| 971 | |||
| 972 | check_frame_size (f, &min_rows, &min_cols); | ||
| 973 | |||
| 974 | size_hints.base_width = base_width; | ||
| 975 | size_hints.base_height = base_height; | ||
| 976 | size_hints.min_width = base_width + min_cols * size_hints.width_inc; | ||
| 977 | size_hints.min_height = base_height + min_rows * size_hints.height_inc; | ||
| 978 | |||
| 979 | /* These currently have a one to one mapping with the X values, but I | ||
| 980 | don't think we should rely on that. */ | ||
| 981 | hint_flags |= GDK_HINT_WIN_GRAVITY; | ||
| 982 | size_hints.win_gravity = 0; | ||
| 983 | if (win_gravity == NorthWestGravity) | ||
| 984 | size_hints.win_gravity = GDK_GRAVITY_NORTH_WEST; | ||
| 985 | else if (win_gravity == NorthGravity) | ||
| 986 | size_hints.win_gravity = GDK_GRAVITY_NORTH; | ||
| 987 | else if (win_gravity == NorthEastGravity) | ||
| 988 | size_hints.win_gravity = GDK_GRAVITY_NORTH_EAST; | ||
| 989 | else if (win_gravity == WestGravity) | ||
| 990 | size_hints.win_gravity = GDK_GRAVITY_WEST; | ||
| 991 | else if (win_gravity == CenterGravity) | ||
| 992 | size_hints.win_gravity = GDK_GRAVITY_CENTER; | ||
| 993 | else if (win_gravity == EastGravity) | ||
| 994 | size_hints.win_gravity = GDK_GRAVITY_EAST; | ||
| 995 | else if (win_gravity == SouthWestGravity) | ||
| 996 | size_hints.win_gravity = GDK_GRAVITY_SOUTH_WEST; | ||
| 997 | else if (win_gravity == SouthGravity) | ||
| 998 | size_hints.win_gravity = GDK_GRAVITY_SOUTH; | ||
| 999 | else if (win_gravity == SouthEastGravity) | ||
| 1000 | size_hints.win_gravity = GDK_GRAVITY_SOUTH_EAST; | ||
| 1001 | else if (win_gravity == StaticGravity) | ||
| 1002 | size_hints.win_gravity = GDK_GRAVITY_STATIC; | ||
| 1003 | |||
| 1004 | if (flags & PPosition) hint_flags |= GDK_HINT_POS; | ||
| 1005 | if (flags & USPosition) hint_flags |= GDK_HINT_USER_POS; | ||
| 1006 | if (flags & USSize) hint_flags |= GDK_HINT_USER_SIZE; | ||
| 1007 | |||
| 1008 | if (user_position) | ||
| 1009 | { | ||
| 1010 | hint_flags &= ~GDK_HINT_POS; | ||
| 1011 | hint_flags |= GDK_HINT_USER_POS; | ||
| 1012 | } | ||
| 1013 | |||
| 1014 | if (hint_flags != f->output_data.x->hint_flags | ||
| 1015 | || memcmp (&size_hints, | ||
| 1016 | &f->output_data.x->size_hints, | ||
| 1017 | sizeof (size_hints)) != 0) | ||
| 1018 | { | ||
| 1019 | BLOCK_INPUT; | ||
| 1020 | gtk_window_set_geometry_hints (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)), | ||
| 1021 | NULL, &size_hints, hint_flags); | ||
| 1022 | f->output_data.x->size_hints = size_hints; | ||
| 1023 | f->output_data.x->hint_flags = hint_flags; | ||
| 1024 | UNBLOCK_INPUT; | ||
| 1025 | } | ||
| 1028 | } | 1026 | } |
| 1029 | 1027 | ||
| 1030 | /* Change background color of a frame. | 1028 | /* Change background color of a frame. |