diff options
author | Yuuki Harano <masm+github@masm11.me> | 2020-09-06 23:27:45 +0900 |
---|---|---|
committer | Jeff Walsh <jeff.walsh@drtusers-MacBook-Pro.local> | 2020-11-24 12:24:40 +1100 |
commit | 28073ba59bbabec1194977d654b471800ce63f45 (patch) | |
tree | 967c439b8f95894da3e573b0897d28b3b4d6c6d2 /src/pgtkfns.c | |
parent | e75ce0302d4c907c8ff56fb15fc7dd12b48e7370 (diff) | |
download | emacs-28073ba59bbabec1194977d654b471800ce63f45.tar.gz emacs-28073ba59bbabec1194977d654b471800ce63f45.tar.bz2 emacs-28073ba59bbabec1194977d654b471800ce63f45.zip |
Re-implement childframe with emacsgtkfixed
* src/emacsgtkfixed.c (G_DEFINE_TYPE): Make emacs_fixed_get_type public.
* src/emacsgtkfixed.h (EMACS_TYPE_FIXED): Make emacs_fixed_get_type public.
* src/gtkutil.c (xg_frame_set_char_size): Call appropriate functions
by whether the frame is a child frame or not.
(xg_create_frame_widgets): Use GTK_WINDOW_TOPLEVEL when creating child frame.
(xg_create_frame_outer_widgets): New function.
(xg_set_skip_taskbar): Call only when top-level frame.
(xg_set_no_accept_focus): See appropriate widget.
* src/gtkutil.h: New declaration.
* src/pgtkfns.c (pgtk_set_name_internal): Do only when top-level frame.
(Fx_create_frame): Reparent the frame.
(frame_geometry): Call appropriate functions
(syms_of_pgtkfns): Port from X code.
* src/pgtkterm.c (x_free_frame_resources): Destroy appropriate widget.
(x_calc_absolute_position): Port from X code.
(x_set_offset): Re-port from X code.
(pgtk_set_window_size): Use appropriate widget.
(pgtk_make_frame_visible): Use appropriate widget.
(pgtk_make_frame_invisible): Use appropriate widget.
(x_set_parent_frame): Reparent the frame.
(x_set_z_group): Process only when top-level frame.
(pgtk_text_icon): Process only when top-level frame.
(set_fullscreen_state): Process only when top-level frame.
(frame_highlight): Hold ref.
(frame_unhighlight): Hold ref.
(pgtk_window_is_of_frame_recursive): Prune child frames.
(pgtk_window_is_of_frame): Prune child frames.
(print_widget_tree_recursive): Don't call this when not debugging.
(pgtk_handle_draw): Don't call this when not debugging.
(pgtk_set_event_handler): expect map-event for edit_widget not outer widget.
* src/pgtkterm.h (FRAME_WIDGET): New macro.
Diffstat (limited to 'src/pgtkfns.c')
-rw-r--r-- | src/pgtkfns.c | 67 |
1 files changed, 56 insertions, 11 deletions
diff --git a/src/pgtkfns.c b/src/pgtkfns.c index 06fb4e206f4..c6909ba3d63 100644 --- a/src/pgtkfns.c +++ b/src/pgtkfns.c @@ -231,7 +231,7 @@ x_set_cursor_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval) static void pgtk_set_name_internal (struct frame *f, Lisp_Object name) { - if (FRAME_GTK_WIDGET (f)) + if (FRAME_GTK_OUTER_WIDGET (f)) { block_input (); { @@ -1523,18 +1523,32 @@ This function is an internal primitive--use `make-frame' instead. */ ) struct frame *p = XFRAME (parent_frame); block_input (); + PGTK_TRACE ("x_set_parent_frame x: %d, y: %d", f->left_pos, f->top_pos); - gtk_window_set_transient_for (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)), - GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (p))); - gtk_window_set_attached_to (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)), - FRAME_GTK_WIDGET (p)); - gtk_window_set_destroy_with_parent (GTK_WINDOW - (FRAME_GTK_OUTER_WIDGET (f)), TRUE); - gtk_widget_show_all (FRAME_GTK_OUTER_WIDGET (f)); + GtkWidget *fixed = FRAME_GTK_WIDGET (f); + GtkWidget *fixed_of_p = FRAME_GTK_WIDGET (p); + GtkWidget *whbox_of_f = gtk_widget_get_parent (fixed); + g_object_ref (fixed); + gtk_container_remove (GTK_CONTAINER (whbox_of_f), fixed); + gtk_fixed_put (GTK_FIXED (fixed_of_p), fixed, f->left_pos, f->top_pos); + gtk_widget_show_all (fixed); + g_object_unref (fixed); + + gtk_widget_destroy (FRAME_GTK_OUTER_WIDGET (f)); + FRAME_GTK_OUTER_WIDGET (f) = NULL; + FRAME_OUTPUT_DATA (f)->vbox_widget = NULL; + FRAME_OUTPUT_DATA (f)->hbox_widget = NULL; + FRAME_OUTPUT_DATA (f)->menubar_widget = NULL; + FRAME_OUTPUT_DATA (f)->toolbar_widget = NULL; + FRAME_OUTPUT_DATA (f)->ttip_widget = NULL; + FRAME_OUTPUT_DATA (f)->ttip_lbl = NULL; + FRAME_OUTPUT_DATA (f)->ttip_window = NULL; + unblock_input (); } - gtk_widget_show_all (FRAME_GTK_OUTER_WIDGET (f)); + if (FRAME_GTK_OUTER_WIDGET (f)) + gtk_widget_show_all (FRAME_GTK_OUTER_WIDGET (f)); gui_default_parameter (f, parms, Qno_focus_on_map, Qnil, NULL, NULL, RES_TYPE_BOOLEAN); @@ -3298,8 +3312,15 @@ frame_geometry (Lisp_Object frame, Lisp_Object attribute) /* Get these here because they can't be got in configure_event(). */ int left_pos, top_pos; - gtk_window_get_position (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)), - &left_pos, &top_pos); + if (FRAME_GTK_OUTER_WIDGET (f)) { + gtk_window_get_position (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)), + &left_pos, &top_pos); + } else { + GtkAllocation alloc; + gtk_widget_get_allocation (FRAME_GTK_WIDGET (f), &alloc); + left_pos = alloc.x; + top_pos = alloc.y; + } int native_left = left_pos + border; int native_top = top_pos + border + title_height; @@ -3647,6 +3668,8 @@ syms_of_pgtkfns (void) DEFSYM (Qframe_title_format, "frame-title-format"); DEFSYM (Qicon_title_format, "icon-title-format"); DEFSYM (Qdark, "dark"); + DEFSYM (Qhide, "hide"); + DEFSYM (Qresize_mode, "resize-mode"); DEFVAR_LISP ("x-cursor-fore-pixel", Vx_cursor_fore_pixel, doc: /* A string indicating the foreground color of the cursor box. */); @@ -3799,6 +3822,28 @@ When using Gtk+ tooltips, the tooltip face is not used. */); Value is a pair (COLUMNS . ROWS). Text larger than this is clipped. */); Vx_max_tooltip_size = Fcons (make_fixnum (80), make_fixnum (40)); + DEFVAR_LISP ("x-gtk-resize-child-frames", x_gtk_resize_child_frames, + doc: /* If non-nil, resize child frames specially with GTK builds. +If this is nil, resize child frames like any other frames. This is the +default and usually works with most desktops. Some desktop environments +(GNOME shell in particular when using the mutter window manager), +however, may refuse to resize a child frame when Emacs is built with +GTK3. For those environments, the two settings below are provided. + +If this equals the symbol 'hide', Emacs temporarily hides the child +frame during resizing. This approach seems to work reliably, may +however induce some flicker when the frame is made visible again. + +If this equals the symbol 'resize-mode', Emacs uses GTK's resize mode to +always trigger an immediate resize of the child frame. This method is +deprecated by GTK and may not work in future versions of that toolkit. +It also may freeze Emacs when used with other desktop environments. It +avoids, however, the unpleasant flicker induced by the hiding approach. + +This variable is considered a temporary workaround and will be hopefully +eliminated in future versions of Emacs. */); + x_gtk_resize_child_frames = Qnil; + DEFSYM (Qmono, "mono"); DEFSYM (Qassq_delete_all, "assq-delete-all"); |