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.
This commit is contained in:
parent
5346b67fc2
commit
b629cb3f54
4 changed files with 74 additions and 76 deletions
107
src/gtkutil.c
107
src/gtkutil.c
|
@ -736,67 +736,74 @@ xg_check_special_colors (struct frame *f,
|
|||
const char *color_name,
|
||||
Emacs_Color *color)
|
||||
{
|
||||
bool success_p = 0;
|
||||
bool get_bg = strcmp ("gtk_selection_bg_color", color_name) == 0;
|
||||
bool get_fg = !get_bg && strcmp ("gtk_selection_fg_color", color_name) == 0;
|
||||
bool success_p;
|
||||
bool get_bg;
|
||||
bool get_fg;
|
||||
#ifdef HAVE_GTK3
|
||||
GtkStyleContext *gsty;
|
||||
GdkRGBA col;
|
||||
char buf[sizeof "rgb://rrrr/gggg/bbbb"];
|
||||
int state;
|
||||
GdkRGBA *c;
|
||||
unsigned short r, g, b;
|
||||
#else
|
||||
GtkStyle *gsty;
|
||||
GdkColor *grgb;
|
||||
#endif
|
||||
|
||||
if (! FRAME_GTK_WIDGET (f) || ! (get_bg || get_fg))
|
||||
get_bg = !strcmp ("gtk_selection_bg_color", color_name);
|
||||
get_fg = !get_bg && !strcmp ("gtk_selection_fg_color", color_name);
|
||||
success_p = false;
|
||||
|
||||
#ifdef HAVE_PGTK
|
||||
while (FRAME_PARENT_FRAME (f))
|
||||
f = FRAME_PARENT_FRAME (f);
|
||||
#endif
|
||||
|
||||
if (!FRAME_GTK_WIDGET (f) || !(get_bg || get_fg))
|
||||
return success_p;
|
||||
|
||||
block_input ();
|
||||
{
|
||||
#ifdef HAVE_GTK3
|
||||
gsty = gtk_widget_get_style_context (FRAME_GTK_OUTER_WIDGET (f));
|
||||
state = GTK_STATE_FLAG_SELECTED | GTK_STATE_FLAG_FOCUSED;
|
||||
|
||||
if (get_fg)
|
||||
gtk_style_context_get_color (gsty, state, &col);
|
||||
else
|
||||
{
|
||||
/* FIXME: Retrieving the background color is deprecated in
|
||||
GTK+ 3.16. New versions of GTK+ don't use the concept of a
|
||||
single background color any more, so we shouldn't query for
|
||||
it. */
|
||||
gtk_style_context_get (gsty, state,
|
||||
GTK_STYLE_PROPERTY_BACKGROUND_COLOR, &c,
|
||||
NULL);
|
||||
col = *c;
|
||||
gdk_rgba_free (c);
|
||||
}
|
||||
|
||||
r = col.red * 65535;
|
||||
g = col.green * 65535;
|
||||
b = col.blue * 65535;
|
||||
#ifndef HAVE_PGTK
|
||||
GtkStyleContext *gsty
|
||||
= gtk_widget_get_style_context (FRAME_GTK_OUTER_WIDGET (f));
|
||||
sprintf (buf, "rgb:%04x/%04x/%04x", r, g, b);
|
||||
success_p = x_parse_color (f, buf, color) != 0;
|
||||
#else
|
||||
GtkStyleContext *gsty
|
||||
= gtk_widget_get_style_context (FRAME_WIDGET (f));
|
||||
#endif
|
||||
GdkRGBA col;
|
||||
char buf[sizeof "rgb://rrrr/gggg/bbbb"];
|
||||
int state = GTK_STATE_FLAG_SELECTED|GTK_STATE_FLAG_FOCUSED;
|
||||
if (get_fg)
|
||||
gtk_style_context_get_color (gsty, state, &col);
|
||||
else
|
||||
{
|
||||
GdkRGBA *c;
|
||||
/* FIXME: Retrieving the background color is deprecated in
|
||||
GTK+ 3.16. New versions of GTK+ don't use the concept of a
|
||||
single background color any more, so we shouldn't query for
|
||||
it. */
|
||||
gtk_style_context_get (gsty, state,
|
||||
GTK_STYLE_PROPERTY_BACKGROUND_COLOR, &c,
|
||||
NULL);
|
||||
col = *c;
|
||||
gdk_rgba_free (c);
|
||||
}
|
||||
|
||||
unsigned short
|
||||
r = col.red * 65535,
|
||||
g = col.green * 65535,
|
||||
b = col.blue * 65535;
|
||||
#ifndef HAVE_PGTK
|
||||
sprintf (buf, "rgb:%04x/%04x/%04x", r, g, b);
|
||||
success_p = x_parse_color (f, buf, color) != 0;
|
||||
#else
|
||||
sprintf (buf, "#%04x%04x%04x", r, g, b);
|
||||
success_p = pgtk_parse_color (f, buf, color) != 0;
|
||||
sprintf (buf, "#%04x%04x%04x", r, g, b);
|
||||
success_p = pgtk_parse_color (f, buf, color) != 0;
|
||||
#endif
|
||||
#else
|
||||
GtkStyle *gsty = gtk_widget_get_style (FRAME_GTK_WIDGET (f));
|
||||
GdkColor *grgb = get_bg
|
||||
? &gsty->bg[GTK_STATE_SELECTED]
|
||||
: &gsty->fg[GTK_STATE_SELECTED];
|
||||
gsty = gtk_widget_get_style (FRAME_GTK_WIDGET (f));
|
||||
grgb = (get_bg ? &gsty->bg[GTK_STATE_SELECTED]
|
||||
: &gsty->fg[GTK_STATE_SELECTED]);
|
||||
|
||||
color->red = grgb->red;
|
||||
color->green = grgb->green;
|
||||
color->blue = grgb->blue;
|
||||
color->pixel = grgb->pixel;
|
||||
success_p = 1;
|
||||
color->red = grgb->red;
|
||||
color->green = grgb->green;
|
||||
color->blue = grgb->blue;
|
||||
color->pixel = grgb->pixel;
|
||||
success_p = 1;
|
||||
#endif
|
||||
|
||||
}
|
||||
unblock_input ();
|
||||
return success_p;
|
||||
}
|
||||
|
|
|
@ -566,15 +566,23 @@ pgtk_set_tool_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval)
|
|||
static void
|
||||
pgtk_set_child_frame_border_width (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
|
||||
{
|
||||
int border = check_int_nonnegative (arg);
|
||||
int border;
|
||||
|
||||
if (NILP (arg))
|
||||
border = -1;
|
||||
else if (RANGED_FIXNUMP (0, arg, INT_MAX))
|
||||
border = XFIXNAT (arg);
|
||||
else
|
||||
signal_error ("Invalid child frame border width", arg);
|
||||
|
||||
if (border != FRAME_CHILD_FRAME_BORDER_WIDTH (f))
|
||||
{
|
||||
f->child_frame_border_width = border;
|
||||
|
||||
if (FRAME_X_WINDOW (f))
|
||||
if (FRAME_GTK_WIDGET (f))
|
||||
{
|
||||
adjust_frame_size (f, -1, -1, 3, false, Qchild_frame_border_width);
|
||||
adjust_frame_size (f, -1, -1, 3,
|
||||
false, Qchild_frame_border_width);
|
||||
pgtk_clear_under_internal_border (f);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -610,11 +610,6 @@ pgtk_menu_show (struct frame *f, int x, int y, int menuflags,
|
|||
|
||||
*error_name = NULL;
|
||||
|
||||
if (!FRAME_GTK_OUTER_WIDGET (f)) {
|
||||
*error_name = "Can't popup from child frames.";
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
if (menu_items_used <= MENU_ITEMS_PANE_LENGTH)
|
||||
{
|
||||
*error_name = "Empty menu";
|
||||
|
@ -919,11 +914,6 @@ pgtk_dialog_show (struct frame *f, Lisp_Object title,
|
|||
|
||||
*error_name = NULL;
|
||||
|
||||
if (!FRAME_GTK_OUTER_WIDGET (f)) {
|
||||
*error_name = "Can't popup from child frames.";
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
if (menu_items_n_panes > 1)
|
||||
{
|
||||
*error_name = "Multiple panes in dialog box";
|
||||
|
|
|
@ -3351,15 +3351,10 @@ pgtk_mouse_position (struct frame **fp, int insist, Lisp_Object * bar_window,
|
|||
if (gui_mouse_grabbed (dpyinfo)
|
||||
&& (!EQ (track_mouse, Qdropping)
|
||||
&& !EQ (track_mouse, Qdrag_source)))
|
||||
{
|
||||
/* 1.1. use last_mouse_frame as frame where the pointer is
|
||||
on. */
|
||||
f1 = dpyinfo->last_mouse_frame;
|
||||
}
|
||||
f1 = dpyinfo->last_mouse_frame;
|
||||
else
|
||||
{
|
||||
f1 = *fp;
|
||||
/* 1.2. get frame where the pointer is on. */
|
||||
win = gtk_widget_get_window (FRAME_GTK_WIDGET (*fp));
|
||||
seat = gdk_display_get_default_seat (dpyinfo->gdpy);
|
||||
device = gdk_seat_get_pointer (seat);
|
||||
|
@ -3385,19 +3380,17 @@ pgtk_mouse_position (struct frame **fp, int insist, Lisp_Object * bar_window,
|
|||
return;
|
||||
}
|
||||
|
||||
/* 2. get the display and the device. */
|
||||
win = gtk_widget_get_window (FRAME_GTK_WIDGET (f1));
|
||||
GdkDisplay *gdpy = gdk_window_get_display (win);
|
||||
seat = gdk_display_get_default_seat (gdpy);
|
||||
seat = gdk_display_get_default_seat (dpyinfo->gdpy);
|
||||
device = gdk_seat_get_pointer (seat);
|
||||
|
||||
/* 3. get x, y relative to edit window of the frame. */
|
||||
win = gdk_window_get_device_position (win, device, &win_x, &win_y, &mask);
|
||||
win = gdk_window_get_device_position (win, device,
|
||||
&win_x, &win_y, &mask);
|
||||
|
||||
if (f1 != NULL)
|
||||
{
|
||||
dpyinfo = FRAME_DISPLAY_INFO (f1);
|
||||
remember_mouse_glyph (f1, win_x, win_y, &dpyinfo->last_mouse_glyph);
|
||||
remember_mouse_glyph (f1, win_x, win_y,
|
||||
&dpyinfo->last_mouse_glyph);
|
||||
dpyinfo->last_mouse_glyph_frame = f1;
|
||||
|
||||
*bar_window = Qnil;
|
||||
|
|
Loading…
Add table
Reference in a new issue