aboutsummaryrefslogtreecommitdiffstats
path: root/src/pgtkfns.c
diff options
context:
space:
mode:
authorPo Lu2022-04-27 19:19:01 +0800
committerPo Lu2022-04-27 19:19:01 +0800
commit5aef2623a37d9fe452b7072dbd12c7a24dd971e2 (patch)
tree0cb5d2d245e443b8d7b1074fe2e75a9c99fc126b /src/pgtkfns.c
parentd4e3e548f5519e98c2fc842daf73a6acac7faa70 (diff)
downloademacs-5aef2623a37d9fe452b7072dbd12c7a24dd971e2.tar.gz
emacs-5aef2623a37d9fe452b7072dbd12c7a24dd971e2.zip
Cleanups to PGTK code
* src/pgtkfns.c (pgtk_explicitly_set_name, pgtk_set_tab_bar_lines) (pgtk_change_tab_bar_height, pgtk_set_child_frame_border_width) (pgtk_set_internal_border_width, pgtk_set_cursor_type) (pgtk_set_mouse_color, pgtk_set_override_redirect, xg_set_icon) (pgtk_frame_parm_handlers, Fpgtk_set_monitor_scale_factor) (pgtk_set_scroll_bar_default_width, pgtk_get_focus_frame) (pgtk_hide_tip, Fx_show_tip, Fx_hide_tip, frame_geometry) (syms_of_pgtkfns): Clean up coding style and delete incorrect comments that mostly duplicate what is in xfns.c, and fix comment coding style. Also rename functions from `x_' to `pgtk_'. * src/pgtkterm.c (pgtk_setup_relief_colors): Fix relief caching with new flag. (pgtk_draw_relief_rect, flip_cr_context, pgtk_wait_for_map_event) (pgtk_make_frame_visible, pgtk_make_frame_invisible) (pgtk_set_parent_frame, pgtk_draw_glyph_string_foreground) (pgtk_draw_composite_glyph_string_foreground) (pgtk_draw_glyphless_glyph_string_foreground) (pgtk_set_clip_rectangles, pgtk_draw_glyph_string_bg_rect) (pgtk_draw_image_foreground, pgtk_draw_image_glyph_string) (pgtk_draw_stretch_glyph_string, pgtk_draw_glyph_string) (pgtk_copy_bits, pgtk_bitmap_icon, pgtk_define_fringe_bitmap) (pgtk_show_hourglass, pgtk_flash, pgtk_send_scroll_bar_event) (pgtk_free_pixmap, set_opacity_recursively, frame_highlight) (frame_unhighlight, pgtk_toggle_invisible_pointer) (pgtk_create_terminal, pgtk_window_is_of_frame_recursive) (pgtk_window_is_of_frame, pgtk_any_window_to_frame) (pgtk_handle_draw, size_allocate, pgtk_enqueue_string) (key_press_event, motion_notify_event): Fix coding style and some minor bugs. * src/pgtkterm.h (struct pgtk_output): New field for tracking relief color status, update prototypes.
Diffstat (limited to 'src/pgtkfns.c')
-rw-r--r--src/pgtkfns.c207
1 files changed, 68 insertions, 139 deletions
diff --git a/src/pgtkfns.c b/src/pgtkfns.c
index 1cab954a076..d1a72804cfe 100644
--- a/src/pgtkfns.c
+++ b/src/pgtkfns.c
@@ -360,7 +360,8 @@ pgtk_set_name (struct frame *f, Lisp_Object name, int explicit)
360 specified a name for the frame; the name will override any set by the 360 specified a name for the frame; the name will override any set by the
361 redisplay code. */ 361 redisplay code. */
362static void 362static void
363x_explicitly_set_name (struct frame *f, Lisp_Object arg, Lisp_Object oldval) 363pgtk_explicitly_set_name (struct frame *f, Lisp_Object arg,
364 Lisp_Object oldval)
364{ 365{
365 pgtk_set_name (f, arg, true); 366 pgtk_set_name (f, arg, true);
366} 367}
@@ -467,13 +468,12 @@ pgtk_set_tab_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval)
467 else 468 else
468 nlines = 0; 469 nlines = 0;
469 470
470 x_change_tab_bar_height (f, nlines * FRAME_LINE_HEIGHT (f)); 471 pgtk_change_tab_bar_height (f, nlines * FRAME_LINE_HEIGHT (f));
471} 472}
472 473
473
474/* Set the pixel height of the tab bar of frame F to HEIGHT. */ 474/* Set the pixel height of the tab bar of frame F to HEIGHT. */
475void 475void
476x_change_tab_bar_height (struct frame *f, int height) 476pgtk_change_tab_bar_height (struct frame *f, int height)
477{ 477{
478 int unit = FRAME_LINE_HEIGHT (f); 478 int unit = FRAME_LINE_HEIGHT (f);
479 int old_height = FRAME_TAB_BAR_HEIGHT (f); 479 int old_height = FRAME_TAB_BAR_HEIGHT (f);
@@ -578,12 +578,11 @@ pgtk_set_child_frame_border_width (struct frame *f, Lisp_Object arg, Lisp_Object
578 pgtk_clear_under_internal_border (f); 578 pgtk_clear_under_internal_border (f);
579 } 579 }
580 } 580 }
581
582} 581}
583 582
584static void 583static void
585pgtk_set_internal_border_width (struct frame *f, Lisp_Object arg, 584pgtk_set_internal_border_width (struct frame *f, Lisp_Object arg,
586 Lisp_Object oldval) 585 Lisp_Object oldval)
587{ 586{
588 int border = check_int_nonnegative (arg); 587 int border = check_int_nonnegative (arg);
589 588
@@ -661,32 +660,17 @@ pgtk_set_icon_name (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
661 unblock_input (); 660 unblock_input ();
662} 661}
663 662
664/* This is the same as the xfns.c definition. */
665static void 663static void
666pgtk_set_cursor_type (struct frame *f, Lisp_Object arg, Lisp_Object oldval) 664pgtk_set_cursor_type (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
667{ 665{
668 set_frame_cursor_types (f, arg); 666 set_frame_cursor_types (f, arg);
669} 667}
670 668
671/* called to set mouse pointer color, but all other terms use it to
672 initialize pointer types (and don't set the color ;) */
673static void 669static void
674pgtk_set_mouse_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval) 670pgtk_set_mouse_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
675{ 671{
676} 672}
677 673
678/**
679 * pgtk_set_undecorated:
680 *
681 * Set frame F's `undecorated' parameter. If non-nil, F's window-system
682 * window is drawn without decorations, title, minimize/maximize boxes
683 * and external borders. This usually means that the window cannot be
684 * dragged, resized, iconified, maximized or deleted with the mouse. If
685 * nil, draw the frame with all the elements listed above unless these
686 * have been suspended via window manager settings.
687 *
688 * Some window managers may not honor this parameter.
689 */
690static void 674static void
691pgtk_set_undecorated (struct frame *f, Lisp_Object new_value, 675pgtk_set_undecorated (struct frame *f, Lisp_Object new_value,
692 Lisp_Object old_value) 676 Lisp_Object old_value)
@@ -698,16 +682,6 @@ pgtk_set_undecorated (struct frame *f, Lisp_Object new_value,
698 } 682 }
699} 683}
700 684
701/**
702 * pgtk_set_skip_taskbar:
703 *
704 * Set frame F's `skip-taskbar' parameter. If non-nil, this should
705 * remove F's icon from the taskbar associated with the display of F's
706 * window-system window and inhibit switching to F's window via
707 * <Alt>-<TAB>. If nil, lift these restrictions.
708 *
709 * Some window managers may not honor this parameter.
710 */
711static void 685static void
712pgtk_set_skip_taskbar (struct frame *f, Lisp_Object new_value, 686pgtk_set_skip_taskbar (struct frame *f, Lisp_Object new_value,
713 Lisp_Object old_value) 687 Lisp_Object old_value)
@@ -719,18 +693,9 @@ pgtk_set_skip_taskbar (struct frame *f, Lisp_Object new_value,
719 } 693 }
720} 694}
721 695
722/**
723 * pgtk_set_override_redirect:
724 *
725 * Set frame F's `override_redirect' parameter which, if non-nil, hints
726 * that the window manager doesn't want to deal with F. Usually, such
727 * frames have no decorations and always appear on top of all frames.
728 *
729 * Some window managers may not honor this parameter.
730 */
731static void 696static void
732pgtk_set_override_redirect (struct frame *f, Lisp_Object new_value, 697pgtk_set_override_redirect (struct frame *f, Lisp_Object new_value,
733 Lisp_Object old_value) 698 Lisp_Object old_value)
734{ 699{
735 if (!EQ (new_value, old_value)) 700 if (!EQ (new_value, old_value))
736 { 701 {
@@ -745,9 +710,7 @@ pgtk_set_override_redirect (struct frame *f, Lisp_Object new_value,
745 } 710 }
746} 711}
747 712
748/* Set icon from FILE for frame F. By using GTK functions the icon 713/* Set icon from FILE for frame F. */
749 may be any format that GdkPixbuf knows about, i.e. not just bitmaps. */
750
751bool 714bool
752xg_set_icon (struct frame *f, Lisp_Object file) 715xg_set_icon (struct frame *f, Lisp_Object file)
753{ 716{
@@ -969,59 +932,58 @@ unless TYPE is `png'. */)
969 return pgtk_cr_export_frames (frames, surface_type); 932 return pgtk_cr_export_frames (frames, surface_type);
970} 933}
971 934
972 935frame_parm_handler pgtk_frame_parm_handlers[] =
973/* Note: see frame.c for template, also where generic functions are impl */ 936 {
974frame_parm_handler pgtk_frame_parm_handlers[] = { 937 gui_set_autoraise, /* generic OK */
975 gui_set_autoraise, /* generic OK */ 938 gui_set_autolower, /* generic OK */
976 gui_set_autolower, /* generic OK */ 939 pgtk_set_background_color,
977 pgtk_set_background_color, 940 pgtk_set_border_color,
978 pgtk_set_border_color, 941 gui_set_border_width,
979 gui_set_border_width, 942 pgtk_set_cursor_color,
980 pgtk_set_cursor_color, 943 pgtk_set_cursor_type,
981 pgtk_set_cursor_type, 944 gui_set_font, /* generic OK */
982 gui_set_font, /* generic OK */ 945 pgtk_set_foreground_color,
983 pgtk_set_foreground_color, 946 pgtk_set_icon_name,
984 pgtk_set_icon_name, 947 pgtk_set_icon_type,
985 pgtk_set_icon_type, 948 pgtk_set_child_frame_border_width,
986 pgtk_set_child_frame_border_width, 949 pgtk_set_internal_border_width, /* generic OK */
987 pgtk_set_internal_border_width, /* generic OK */ 950 gui_set_right_divider_width,
988 gui_set_right_divider_width, 951 gui_set_bottom_divider_width,
989 gui_set_bottom_divider_width, 952 pgtk_set_menu_bar_lines,
990 pgtk_set_menu_bar_lines, 953 pgtk_set_mouse_color,
991 pgtk_set_mouse_color, 954 pgtk_explicitly_set_name,
992 x_explicitly_set_name, 955 gui_set_scroll_bar_width, /* generic OK */
993 gui_set_scroll_bar_width, /* generic OK */ 956 gui_set_scroll_bar_height, /* generic OK */
994 gui_set_scroll_bar_height, /* generic OK */ 957 pgtk_set_title,
995 pgtk_set_title, 958 gui_set_unsplittable, /* generic OK */
996 gui_set_unsplittable, /* generic OK */ 959 gui_set_vertical_scroll_bars, /* generic OK */
997 gui_set_vertical_scroll_bars, /* generic OK */ 960 gui_set_horizontal_scroll_bars, /* generic OK */
998 gui_set_horizontal_scroll_bars, /* generic OK */ 961 gui_set_visibility, /* generic OK */
999 gui_set_visibility, /* generic OK */ 962 pgtk_set_tab_bar_lines,
1000 pgtk_set_tab_bar_lines, 963 pgtk_set_tool_bar_lines,
1001 pgtk_set_tool_bar_lines, 964 pgtk_set_scroll_bar_foreground,
1002 pgtk_set_scroll_bar_foreground, 965 pgtk_set_scroll_bar_background,
1003 pgtk_set_scroll_bar_background, 966 gui_set_screen_gamma, /* generic OK */
1004 gui_set_screen_gamma, /* generic OK */ 967 gui_set_line_spacing, /* generic OK, sets f->extra_line_spacing to int */
1005 gui_set_line_spacing, /* generic OK, sets f->extra_line_spacing to int */ 968 gui_set_left_fringe, /* generic OK */
1006 gui_set_left_fringe, /* generic OK */ 969 gui_set_right_fringe, /* generic OK */
1007 gui_set_right_fringe, /* generic OK */ 970 0,
1008 0, /* x_set_wait_for_wm */ 971 gui_set_fullscreen, /* generic OK */
1009 gui_set_fullscreen, /* generic OK */ 972 gui_set_font_backend, /* generic OK */
1010 gui_set_font_backend, /* generic OK */ 973 gui_set_alpha,
1011 gui_set_alpha, 974 pgtk_set_sticky,
1012 pgtk_set_sticky, 975 pgtk_set_tool_bar_position,
1013 pgtk_set_tool_bar_position, 976 0,
1014 0, /* x_set_inhibit_double_buffering */ 977 pgtk_set_undecorated,
1015 pgtk_set_undecorated, 978 pgtk_set_parent_frame,
1016 pgtk_set_parent_frame, 979 pgtk_set_skip_taskbar,
1017 pgtk_set_skip_taskbar, 980 pgtk_set_no_focus_on_map,
1018 pgtk_set_no_focus_on_map, 981 pgtk_set_no_accept_focus,
1019 pgtk_set_no_accept_focus, 982 pgtk_set_z_group,
1020 pgtk_set_z_group, 983 pgtk_set_override_redirect,
1021 pgtk_set_override_redirect, 984 gui_set_no_special_glyphs,
1022 gui_set_no_special_glyphs, 985 pgtk_set_alpha_background,
1023 pgtk_set_alpha_background, 986 };
1024};
1025 987
1026 988
1027/* Handler for signals raised during x_create_frame and 989/* Handler for signals raised during x_create_frame and
@@ -1186,7 +1148,7 @@ incorrect when you specify fractional scale factor in compositor.
1186If you set scale factor by this function, it is used instead of Gdk's one. 1148If you set scale factor by this function, it is used instead of Gdk's one.
1187 1149
1188Pass nil as SCALE-FACTOR if you want to reset the specified monitor's 1150Pass nil as SCALE-FACTOR if you want to reset the specified monitor's
1189scale factor. */ ) 1151scale factor. */)
1190 (Lisp_Object monitor_model, Lisp_Object scale_factor) 1152 (Lisp_Object monitor_model, Lisp_Object scale_factor)
1191{ 1153{
1192 CHECK_STRING (monitor_model); 1154 CHECK_STRING (monitor_model);
@@ -2255,27 +2217,6 @@ DEFUN ("x-display-list", Fx_display_list, Sx_display_list, 0, 0, 0,
2255 return result; 2217 return result;
2256} 2218}
2257 2219
2258
2259DEFUN ("pgtk-hide-others", Fpgtk_hide_others, Spgtk_hide_others, 0, 0, 0,
2260 doc: /* Hides all applications other than Emacs. */)
2261 (void)
2262{
2263 check_window_system (NULL);
2264 return Qnil;
2265}
2266
2267DEFUN ("pgtk-hide-emacs", Fpgtk_hide_emacs, Spgtk_hide_emacs, 1, 1, 0,
2268 doc: /* If ON is non-nil, the entire Emacs application is hidden.
2269Otherwise if Emacs is hidden, it is unhidden.
2270If ON is equal to `activate', Emacs is unhidden and becomes
2271the active application. */)
2272 (Lisp_Object on)
2273{
2274 check_window_system (NULL);
2275 return Qnil;
2276}
2277
2278
2279DEFUN ("pgtk-font-name", Fpgtk_font_name, Spgtk_font_name, 1, 1, 0, 2220DEFUN ("pgtk-font-name", Fpgtk_font_name, Spgtk_font_name, 1, 1, 0,
2280 doc: /* Determine font PostScript or family name for font NAME. 2221 doc: /* Determine font PostScript or family name for font NAME.
2281NAME should be a string containing either the font name or an XLFD 2222NAME should be a string containing either the font name or an XLFD
@@ -2311,7 +2252,6 @@ check_x_display_info (Lisp_Object frame)
2311 return check_pgtk_display_info (frame); 2252 return check_pgtk_display_info (frame);
2312} 2253}
2313 2254
2314
2315void 2255void
2316pgtk_set_scroll_bar_default_width (struct frame *f) 2256pgtk_set_scroll_bar_default_width (struct frame *f)
2317{ 2257{
@@ -2359,9 +2299,8 @@ pgtk_get_string_resource (XrmDatabase rdb, const char *name,
2359 return res; 2299 return res;
2360} 2300}
2361 2301
2362
2363Lisp_Object 2302Lisp_Object
2364x_get_focus_frame (struct frame *frame) 2303pgtk_get_focus_frame (struct frame *frame)
2365{ 2304{
2366 struct pgtk_display_info *dpyinfo = FRAME_DISPLAY_INFO (frame); 2305 struct pgtk_display_info *dpyinfo = FRAME_DISPLAY_INFO (frame);
2367 Lisp_Object focus; 2306 Lisp_Object focus;
@@ -2404,7 +2343,6 @@ DEFUN ("xw-color-values", Fxw_color_values, Sxw_color_values, 1, 2, 0,
2404 return Qnil; 2343 return Qnil;
2405} 2344}
2406 2345
2407
2408DEFUN ("xw-display-color-p", Fxw_display_color_p, Sxw_display_color_p, 0, 1, 0, 2346DEFUN ("xw-display-color-p", Fxw_display_color_p, Sxw_display_color_p, 0, 1, 0,
2409 doc: /* Internal function called by `display-color-p', which see. */) 2347 doc: /* Internal function called by `display-color-p', which see. */)
2410 (Lisp_Object terminal) 2348 (Lisp_Object terminal)
@@ -2413,7 +2351,6 @@ DEFUN ("xw-display-color-p", Fxw_display_color_p, Sxw_display_color_p, 0, 1, 0,
2413 return Qt; 2351 return Qt;
2414} 2352}
2415 2353
2416
2417DEFUN ("x-display-grayscale-p", Fx_display_grayscale_p, Sx_display_grayscale_p, 0, 1, 0, 2354DEFUN ("x-display-grayscale-p", Fx_display_grayscale_p, Sx_display_grayscale_p, 0, 1, 0,
2418 doc: /* Return t if the display supports shades of gray. 2355 doc: /* Return t if the display supports shades of gray.
2419Note that color displays do support shades of gray. 2356Note that color displays do support shades of gray.
@@ -2425,7 +2362,6 @@ If omitted or nil, that stands for the selected frame's display. */)
2425 return Qnil; 2362 return Qnil;
2426} 2363}
2427 2364
2428
2429DEFUN ("x-display-pixel-width", Fx_display_pixel_width, Sx_display_pixel_width, 0, 1, 0, 2365DEFUN ("x-display-pixel-width", Fx_display_pixel_width, Sx_display_pixel_width, 0, 1, 0,
2430 doc: /* Return the width in pixels of the display TERMINAL. 2366 doc: /* Return the width in pixels of the display TERMINAL.
2431The optional argument TERMINAL specifies which display to ask about. 2367The optional argument TERMINAL specifies which display to ask about.
@@ -2471,7 +2407,6 @@ each physical monitor, use `display-monitor-attributes-list'. */)
2471 return make_fixnum (width); 2407 return make_fixnum (width);
2472} 2408}
2473 2409
2474
2475DEFUN ("x-display-pixel-height", Fx_display_pixel_height, Sx_display_pixel_height, 0, 1, 0, 2410DEFUN ("x-display-pixel-height", Fx_display_pixel_height, Sx_display_pixel_height, 0, 1, 0,
2476 doc: /* Return the height in pixels of the display TERMINAL. 2411 doc: /* Return the height in pixels of the display TERMINAL.
2477The optional argument TERMINAL specifies which display to ask about. 2412The optional argument TERMINAL specifies which display to ask about.
@@ -3066,7 +3001,7 @@ compute_tip_xy (struct frame *f, Lisp_Object parms, Lisp_Object dx,
3066 3001
3067/* Hide tooltip. Delete its frame if DELETE is true. */ 3002/* Hide tooltip. Delete its frame if DELETE is true. */
3068static Lisp_Object 3003static Lisp_Object
3069x_hide_tip (bool delete) 3004pgtk_hide_tip (bool delete)
3070{ 3005{
3071 if (!NILP (tip_timer)) 3006 if (!NILP (tip_timer))
3072 { 3007 {
@@ -3306,13 +3241,13 @@ Text larger than the specified size is clipped. */)
3306 } 3241 }
3307 } 3242 }
3308 3243
3309 x_hide_tip (delete); 3244 pgtk_hide_tip (delete);
3310 } 3245 }
3311 else 3246 else
3312 x_hide_tip (true); 3247 pgtk_hide_tip (true);
3313 } 3248 }
3314 else 3249 else
3315 x_hide_tip (true); 3250 pgtk_hide_tip (true);
3316 3251
3317 tip_last_frame = frame; 3252 tip_last_frame = frame;
3318 tip_last_string = string; 3253 tip_last_string = string;
@@ -3439,7 +3374,7 @@ DEFUN ("x-hide-tip", Fx_hide_tip, Sx_hide_tip, 0, 0, 0,
3439Value is t if tooltip was open, nil otherwise. */) 3374Value is t if tooltip was open, nil otherwise. */)
3440 (void) 3375 (void)
3441{ 3376{
3442 return x_hide_tip (!tooltip_reuse_hidden_frame); 3377 return pgtk_hide_tip (!tooltip_reuse_hidden_frame);
3443} 3378}
3444 3379
3445/* Return geometric attributes of FRAME. According to the value of 3380/* Return geometric attributes of FRAME. According to the value of
@@ -3465,10 +3400,8 @@ frame_geometry (Lisp_Object frame, Lisp_Object attribute)
3465 int left_pos, top_pos; 3400 int left_pos, top_pos;
3466 3401
3467 if (FRAME_GTK_OUTER_WIDGET (f)) 3402 if (FRAME_GTK_OUTER_WIDGET (f))
3468 { 3403 gtk_window_get_position (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)),
3469 gtk_window_get_position (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)), 3404 &left_pos, &top_pos);
3470 &left_pos, &top_pos);
3471 }
3472 else 3405 else
3473 { 3406 {
3474 GtkAllocation alloc; 3407 GtkAllocation alloc;
@@ -3912,7 +3845,6 @@ syms_of_pgtkfns (void)
3912 g_free (ver); 3845 g_free (ver);
3913 } 3846 }
3914 3847
3915
3916 defsubr (&Spgtk_set_resource); 3848 defsubr (&Spgtk_set_resource);
3917 defsubr (&Sxw_display_color_p); /* this and next called directly by C code */ 3849 defsubr (&Sxw_display_color_p); /* this and next called directly by C code */
3918 defsubr (&Sx_display_grayscale_p); 3850 defsubr (&Sx_display_grayscale_p);
@@ -3942,9 +3874,6 @@ syms_of_pgtkfns (void)
3942 defsubr (&Sx_display_list); 3874 defsubr (&Sx_display_list);
3943 defsubr (&Sx_gtk_debug); 3875 defsubr (&Sx_gtk_debug);
3944 3876
3945 defsubr (&Spgtk_hide_others);
3946 defsubr (&Spgtk_hide_emacs);
3947
3948 defsubr (&Sx_show_tip); 3877 defsubr (&Sx_show_tip);
3949 defsubr (&Sx_hide_tip); 3878 defsubr (&Sx_hide_tip);
3950 3879