diff options
| author | Po Lu | 2022-05-23 13:30:33 +0800 |
|---|---|---|
| committer | Po Lu | 2022-05-23 13:30:33 +0800 |
| commit | b629cb3f547b5acd6d4ee3574d31b3530f93ff1f (patch) | |
| tree | 4e79b0c67a52d3da1f6f8c4607495c39c62e5a0f /src | |
| parent | 5346b67fc27f50abeec3c4f72252a8d9a36f2e6b (diff) | |
| download | emacs-b629cb3f547b5acd6d4ee3574d31b3530f93ff1f.tar.gz emacs-b629cb3f547b5acd6d4ee3574d31b3530f93ff1f.zip | |
Minor fixes to PGTK child frames
* src/gtkutil.c (xg_check_special_colors): Handle child frames
correctly.
* src/pgtkfns.c (pgtk_set_child_frame_border_width): Synchronize
code from X. (bug#55588)
* src/pgtkmenu.c (pgtk_menu_show, pgtk_dialog_show): Allow in
child frames. There are no problems here.
* src/pgtkterm.c (pgtk_mouse_position): Clean up coding style.
Diffstat (limited to 'src')
| -rw-r--r-- | src/gtkutil.c | 105 | ||||
| -rw-r--r-- | src/pgtkfns.c | 14 | ||||
| -rw-r--r-- | src/pgtkmenu.c | 10 | ||||
| -rw-r--r-- | src/pgtkterm.c | 19 |
4 files changed, 73 insertions, 75 deletions
diff --git a/src/gtkutil.c b/src/gtkutil.c index 11ccbbd6683..f2018bc01f5 100644 --- a/src/gtkutil.c +++ b/src/gtkutil.c | |||
| @@ -736,67 +736,74 @@ xg_check_special_colors (struct frame *f, | |||
| 736 | const char *color_name, | 736 | const char *color_name, |
| 737 | Emacs_Color *color) | 737 | Emacs_Color *color) |
| 738 | { | 738 | { |
| 739 | bool success_p = 0; | 739 | bool success_p; |
| 740 | bool get_bg = strcmp ("gtk_selection_bg_color", color_name) == 0; | 740 | bool get_bg; |
| 741 | bool get_fg = !get_bg && strcmp ("gtk_selection_fg_color", color_name) == 0; | 741 | bool get_fg; |
| 742 | #ifdef HAVE_GTK3 | ||
| 743 | GtkStyleContext *gsty; | ||
| 744 | GdkRGBA col; | ||
| 745 | char buf[sizeof "rgb://rrrr/gggg/bbbb"]; | ||
| 746 | int state; | ||
| 747 | GdkRGBA *c; | ||
| 748 | unsigned short r, g, b; | ||
| 749 | #else | ||
| 750 | GtkStyle *gsty; | ||
| 751 | GdkColor *grgb; | ||
| 752 | #endif | ||
| 753 | |||
| 754 | get_bg = !strcmp ("gtk_selection_bg_color", color_name); | ||
| 755 | get_fg = !get_bg && !strcmp ("gtk_selection_fg_color", color_name); | ||
| 756 | success_p = false; | ||
| 742 | 757 | ||
| 743 | if (! FRAME_GTK_WIDGET (f) || ! (get_bg || get_fg)) | 758 | #ifdef HAVE_PGTK |
| 759 | while (FRAME_PARENT_FRAME (f)) | ||
| 760 | f = FRAME_PARENT_FRAME (f); | ||
| 761 | #endif | ||
| 762 | |||
| 763 | if (!FRAME_GTK_WIDGET (f) || !(get_bg || get_fg)) | ||
| 744 | return success_p; | 764 | return success_p; |
| 745 | 765 | ||
| 746 | block_input (); | 766 | block_input (); |
| 747 | { | ||
| 748 | #ifdef HAVE_GTK3 | 767 | #ifdef HAVE_GTK3 |
| 749 | #ifndef HAVE_PGTK | 768 | gsty = gtk_widget_get_style_context (FRAME_GTK_OUTER_WIDGET (f)); |
| 750 | GtkStyleContext *gsty | 769 | state = GTK_STATE_FLAG_SELECTED | GTK_STATE_FLAG_FOCUSED; |
| 751 | = gtk_widget_get_style_context (FRAME_GTK_OUTER_WIDGET (f)); | 770 | |
| 752 | #else | 771 | if (get_fg) |
| 753 | GtkStyleContext *gsty | 772 | gtk_style_context_get_color (gsty, state, &col); |
| 754 | = gtk_widget_get_style_context (FRAME_WIDGET (f)); | 773 | else |
| 755 | #endif | 774 | { |
| 756 | GdkRGBA col; | 775 | /* FIXME: Retrieving the background color is deprecated in |
| 757 | char buf[sizeof "rgb://rrrr/gggg/bbbb"]; | 776 | GTK+ 3.16. New versions of GTK+ don't use the concept of a |
| 758 | int state = GTK_STATE_FLAG_SELECTED|GTK_STATE_FLAG_FOCUSED; | 777 | single background color any more, so we shouldn't query for |
| 759 | if (get_fg) | 778 | it. */ |
| 760 | gtk_style_context_get_color (gsty, state, &col); | 779 | gtk_style_context_get (gsty, state, |
| 761 | else | 780 | GTK_STYLE_PROPERTY_BACKGROUND_COLOR, &c, |
| 762 | { | 781 | NULL); |
| 763 | GdkRGBA *c; | 782 | col = *c; |
| 764 | /* FIXME: Retrieving the background color is deprecated in | 783 | gdk_rgba_free (c); |
| 765 | GTK+ 3.16. New versions of GTK+ don't use the concept of a | 784 | } |
| 766 | single background color any more, so we shouldn't query for | ||
| 767 | it. */ | ||
| 768 | gtk_style_context_get (gsty, state, | ||
| 769 | GTK_STYLE_PROPERTY_BACKGROUND_COLOR, &c, | ||
| 770 | NULL); | ||
| 771 | col = *c; | ||
| 772 | gdk_rgba_free (c); | ||
| 773 | } | ||
| 774 | 785 | ||
| 775 | unsigned short | 786 | r = col.red * 65535; |
| 776 | r = col.red * 65535, | 787 | g = col.green * 65535; |
| 777 | g = col.green * 65535, | 788 | b = col.blue * 65535; |
| 778 | b = col.blue * 65535; | ||
| 779 | #ifndef HAVE_PGTK | 789 | #ifndef HAVE_PGTK |
| 780 | sprintf (buf, "rgb:%04x/%04x/%04x", r, g, b); | 790 | sprintf (buf, "rgb:%04x/%04x/%04x", r, g, b); |
| 781 | success_p = x_parse_color (f, buf, color) != 0; | 791 | success_p = x_parse_color (f, buf, color) != 0; |
| 782 | #else | 792 | #else |
| 783 | sprintf (buf, "#%04x%04x%04x", r, g, b); | 793 | sprintf (buf, "#%04x%04x%04x", r, g, b); |
| 784 | success_p = pgtk_parse_color (f, buf, color) != 0; | 794 | success_p = pgtk_parse_color (f, buf, color) != 0; |
| 785 | #endif | 795 | #endif |
| 786 | #else | 796 | #else |
| 787 | GtkStyle *gsty = gtk_widget_get_style (FRAME_GTK_WIDGET (f)); | 797 | gsty = gtk_widget_get_style (FRAME_GTK_WIDGET (f)); |
| 788 | GdkColor *grgb = get_bg | 798 | grgb = (get_bg ? &gsty->bg[GTK_STATE_SELECTED] |
| 789 | ? &gsty->bg[GTK_STATE_SELECTED] | 799 | : &gsty->fg[GTK_STATE_SELECTED]); |
| 790 | : &gsty->fg[GTK_STATE_SELECTED]; | ||
| 791 | 800 | ||
| 792 | color->red = grgb->red; | 801 | color->red = grgb->red; |
| 793 | color->green = grgb->green; | 802 | color->green = grgb->green; |
| 794 | color->blue = grgb->blue; | 803 | color->blue = grgb->blue; |
| 795 | color->pixel = grgb->pixel; | 804 | color->pixel = grgb->pixel; |
| 796 | success_p = 1; | 805 | success_p = 1; |
| 797 | #endif | 806 | #endif |
| 798 | |||
| 799 | } | ||
| 800 | unblock_input (); | 807 | unblock_input (); |
| 801 | return success_p; | 808 | return success_p; |
| 802 | } | 809 | } |
diff --git a/src/pgtkfns.c b/src/pgtkfns.c index 1feb3fe250d..b26709d90c0 100644 --- a/src/pgtkfns.c +++ b/src/pgtkfns.c | |||
| @@ -566,15 +566,23 @@ pgtk_set_tool_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval) | |||
| 566 | static void | 566 | static void |
| 567 | pgtk_set_child_frame_border_width (struct frame *f, Lisp_Object arg, Lisp_Object oldval) | 567 | pgtk_set_child_frame_border_width (struct frame *f, Lisp_Object arg, Lisp_Object oldval) |
| 568 | { | 568 | { |
| 569 | int border = check_int_nonnegative (arg); | 569 | int border; |
| 570 | |||
| 571 | if (NILP (arg)) | ||
| 572 | border = -1; | ||
| 573 | else if (RANGED_FIXNUMP (0, arg, INT_MAX)) | ||
| 574 | border = XFIXNAT (arg); | ||
| 575 | else | ||
| 576 | signal_error ("Invalid child frame border width", arg); | ||
| 570 | 577 | ||
| 571 | if (border != FRAME_CHILD_FRAME_BORDER_WIDTH (f)) | 578 | if (border != FRAME_CHILD_FRAME_BORDER_WIDTH (f)) |
| 572 | { | 579 | { |
| 573 | f->child_frame_border_width = border; | 580 | f->child_frame_border_width = border; |
| 574 | 581 | ||
| 575 | if (FRAME_X_WINDOW (f)) | 582 | if (FRAME_GTK_WIDGET (f)) |
| 576 | { | 583 | { |
| 577 | adjust_frame_size (f, -1, -1, 3, false, Qchild_frame_border_width); | 584 | adjust_frame_size (f, -1, -1, 3, |
| 585 | false, Qchild_frame_border_width); | ||
| 578 | pgtk_clear_under_internal_border (f); | 586 | pgtk_clear_under_internal_border (f); |
| 579 | } | 587 | } |
| 580 | } | 588 | } |
diff --git a/src/pgtkmenu.c b/src/pgtkmenu.c index eec9f419d07..2eabf6ac1bc 100644 --- a/src/pgtkmenu.c +++ b/src/pgtkmenu.c | |||
| @@ -610,11 +610,6 @@ pgtk_menu_show (struct frame *f, int x, int y, int menuflags, | |||
| 610 | 610 | ||
| 611 | *error_name = NULL; | 611 | *error_name = NULL; |
| 612 | 612 | ||
| 613 | if (!FRAME_GTK_OUTER_WIDGET (f)) { | ||
| 614 | *error_name = "Can't popup from child frames."; | ||
| 615 | return Qnil; | ||
| 616 | } | ||
| 617 | |||
| 618 | if (menu_items_used <= MENU_ITEMS_PANE_LENGTH) | 613 | if (menu_items_used <= MENU_ITEMS_PANE_LENGTH) |
| 619 | { | 614 | { |
| 620 | *error_name = "Empty menu"; | 615 | *error_name = "Empty menu"; |
| @@ -919,11 +914,6 @@ pgtk_dialog_show (struct frame *f, Lisp_Object title, | |||
| 919 | 914 | ||
| 920 | *error_name = NULL; | 915 | *error_name = NULL; |
| 921 | 916 | ||
| 922 | if (!FRAME_GTK_OUTER_WIDGET (f)) { | ||
| 923 | *error_name = "Can't popup from child frames."; | ||
| 924 | return Qnil; | ||
| 925 | } | ||
| 926 | |||
| 927 | if (menu_items_n_panes > 1) | 917 | if (menu_items_n_panes > 1) |
| 928 | { | 918 | { |
| 929 | *error_name = "Multiple panes in dialog box"; | 919 | *error_name = "Multiple panes in dialog box"; |
diff --git a/src/pgtkterm.c b/src/pgtkterm.c index 71b5f23283c..da958a6664a 100644 --- a/src/pgtkterm.c +++ b/src/pgtkterm.c | |||
| @@ -3351,15 +3351,10 @@ pgtk_mouse_position (struct frame **fp, int insist, Lisp_Object * bar_window, | |||
| 3351 | if (gui_mouse_grabbed (dpyinfo) | 3351 | if (gui_mouse_grabbed (dpyinfo) |
| 3352 | && (!EQ (track_mouse, Qdropping) | 3352 | && (!EQ (track_mouse, Qdropping) |
| 3353 | && !EQ (track_mouse, Qdrag_source))) | 3353 | && !EQ (track_mouse, Qdrag_source))) |
| 3354 | { | 3354 | f1 = dpyinfo->last_mouse_frame; |
| 3355 | /* 1.1. use last_mouse_frame as frame where the pointer is | ||
| 3356 | on. */ | ||
| 3357 | f1 = dpyinfo->last_mouse_frame; | ||
| 3358 | } | ||
| 3359 | else | 3355 | else |
| 3360 | { | 3356 | { |
| 3361 | f1 = *fp; | 3357 | f1 = *fp; |
| 3362 | /* 1.2. get frame where the pointer is on. */ | ||
| 3363 | win = gtk_widget_get_window (FRAME_GTK_WIDGET (*fp)); | 3358 | win = gtk_widget_get_window (FRAME_GTK_WIDGET (*fp)); |
| 3364 | seat = gdk_display_get_default_seat (dpyinfo->gdpy); | 3359 | seat = gdk_display_get_default_seat (dpyinfo->gdpy); |
| 3365 | device = gdk_seat_get_pointer (seat); | 3360 | device = gdk_seat_get_pointer (seat); |
| @@ -3385,19 +3380,17 @@ pgtk_mouse_position (struct frame **fp, int insist, Lisp_Object * bar_window, | |||
| 3385 | return; | 3380 | return; |
| 3386 | } | 3381 | } |
| 3387 | 3382 | ||
| 3388 | /* 2. get the display and the device. */ | ||
| 3389 | win = gtk_widget_get_window (FRAME_GTK_WIDGET (f1)); | 3383 | win = gtk_widget_get_window (FRAME_GTK_WIDGET (f1)); |
| 3390 | GdkDisplay *gdpy = gdk_window_get_display (win); | 3384 | seat = gdk_display_get_default_seat (dpyinfo->gdpy); |
| 3391 | seat = gdk_display_get_default_seat (gdpy); | ||
| 3392 | device = gdk_seat_get_pointer (seat); | 3385 | device = gdk_seat_get_pointer (seat); |
| 3393 | 3386 | ||
| 3394 | /* 3. get x, y relative to edit window of the frame. */ | 3387 | win = gdk_window_get_device_position (win, device, |
| 3395 | win = gdk_window_get_device_position (win, device, &win_x, &win_y, &mask); | 3388 | &win_x, &win_y, &mask); |
| 3396 | 3389 | ||
| 3397 | if (f1 != NULL) | 3390 | if (f1 != NULL) |
| 3398 | { | 3391 | { |
| 3399 | dpyinfo = FRAME_DISPLAY_INFO (f1); | 3392 | remember_mouse_glyph (f1, win_x, win_y, |
| 3400 | remember_mouse_glyph (f1, win_x, win_y, &dpyinfo->last_mouse_glyph); | 3393 | &dpyinfo->last_mouse_glyph); |
| 3401 | dpyinfo->last_mouse_glyph_frame = f1; | 3394 | dpyinfo->last_mouse_glyph_frame = f1; |
| 3402 | 3395 | ||
| 3403 | *bar_window = Qnil; | 3396 | *bar_window = Qnil; |