From c936cbbc830b194dbb1cd7ff039ea9978a7ab607 Mon Sep 17 00:00:00 2001 From: Martin Rudalics Date: Sat, 8 Nov 2014 12:11:50 +0100 Subject: [PATCH] Run `window-configuration-change-hook' only after all faces have been realized. * frame.c (adjust_frame_size): Call x_set_window_size only if f->can_x_set_window_size is set. (make_frame): Initialize f->can_x_set_window_size and f->can_run_window_configuration_change_hook. (Fcan_run_window_configuration_change_hook): New function. * frame.h (frame): Split `official' into `can_x_set_window_size' and `can_run_window_configuration_change_hook'. * nsfns.m (Fx_create_frame): Set f->can_x_set_window_size. * w32fns.c (Fx_create_frame, x_create_tip_frame): Set f->can_x_set_window_size. * window.c (run_window_configuration_change_hook): Return immediately if either f->can_x_set_window_size or f->can_run_window_configuration_change_hook are false. (Fset_window_configuration): Instead of f->official set f->can_x_set_window_size. * xfns.c (Fx_create_frame, x_create_tip_frame): Set f->can_x_set_window_size. * faces.el (face-set-after-frame-default): Enable running `window-configuration-change-hook'. --- lisp/ChangeLog | 5 +++++ lisp/faces.el | 3 ++- src/ChangeLog | 20 ++++++++++++++++++++ src/frame.c | 25 +++++++++++++++++++++++-- src/frame.h | 12 +++++++----- src/nsfns.m | 4 ++-- src/w32fns.c | 6 +++--- src/window.c | 12 +++++++----- src/xfns.c | 4 ++-- 9 files changed, 71 insertions(+), 20 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 52d8a5b6051..dae450a2776 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2014-11-08 Martin Rudalics + + * faces.el (face-set-after-frame-default): Enable running + `window-configuration-change-hook'. + 2014-11-07 Juri Linkov * replace.el: History for query replace pairs. diff --git a/lisp/faces.el b/lisp/faces.el index d7b330ee64c..1d4fc9c5570 100644 --- a/lisp/faces.el +++ b/lisp/faces.el @@ -2092,7 +2092,8 @@ frame parameters in PARAMETERS." (value (cdr (assq param-name parameters)))) (if value (set-face-attribute (nth 1 param) frame - (nth 2 param) value)))))) + (nth 2 param) value)))) + (frame-can-run-window-configuration-change-hook frame t))) (defun tty-handle-reverse-video (frame parameters) "Handle the reverse-video frame parameter for terminal frames." diff --git a/src/ChangeLog b/src/ChangeLog index 4700e314a16..f8ed3b36dde 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,23 @@ +2014-11-08 Martin Rudalics + + * frame.c (adjust_frame_size): Call x_set_window_size only if + f->can_x_set_window_size is set. + (make_frame): Initialize f->can_x_set_window_size and + f->can_run_window_configuration_change_hook. + (Fcan_run_window_configuration_change_hook): New function. + * frame.h (frame): Split `official' into `can_x_set_window_size' + and `can_run_window_configuration_change_hook'. + * nsfns.m (Fx_create_frame): Set f->can_x_set_window_size. + * w32fns.c (Fx_create_frame, x_create_tip_frame): Set + f->can_x_set_window_size. + * window.c (run_window_configuration_change_hook): Return + immediately if either f->can_x_set_window_size or + f->can_run_window_configuration_change_hook are false. + (Fset_window_configuration): Instead of f->official set + f->can_x_set_window_size. + * xfns.c (Fx_create_frame, x_create_tip_frame): Set + f->can_x_set_window_size. + 2014-11-08 Jan Djärv * nsterm.m (EmacsScroller.dealloc): Reinstate, removed at merge diff --git a/src/frame.c b/src/frame.c index b03e207c105..c68195caba2 100644 --- a/src/frame.c +++ b/src/frame.c @@ -463,7 +463,7 @@ adjust_frame_size (struct frame *f, int new_width, int new_height, int inhibit, #ifdef HAVE_WINDOW_SYSTEM if (FRAME_WINDOW_P (f) - && f->official + && f->can_x_set_window_size && ((!inhibit_horizontal && (new_pixel_width != old_pixel_width || inhibit == 0 || inhibit == 2)) @@ -608,7 +608,8 @@ make_frame (bool mini_p) f->wants_modeline = true; f->redisplay = true; f->garbaged = true; - f->official = false; + f->can_x_set_window_size = false; + f->can_run_window_configuration_change_hook = false; f->column_width = 1; /* !FRAME_WINDOW_P value. */ f->line_height = 1; /* !FRAME_WINDOW_P value. */ #ifdef HAVE_WINDOW_SYSTEM @@ -2259,6 +2260,25 @@ If there is no window system support, this function does nothing. */) return Qnil; } +DEFUN ("frame-can-run-window-configuration-change-hook", + Fcan_run_window_configuration_change_hook, + Scan_run_window_configuration_change_hook, 2, 2, 0, + doc: /* Whether `window-configuration-change-hook' is run for frame FRAME. +FRAME nil means use the selected frame. Second argument ALLOW non-nil +means functions on `window-configuration-change-hook' are called +whenever the window configuration of FRAME changes. ALLOW nil means +these functions are not called. + +This function is currently called by `face-set-after-frame-default' only +and should be otherwise used with utter care to avoid that running +functions on `window-configuration-change-hook' is impeded forever. */) + (Lisp_Object frame, Lisp_Object allow) +{ + struct frame *f = decode_live_frame (frame); + + f->can_run_window_configuration_change_hook = NILP (allow) ? false : true; +} + /* Discard BUFFER from the buffer-list and buried-buffer-list of each frame. */ @@ -5083,6 +5103,7 @@ even if this option is non-nil. */); defsubr (&Sraise_frame); defsubr (&Slower_frame); defsubr (&Sx_focus_frame); + defsubr (&Scan_run_window_configuration_change_hook); defsubr (&Sredirect_frame_focus); defsubr (&Sframe_focus); defsubr (&Sframe_parameters); diff --git a/src/frame.h b/src/frame.h index b5d3bbb5b11..3fd1a6abc20 100644 --- a/src/frame.h +++ b/src/frame.h @@ -328,11 +328,13 @@ struct frame in pixels. */ bool_bf new_pixelwise : 1; - /* True if frame has been added to Vframe_list and is henceforth - considered official. For in-official frames we neither process - x_set_window_size requests nor do we allow running - window-configuration-change-hook when resizing windows. */ - bool_bf official : 1; + /* True means x_set_window_size requests can be processed for this + frame. */ + bool_bf can_x_set_window_size : 1; + + /* True means run_window_configuration_change_hook can be processed + for this frame. */ + bool_bf can_run_window_configuration_change_hook : 1; /* Bitfield area ends here. */ diff --git a/src/nsfns.m b/src/nsfns.m index 16f4ba3b579..c4b273c3bf5 100644 --- a/src/nsfns.m +++ b/src/nsfns.m @@ -1346,8 +1346,8 @@ This function is an internal primitive--use `make-frame' instead. */) x_default_parameter (f, parms, Qfullscreen, Qnil, "fullscreen", "Fullscreen", RES_TYPE_SYMBOL); - /* Consider frame official, now. */ - f->official = true; + /* Allow x_set_window_size, now. */ + f->can_x_set_window_size = true; adjust_frame_size (f, FRAME_TEXT_WIDTH (f), FRAME_TEXT_HEIGHT (f), 0, 1, Qnil); diff --git a/src/w32fns.c b/src/w32fns.c index 95821df6c61..502154d4473 100644 --- a/src/w32fns.c +++ b/src/w32fns.c @@ -4703,8 +4703,8 @@ This function is an internal primitive--use `make-frame' instead. */) x_default_parameter (f, parameters, Qscroll_bar_height, Qnil, "scrollBarHeight", "ScrollBarHeight", RES_TYPE_NUMBER); - /* Consider frame official, now. */ - f->official = true; + /* Allow x_set_window_size, now. */ + f->can_x_set_window_size = true; adjust_frame_size (f, FRAME_TEXT_WIDTH (f), FRAME_TEXT_HEIGHT (f), 0, 1, Qnil); @@ -5851,7 +5851,7 @@ x_create_tip_frame (struct w32_display_info *dpyinfo, below. And the frame needs to be on Vframe_list or making it visible won't work. */ Vframe_list = Fcons (frame, Vframe_list); - f->official = true; + f->can_x_set_window_size = true; /* Setting attributes of faces of the tooltip frame from resources and similar will increment face_change_count, which leads to the diff --git a/src/window.c b/src/window.c index 168ef1e3b9d..e4ff2b41806 100644 --- a/src/window.c +++ b/src/window.c @@ -3337,7 +3337,9 @@ run_window_configuration_change_hook (struct frame *f) = Fdefault_value (Qwindow_configuration_change_hook); XSETFRAME (frame, f); - if (NILP (Vrun_hooks) || !(f->official)) + if (NILP (Vrun_hooks) + || !(f->can_x_set_window_size) + || !(f->can_run_window_configuration_change_hook)) return; /* Use the right buffer. Matters when running the local hooks. */ @@ -6204,8 +6206,8 @@ the return value is nil. Otherwise the value is t. */) call1 (Qrecord_window_buffer, window); } - /* Consider frame unofficial, temporarily. */ - f->official = false; + /* Disallow x_set_window_size, temporarily. */ + f->can_x_set_window_size = false; /* The mouse highlighting code could get screwed up if it runs during this. */ block_input (); @@ -6414,9 +6416,9 @@ the return value is nil. Otherwise the value is t. */) ++n; } - /* Make frame official again and apply frame size changes if + /* Allow x_set_window_size again and apply frame size changes if needed. */ - f->official = true; + f->can_x_set_window_size = true; adjust_frame_size (f, -1, -1, 1, 0, Qnil); adjust_frame_glyphs (f); diff --git a/src/xfns.c b/src/xfns.c index 10eb3336fad..3ca8f20dd72 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -3248,7 +3248,7 @@ This function is an internal primitive--use `make-frame' instead. */) "alpha", "Alpha", RES_TYPE_NUMBER); /* Consider frame official, now. */ - f->official = true; + f->can_x_set_window_size = true; adjust_frame_size (f, FRAME_TEXT_WIDTH (f), FRAME_TEXT_HEIGHT (f), 0, 1, Qnil); @@ -5233,7 +5233,7 @@ x_create_tip_frame (struct x_display_info *dpyinfo, below. And the frame needs to be on Vframe_list or making it visible won't work. */ Vframe_list = Fcons (frame, Vframe_list); - f->official = true; + f->can_x_set_window_size = true; /* Setting attributes of faces of the tooltip frame from resources and similar will increment face_change_count, which leads to the -- 2.39.5