diff options
| author | Martin Rudalics <rudalics@gmx.at> | 2017-04-12 10:38:25 +0200 |
|---|---|---|
| committer | Martin Rudalics <rudalics@gmx.at> | 2017-04-12 10:38:25 +0200 |
| commit | 3fdd3bb56c006a2a24761b8fcea0cbd9b0cba422 (patch) | |
| tree | a0b8f5e431ba812b4fe69261a8515e973a3e7ed3 /src/gtkutil.c | |
| parent | 449bc49c768a4733411c7e05186be7efc163cd7c (diff) | |
| download | emacs-3fdd3bb56c006a2a24761b8fcea0cbd9b0cba422.tar.gz | |
Add new frame parameters and associated functions
Add new frame parameters `undecorated', `override-redirect',
`parent-frame', `skip-taskbar', `no-focus-on-map',
`no-accept-focus', `z-group', `delete-before', `no-other-frame',
`mouse-wheel-frame', `min-width', `min-height'. Add new
functions `frame-restack' and `frame-list-z-order'.
* lisp/cus-start.el (focus-follows-mouse): Adapt customization
type.
* lisp/frame.el (handle-delete-frame): Handle child and
`delete-before' frames.
(other-frame): Stop looking for other frame after one round.
(frame-list-z-order, frame-restack): New functions.
(delete-other-frames): Handle child frames.
* lisp/frameset.el (frameset-persistent-filter-alist)
(frameset--record-relationships): Handle `delete-before',
`parent-frame' and `mouse-wheel-frame' parameters. Rename
latter from `frameset--record-minibuffer-relationships'.
(frameset--restore-frame): Handle ‘parent-frame’ parameter
specially.
(frameset-restore): Handle `delete-before', `parent-frame' and
`mouse-wheel-frame' parameters.
* lisp/mwheel.el (mwheel-scroll): Handle `mouse-wheel-frame'
parameter.
* lisp/window.el (window--min-size-ignore-p): Fix doc-string.
(mouse-autoselect-window-select, handle-select-window): Major
rewrite. Try to not ignore errors. Handle auto-selection of
child frames and different values of `focus-follows-mouse'.
* src/frame.c (frame_windows_min_size): Handle new `min-width'
and `min-height' frame parameters.
(make_frame): Initialize new frame structure members.
(do_switch_frame): Don't reset internal_last_event_frame for
descendant frames.
(Fframe_parent, frame_ancestor_p, Fframe_ancestor_p): New
functions.
(candidate_frame): Don't return `no-other-frame' frame.
(other_frames): New function replacing other_visible_frames.
(delete_frame): Rewrite. Handle child and `delete-before' frames.
(Fmake_frame_invisible): Call other_frames.
(store_frame_param): Check `delete-before' and `parent-frame'
parameters for circular dependencies.
(frame_parms, syms_of_frame): Add entries for and define new
frame parameters.
(focus_follows_mouse): New meaningful value `auto-raise'.
* src/frame.h (z_group): New enumeration type.
(frame): New slots parent_frame, undecorated, override_redirect,
skip_taskbar, no_focus_on_map, no_accept_focus, z_group.
(fset_parent_frame): New inlined function.
(FRAME_UNDECORATED, FRAME_OVERRIDE_REDIRECT)
(FRAME_PARENT_FRAME, FRAME_SKIP_TASKBAR, FRAME_NO_FOCUS_ON_MAP)
(FRAME_NO_ACCEPT_FOCUS, FRAME_Z_GROUP, FRAME_Z_GROUP_NONE)
(FRAME_Z_GROUP_ABOVE, FRAME_Z_GROUP_ABOVE_SUSPENDED)
(FRAME_Z_GROUP_BELOW): New macros.
(frame_ancestor_p): Add declaration.
* src/gtkutil.c (xg_create_frame_widgets): Handle
`undecorated' and `override-redirect' frame parameters.
(x_wm_set_size_hint): None for child frames.
(xg_set_undecorated, xg_frame_restack, xg_set_skip_taskbar)
(xg_set_no_focus_on_map, xg_set_no_accept_focus)
(xg_set_override_redirect): New functions.
(xg_update_scrollbar_pos, xg_update_horizontal_scrollbar_pos):
Don't let scrollbars obscure child frames.
* src/gtkutil.h: (xg_set_undecorated, xg_frame_restack)
(xg_set_skip_taskbar, xg_set_no_focus_on_map)
(xg_set_no_accept_focus, xg_set_override_redirect): Add extern
declarations.
* src/nsfns.m (ns_frame_parm_handlers): Add entries for new
frame parameters.
(Fx_create_frame): Install `min-width' and `min-height' frame
parameters.
* src/nsterm.m (mouseMoved:): Handle focus_follows_mouse change.
* src/w32fns.c (WS_EX_NOACTIVATE): Define if necessary.
(x_real_positions): Handle child frames.
(x_set_menu_bar_lines): Don't for child frames.
(x_set_undecorated, x_set_parent_frame, x_set_skip_taskbar)
(x_set_no_focus_on_map, x_set_no_accept_focus)
(x_set_z_group): New functions.
(w32_createvscrollbar, w32_createhscrollbar): Don't draw
scroll bars over child frames.
(w32_createwindow): Handle new frame parameters and child frames.
(w32_wnd_proc): Let mouse clicks into a child frame activate
the frame. Try to handle the `no-accept-focus' parameter. Do
SetFocus when our window is brought to top or becomes the
foreground window.
(w32_window): Don't initialize menu bar for child frames.
(Fx_create_frame): Handle new frame parameters.
(x_create_tip_frame): Set explicit_parent slot.
(w32_dialog_in_progress): New function.
(Fx_file_dialog): Handle `z-group-above' frames.
(w32_frame_list_z_order, Fw32_frame_list_z_order)
(w32_frame_restack, Fw32_frame_restack): New functions.
(w32_frame_parm_handlers): Add entries for new frame
parameters.
* src/w32font.c (Fx_select_font): Handle `z-group-above'
frames during font selection dialogue.
* src/w32term.c (construct_mouse_wheel): Construct mouse wheel
event from F's w32 window.
(w32_mouse_position): Handle child frames.
(w32_set_vertical_scroll_bar, w32_set_horizontal_scroll_bar):
Don't draw scroll bars over child frames.
(w32_read_socket): Always erase background of child frames.
When generating SELECT_WINDOW_EVENTs handle new value of
`focus-follows-mouse' and handle `no-accept-focus' parameter.
Handle `mouse-wheel-frame' parameter.
(x_calc_absolute_position, x_set_offset, x_set_window_size):
Handle child frames.
(x_make_frame_visible): Handle child frames specially. Handle
`no-focus-on-map' parameter.
* src/w32term.h (w32_dialog_in_progress): Add external
declaration.
* src/xdisp.c (x_consider_frame_title, prepare_menu_bars): Not
for child frames.
* src/xfns.c (Xm/MwmUtil.h): Include for WM hints.
(PropMotifWmHints, PROP_MOTIF_WM_HINTS_ELEMENTS): Define for
non-Motif, non-GTK case.
(x_real_pos_and_offsets): Handle child frames.
(x_set_undecorated, x_set_parent_frame)
(x_set_no_focus_on_map, x_set_no_accept_focus)
(x_set_override_redirect): New functions.
(x_set_menu_bar_lines): Not for child frames.
(x_window): Handle `undecorated' and `override_redirect' cases.
(Fx_create_frame): Handle new frame parameters.
(frame_geometry): Handle child frames and outer border.
(x_frame_list_z_order, Fx_frame_list_z_order)
(x_frame_restack, Fx_frame_restack): New functions.
(Fx_file_dialog, Fx_select_font): Set x_menu_set_in_use.
(x_frame_parm_handlers): Add entries for new frame parameters.
* src/xmenu.c (x_menu_set_in_use): Handle `z-group-above'
frames.
* src/xterm.c (x_set_frame_alpha): Don't set alpha of parent
for child frames.
(XTmouse_position): Handle child frames.
(x_scroll_bar_create, x_scroll_bar_expose): Don't let scroll
bars obscure child frames.
(handle_one_xevent): Handle child frame positions. If necessary
set `skip-taskbar' and reassign proper `z-group' when we are
mapped. When generating SELECT_WINDOW_EVENTs handle new value
of `focus-follows-mouse'. Handle `mouse-wheel-frame' parameter.
Let mouse clicks into a child frame activate the frame.
(x_calc_absolute_position, x_set_offset): Handle child frames
specially.
(x_set_skip_taskbar, x_set_z_group): New functions.
(x_make_frame_visible): Handle child frames.
(ATOM_REFS_INIT): Add entries for
Xatom_net_wm_state_skip_taskbar, Xatom_net_wm_state_above,
Xatom_net_wm_state_below.
* src/xterm.h (top-level): Declare Xatom_net_wm_state_above,
Xatom_net_wm_state_below and Xatom_net_wm_state_skip_taskbar.
(x_set_skip_taskbar, x_set_z_group): Add extern declarations.
Diffstat (limited to 'src/gtkutil.c')
| -rw-r--r-- | src/gtkutil.c | 135 |
1 files changed, 133 insertions, 2 deletions
diff --git a/src/gtkutil.c b/src/gtkutil.c index 63f01436413..227a062bff3 100644 --- a/src/gtkutil.c +++ b/src/gtkutil.c @@ -1200,7 +1200,14 @@ xg_create_frame_widgets (struct frame *f) else if (! NILP (f->name)) title = SSDATA (ENCODE_UTF_8 (f->name)); - if (title) gtk_window_set_title (GTK_WINDOW (wtop), title); + if (title) + gtk_window_set_title (GTK_WINDOW (wtop), title); + + if (FRAME_UNDECORATED (f)) + { + gtk_window_set_decorated (GTK_WINDOW (wtop), FALSE); + store_frame_param (f, Qundecorated, Qt); + } FRAME_GTK_OUTER_WIDGET (f) = wtop; FRAME_GTK_WIDGET (f) = wfixed; @@ -1275,6 +1282,14 @@ xg_create_frame_widgets (struct frame *f) gtk_window_set_resizable (GTK_WINDOW (wtop), TRUE); #endif + if (FRAME_OVERRIDE_REDIRECT (f)) + { + GdkWindow *gwin = gtk_widget_get_window (wtop); + + if (gwin) + gdk_window_set_override_redirect (gwin, TRUE); + } + #ifdef USE_GTK_TOOLTIP /* Steal a tool tip window we can move ourselves. */ f->output_data.x->ttip_widget = 0; @@ -1356,7 +1371,9 @@ x_wm_set_size_hint (struct frame *f, long int flags, bool user_position) /* Don't set size hints during initialization; that apparently leads to a race condition. See the thread at http://lists.gnu.org/archive/html/emacs-devel/2008-10/msg00033.html */ - if (NILP (Vafter_init_time) || !FRAME_GTK_OUTER_WIDGET (f)) + if (NILP (Vafter_init_time) + || !FRAME_GTK_OUTER_WIDGET (f) + || FRAME_PARENT_FRAME (f)) return; XSETFRAME (frame, f); @@ -1489,6 +1506,100 @@ xg_set_background_color (struct frame *f, unsigned long bg) } } +/* Change the frame's decoration (title bar + resize borders). This + might not work with all window managers. */ +void +xg_set_undecorated (struct frame *f, Lisp_Object undecorated) +{ + if (FRAME_GTK_WIDGET (f)) + { + block_input (); + gtk_window_set_decorated (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)), + NILP (undecorated) ? TRUE : FALSE); + unblock_input (); + } +} + + +/* Restack F1 below F2, above if ABOVE_FLAG is true. This might not + work with all window managers. */ +void +xg_frame_restack (struct frame *f1, struct frame *f2, bool above_flag) +{ + block_input (); + if (FRAME_GTK_OUTER_WIDGET (f1) && FRAME_GTK_OUTER_WIDGET (f2)) + { + GdkWindow *gwin1 = gtk_widget_get_window (FRAME_GTK_OUTER_WIDGET (f1)); + GdkWindow *gwin2 = gtk_widget_get_window (FRAME_GTK_OUTER_WIDGET (f2)); + Lisp_Object frame1, frame2; + + XSETFRAME (frame1, f1); + XSETFRAME (frame2, f2); + + gdk_window_restack (gwin1, gwin2, above_flag); + x_sync (f1); + } + unblock_input (); +} + + +/* Don't show frame in taskbar, don't ALT-TAB to it. */ +void +xg_set_skip_taskbar (struct frame *f, Lisp_Object skip_taskbar) +{ + block_input (); + if (FRAME_GTK_WIDGET (f)) + gdk_window_set_skip_taskbar_hint + (gtk_widget_get_window (FRAME_GTK_OUTER_WIDGET (f)), + NILP (skip_taskbar) ? FALSE : TRUE); + unblock_input (); +} + + +/* Don't give frame focus. */ +void +xg_set_no_focus_on_map (struct frame *f, Lisp_Object no_focus_on_map) +{ + block_input (); + if (FRAME_GTK_WIDGET (f)) + { + GtkWindow *gwin = GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)); + gboolean gno_focus_on_map = NILP (no_focus_on_map) ? TRUE : FALSE; + + gtk_window_set_focus_on_map (gwin, gno_focus_on_map); + } + unblock_input (); +} + + +void +xg_set_no_accept_focus (struct frame *f, Lisp_Object no_accept_focus) +{ + block_input (); + if (FRAME_GTK_WIDGET (f)) + { + GtkWindow *gwin = GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)); + gboolean gno_accept_focus = NILP (no_accept_focus) ? TRUE : FALSE; + + gtk_window_set_accept_focus (gwin, gno_accept_focus); + } + unblock_input (); +} + +void +xg_set_override_redirect (struct frame *f, Lisp_Object override_redirect) +{ + block_input (); + + if (FRAME_GTK_OUTER_WIDGET (f)) + { + GdkWindow *gwin = gtk_widget_get_window (FRAME_GTK_OUTER_WIDGET (f)); + + gdk_window_set_override_redirect (gwin, NILP (override_redirect) ? FALSE : TRUE); + } + + unblock_input (); +} /* Set the frame icon to ICON_PIXMAP/MASK. This must be done with GTK functions so GTK does not overwrite the icon. */ @@ -3769,6 +3880,7 @@ xg_update_scrollbar_pos (struct frame *f, GtkWidget *wparent = gtk_widget_get_parent (wscroll); gint msl; int scale = xg_get_gdk_scale (); + bool hidden; top /= scale; left /= scale; @@ -3793,6 +3905,7 @@ xg_update_scrollbar_pos (struct frame *f, the height is less than the min size. */ gtk_widget_hide (wparent); gtk_widget_hide (wscroll); + hidden = true; } else { @@ -3807,6 +3920,15 @@ xg_update_scrollbar_pos (struct frame *f, x_clear_area (f, oldx, oldy, oldw, oldh); } + if (!hidden) + { + GtkWidget *scrollbar = xg_get_widget_from_map (scrollbar_id); + GtkWidget *webox = gtk_widget_get_parent (scrollbar); + + /* Don't obscure any child frames. */ + XLowerWindow (FRAME_X_DISPLAY (f), GTK_WIDGET_TO_X_WIN (webox)); + } + /* GTK does not redraw until the main loop is entered again, but if there are no X events pending we will not enter it. So we sync here to get some events. */ @@ -3872,6 +3994,15 @@ xg_update_horizontal_scrollbar_pos (struct frame *f, if there are no X events pending we will not enter it. So we sync here to get some events. */ + { + GtkWidget *scrollbar = + xg_get_widget_from_map (scrollbar_id); + GtkWidget *webox = gtk_widget_get_parent (scrollbar); + + /* Don't obscure any child frames. */ + XLowerWindow (FRAME_X_DISPLAY (f), GTK_WIDGET_TO_X_WIN (webox)); + } + x_sync (f); SET_FRAME_GARBAGED (f); cancel_mouse_face (f); |
