From b38c0d6a2ff2dca89e9bf5feed49b7708ebf9942 Mon Sep 17 00:00:00 2001 From: Po Lu Date: Sun, 6 Feb 2022 09:18:59 +0800 Subject: [PATCH] Clean up lots of #ifdef'd out code in PGTK files Most of them are either relics from X or from the NS code pgtkfns.c was copied from whole. * src/pgtkfns.c (x_icon): (pgtk_set_scroll_bar_foreground): (pgtk_set_scroll_bar_background): (Fx_create_frame): (pgtk_window_is_ancestor): (x_create_tip_frame): * src/pgtkselect.c (syms_of_pgtkselect): * src/pgtkterm.c (pgtk_iconify_frame): (x_set_frame_alpha): (button_event): Remove defined out code that cannot make sense. * src/pgtkmenu.c (show_help_event): Remove ifdef'd out code and reword comment. --- src/pgtkfns.c | 85 +++--------------------------------------------- src/pgtkmenu.c | 34 +++++-------------- src/pgtkselect.c | 9 ----- src/pgtkterm.c | 50 +--------------------------- 4 files changed, 15 insertions(+), 163 deletions(-) diff --git a/src/pgtkfns.c b/src/pgtkfns.c index c7987afc7db..15e14f75e47 100644 --- a/src/pgtkfns.c +++ b/src/pgtkfns.c @@ -682,40 +682,6 @@ x_set_mouse_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval) { } - -static void -x_icon (struct frame *f, Lisp_Object parms) -/* -------------------------------------------------------------------------- - Strangely-named function to set icon position parameters in frame. - This is irrelevant under macOS, but might be needed under GNUstep, - depending on the window manager used. Note, this is not a standard - frame parameter-setter; it is called directly from x-create-frame. - -------------------------------------------------------------------------- */ -{ -#if 0 - Lisp_Object icon_x, icon_y; - struct pgtk_display_info *dpyinfo = check_pgtk_display_info (Qnil); - - FRAME_X_OUTPUT (f)->icon_top = -1; - FRAME_X_OUTPUT (f)->icon_left = -1; - - /* Set the position of the icon. */ - icon_x = - gui_display_get_arg (dpyinfo, parms, Qicon_left, 0, 0, RES_TYPE_NUMBER); - icon_y = - gui_display_get_arg (dpyinfo, parms, Qicon_top, 0, 0, RES_TYPE_NUMBER); - if (!EQ (icon_x, Qunbound) && !EQ (icon_y, Qunbound)) - { - CHECK_NUMBER (icon_x); - CHECK_NUMBER (icon_y); - FRAME_X_OUTPUT (f)->icon_top = XFIXNUM (icon_y); - FRAME_X_OUTPUT (f)->icon_left = XFIXNUM (icon_x); - } - else if (!EQ (icon_x, Qunbound) || !EQ (icon_y, Qunbound)) - error ("Both left and top icon corners of icon must be specified"); -#endif -} - /** * x_set_undecorated: * @@ -892,13 +858,10 @@ pgtk_set_scroll_bar_foreground (struct frame *f, Lisp_Object new_value, if (!pgtk_parse_color (f, SSDATA (new_value), &rgb)) error ("Unknown color."); - /* On pgtk, this frame parameter should be ignored, and honor gtk theme. */ -#if 0 char css[64]; sprintf (css, "scrollbar slider { background-color: #%06x; }", (unsigned int) rgb.pixel & 0xffffff); gtk_css_provider_load_from_data (css_provider, css, -1, NULL); -#endif update_face_from_frame_parameter (f, Qscroll_bar_foreground, new_value); } @@ -925,13 +888,13 @@ pgtk_set_scroll_bar_background (struct frame *f, Lisp_Object new_value, if (!pgtk_parse_color (f, SSDATA (new_value), &rgb)) error ("Unknown color."); - /* On pgtk, this frame parameter should be ignored, and honor gtk theme. */ -#if 0 + /* On pgtk, this frame parameter should be ignored, and honor + gtk theme. (It honors the GTK theme if not explictly set, so + I see no harm in letting users tinker a bit more.) */ char css[64]; sprintf (css, "scrollbar trough { background-color: #%06x; }", (unsigned int) rgb.pixel & 0xffffff); gtk_css_provider_load_from_data (css_provider, css, -1, NULL); -#endif update_face_from_frame_parameter (f, Qscroll_bar_background, new_value); } @@ -1378,9 +1341,6 @@ This function is an internal primitive--use `make-frame' instead. */ ) f->output_method = output_pgtk; FRAME_X_OUTPUT (f) = xzalloc (sizeof *FRAME_X_OUTPUT (f)); -#if 0 - FRAME_X_OUTPUT (f)->icon_bitmap = -1; -#endif FRAME_FONTSET (f) = -1; FRAME_X_OUTPUT (f)->white_relief.pixel = -1; FRAME_X_OUTPUT (f)->black_relief.pixel = -1; @@ -1478,12 +1438,8 @@ This function is an internal primitive--use `make-frame' instead. */ ) error ("Invalid frame font"); } - /* Frame contents get displaced if an embedded X window has a border. */ -#if 0 - if (!FRAME_X_EMBEDDED_P (f)) -#endif - gui_default_parameter (f, parms, Qborder_width, make_fixnum (0), - "borderWidth", "BorderWidth", RES_TYPE_NUMBER); + gui_default_parameter (f, parms, Qborder_width, make_fixnum (0), + "borderWidth", "BorderWidth", RES_TYPE_NUMBER); if (NILP (Fassq (Qinternal_border_width, parms))) { @@ -1627,10 +1583,6 @@ This function is an internal primitive--use `make-frame' instead. */ ) RES_TYPE_BOOLEAN); f->no_split = minibuffer_only || EQ (tem, Qt); -#if 0 - x_icon_verify (f, parms); -#endif - /* Create the X widget or window. */ /* x_window (f); */ xg_create_frame_widgets (f); @@ -1658,11 +1610,6 @@ This function is an internal primitive--use `make-frame' instead. */ ) #undef INSTALL_CURSOR - x_icon (f, parms); -#if 0 - x_make_gc (f); -#endif - /* Now consider the frame official. */ f->terminal->reference_count++; FRAME_DISPLAY_INFO (f)->reference_count++; @@ -1819,21 +1766,6 @@ This function is an internal primitive--use `make-frame' instead. */ ) return unbind_to (count, frame); } - -#if 0 -static int -pgtk_window_is_ancestor (PGTKWindow * win, PGTKWindow * candidate) -/* Test whether CANDIDATE is an ancestor window of WIN. */ -{ - if (candidate == NULL) - return 0; - else if (win == candidate) - return 1; - else - return pgtk_window_is_ancestor (win,[candidate parentWindow]); -} -#endif - /** * x_frame_restack: * @@ -2817,9 +2749,6 @@ x_create_tip_frame (struct pgtk_display_info *dpyinfo, Lisp_Object parms, struct counts etc. */ f->output_method = output_pgtk; f->output_data.pgtk = xzalloc (sizeof *f->output_data.pgtk); -#if 0 - f->output_data.pgtk->icon_bitmap = -1; -#endif FRAME_FONTSET (f) = -1; f->output_data.pgtk->white_relief.pixel = -1; f->output_data.pgtk->black_relief.pixel = -1; @@ -2945,10 +2874,6 @@ x_create_tip_frame (struct pgtk_display_info *dpyinfo, Lisp_Object parms, struct gtk_window_set_type_hint (GTK_WINDOW (tip_window), GDK_WINDOW_TYPE_HINT_TOOLTIP); f->output_data.pgtk->current_cursor = f->output_data.pgtk->text_cursor; -#if 0 - x_make_gc (f); -#endif - gui_default_parameter (f, parms, Qauto_raise, Qnil, "autoRaise", "AutoRaiseLower", RES_TYPE_BOOLEAN); gui_default_parameter (f, parms, Qauto_lower, Qnil, diff --git a/src/pgtkmenu.c b/src/pgtkmenu.c index d1b1bfffb36..18aaf57302d 100644 --- a/src/pgtkmenu.c +++ b/src/pgtkmenu.c @@ -141,31 +141,15 @@ popup_deactivate_callback (GtkWidget *widget, gpointer client_data) static void show_help_event (struct frame *f, GtkWidget *widget, Lisp_Object help) { - /* Don't show this tooltip. - * Tooltips are always tied to main widget, so stacking order - * on Wayland is: - * (above) - * - menu - * - tooltip - * - main widget - * (below) - * This is applicable to tooltips for menu, and menu tooltips - * are shown below menus. - * As a workaround, I entrust Gtk with menu tooltips, and - * let emacs not to show menu tooltips. - */ - -#if 0 - Lisp_Object frame; - - if (f) - { - XSETFRAME (frame, f); - kbd_buffer_store_help_event (frame, help); - } - else - show_help_echo (help, Qnil, Qnil, Qnil); -#endif + /* Don't show help echo on PGTK, as tooltips are always transient + for the main widget, so on Wayland the menu will display above + and obscure the tooltip. FIXME: this is some low hanging fruit + for fixing. After you fix Fx_show_tip in pgtkterm.c so that it + can display tooltips above menus, copy the definition of this + function from xmenu.c. + + As a workaround, GTK is used to display menu tooltips, outside + the Emacs help echo machinery. */ } /* Callback called when menu items are highlighted/unhighlighted diff --git a/src/pgtkselect.c b/src/pgtkselect.c index 23a79895d54..24fed19cd23 100644 --- a/src/pgtkselect.c +++ b/src/pgtkselect.c @@ -36,10 +36,6 @@ GNUstep port and post-20 update by Adrian Robert (arobert@cogsci.ucsd.edu) #include "pgtkselect.h" #include -#if 0 -static Lisp_Object Vselection_alist; -#endif - static GQuark quark_primary_data = 0; static GQuark quark_primary_size = 0; static GQuark quark_secondary_data = 0; @@ -606,11 +602,6 @@ syms_of_pgtkselect (void) defsubr (&Spgtk_selection_exists_p); defsubr (&Spgtk_selection_owner_p); -#if 0 - Vselection_alist = Qnil; - staticpro (&Vselection_alist); -#endif - DEFVAR_LISP ("pgtk-sent-selection-hooks", Vpgtk_sent_selection_hooks, "A list of functions to be called when Emacs answers a selection request.\n\ The functions are called with four arguments:\n\ diff --git a/src/pgtkterm.c b/src/pgtkterm.c index 23ad3c318c2..169d3f8a031 100644 --- a/src/pgtkterm.c +++ b/src/pgtkterm.c @@ -582,10 +582,6 @@ pgtk_iconify_frame (struct frame *f) block_input (); -#if 0 - x_set_bitmap_icon (f); -#endif - if (FRAME_GTK_OUTER_WIDGET (f)) { if (!FRAME_VISIBLE_P (f)) @@ -600,21 +596,9 @@ pgtk_iconify_frame (struct frame *f) /* Make sure the X server knows where the window should be positioned, in case the user deiconifies with the window manager. */ - if (!FRAME_VISIBLE_P (f) && !FRAME_ICONIFIED_P (f) -#if 0 - && !FRAME_X_EMBEDDED_P (f) -#endif - ) + if (!FRAME_VISIBLE_P (f) && !FRAME_ICONIFIED_P (f)) x_set_offset (f, f->left_pos, f->top_pos, 0); -#if 0 - if (!FRAME_VISIBLE_P (f)) - { - /* If the frame was withdrawn, before, we must map it. */ - XMapRaised (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f)); - } -#endif - SET_FRAME_ICONIFIED (f, true); SET_FRAME_VISIBLE (f, 0); @@ -4600,22 +4584,6 @@ x_set_frame_alpha (struct frame *f) else if (alpha < alpha_min && alpha_min <= 1.0) alpha = alpha_min; -#if 0 - /* If there is a parent from the window manager, put the property there - also, to work around broken window managers that fail to do that. - Do this unconditionally as this function is called on reparent when - alpha has not changed on the frame. */ - - if (!FRAME_PARENT_FRAME (f)) - { - Window parent = x_find_topmost_parent (f); - if (parent != None) - XChangeProperty (dpy, parent, dpyinfo->Xatom_net_wm_window_opacity, - XA_CARDINAL, 32, PropModeReplace, - (unsigned char *) &opac, 1); - } -#endif - set_opacity_recursively (FRAME_WIDGET (f), &alpha); /* without this, blending mode is strange on wayland. */ gtk_widget_queue_resize_no_redraw (FRAME_WIDGET (f)); @@ -6152,9 +6120,6 @@ button_event (GtkWidget * widget, GdkEvent * event, gpointer * user_data) dpyinfo = FRAME_DISPLAY_INFO (frame); dpyinfo->last_mouse_glyph_frame = NULL; -#if 0 - x_display_set_last_user_time (dpyinfo, event->button.time); -#endif if (gui_mouse_grabbed (dpyinfo)) f = dpyinfo->last_mouse_frame; @@ -6183,14 +6148,6 @@ button_event (GtkWidget * widget, GdkEvent * event, gpointer * user_data) } } - /* xg_event_is_for_scrollbar() doesn't work correctly on sway, and - * we shouldn't need it. - */ -#if 0 - if (f && xg_event_is_for_scrollbar (f, event)) - f = 0; -#endif - if (f) { /* Is this in the tab-bar? */ @@ -6232,11 +6189,6 @@ button_event (GtkWidget * widget, GdkEvent * event, gpointer * user_data) if (!NILP (tab_bar_arg)) inev.ie.arg = tab_bar_arg; } -#if 0 - if (FRAME_X_EMBEDDED_P (f)) - xembed_send_message (f, event->button.time, - XEMBED_REQUEST_FOCUS, 0, 0, 0); -#endif } if (event->type == GDK_BUTTON_PRESS) -- 2.39.5