1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2025-01-21 18:23:59 +00:00

Updates for compiling with Gtk+ 3.0 (--with-x-toolkit=gtk3).

* configure.in: Require 3.0 for --with-gtk3.  Add HAVE_GTK3.

* doc/emacs/xresources.texi (GTK resources): ~/.emacs.d/gtkrc does not work
for Gtk+ 3.

* src/gtkutil.c: Include gtkx.h if HAVE_GTK3.  If ! HAVE_GTK3, define
gdk_window_get_screen, gdk_window_get_geometry,
gdk_x11_window_lookup_for_display and GDK_KEY_g.
(xg_set_screen): Use DEFAULT_GDK_DISPLAY.
(xg_get_pixbuf_from_pixmap): New function.
(xg_get_pixbuf_from_pix_and_mask): Change parameters from GdkPixmap
to Pixmap, take frame as parameter, remove GdkColormap parameter.
Call xg_get_pixbuf_from_pixmap instead of
gdk_pixbuf_get_from_drawable.
(xg_get_image_for_pixmap): Do not make GdkPixmaps, call
xg_get_pixbuf_from_pix_and_mask with Pixmap parameters instead.
(xg_check_special_colors): Use GtkStyleContext and its functions
for HAVE_GTK3.
(xg_prepare_tooltip, xg_hide_tooltip): Call gdk_window_get_screen.
(xg_prepare_tooltip, create_dialog, menubar_map_cb)
(xg_update_frame_menubar, xg_tool_bar_detach_callback)
(xg_tool_bar_attach_callback, xg_update_tool_bar_sizes): Call
gtk_widget_get_preferred_size.
(xg_frame_resized): gdk_window_get_geometry only takes 5
parameters.
(xg_win_to_widget, xg_event_is_for_menubar): Call
gdk_x11_window_lookup_for_display.
(xg_set_widget_bg): New function.
(delete_cb): New function.
(xg_create_frame_widgets): connect delete-event to delete_cb.
Call xg_set_widget_bg.  Only set backgrund pixmap for ! HAVE_GTK3
(xg_set_background_color): Call xg_set_widget_bg.
(xg_set_frame_icon): Call xg_get_pixbuf_from_pix_and_mask.
(xg_create_scroll_bar): vadj is a GtkAdjustment for HAVE_GTK3.
Only call gtk_range_set_update_policy if ! HAVE_GTK3.
(xg_make_tool_item): Only connect xg_tool_bar_item_expose_callback
if ! HAVE_GTK3.
(update_frame_tool_bar): Call gtk_widget_hide.
(xg_initialize): Use GDK_KEY_g.

* src/xmenu.c (menu_position_func): Call gtk_widget_get_preferred_size.

* src/xsmfns.c (gdk_set_sm_client_id): Define to gdk_set_sm_client_id
if ! HAVE_GTK3
(x_session_initialize): Call gdk_x11_set_sm_client_id.

* src/xterm.c (XFillRectangle): Use cairo routines for HAVE_GTK3.
(x_term_init): Disable Xinput(2) with GDK_CORE_DEVICE_EVENTS.
Load ~/emacs.d/gtkrc only for ! HAVE_GTK3.

* src/xterm.h (DEFAULT_GDK_DISPLAY): New define.
(GDK_WINDOW_XID, gtk_widget_get_preferred_size): New defines
for ! HAVE_GTK3.
(GTK_WIDGET_TO_X_WIN): Use GDK_WINDOW_XID.
This commit is contained in:
Jan D 2011-03-08 09:34:55 +01:00
parent 25bbfb31d5
commit 0afb4571a7
13 changed files with 534 additions and 354 deletions

View File

@ -1,3 +1,7 @@
2011-03-08 Jan Djärv <jan.h.d@swipnet.se>
* configure.in: Require 3.0 for --with-gtk3. Add HAVE_GTK3.
2011-03-06 Glenn Morris <rgm@gnu.org>
* configure.in (FREETYPE_LIBS): Actually set it to something.

4
aclocal.m4 vendored
View File

@ -13,8 +13,8 @@
m4_ifndef([AC_AUTOCONF_VERSION],
[m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.67],,
[m4_warning([this file was generated for autoconf 2.67.
m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.65],,
[m4_warning([this file was generated for autoconf 2.65.
You have another version of autoconf. It may work, but is not guaranteed to.
If you have problems, you may need to regenerate the build system entirely.
To do so, use the procedure documented by the package, typically `autoreconf'.])])

491
configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -1826,8 +1826,8 @@ fi
HAVE_GTK=no
if test "${with_gtk3}" = "yes"; then
GLIB_REQUIRED=2.6
GTK_REQUIRED=2.90
GLIB_REQUIRED=2.28
GTK_REQUIRED=3.0
GTK_MODULES="gtk+-3.0 >= $GTK_REQUIRED glib-2.0 >= $GLIB_REQUIRED"
dnl Checks for libraries.
@ -1835,6 +1835,7 @@ if test "${with_gtk3}" = "yes"; then
if test "$pkg_check_gtk" = "no" && test "$USE_X_TOOLKIT" != "maybe"; then
AC_MSG_ERROR($GTK_PKG_ERRORS)
fi
AC_DEFINE(HAVE_GTK3, 1, [Define to 1 if using GTK 3 or later.])
fi
if test "$pkg_check_gtk" != "yes"; then

View File

@ -1,3 +1,8 @@
2011-03-08 Jan Djärv <jan.h.d@swipnet.se>
* xresources.texi (GTK resources): ~/.emacs.d/gtkrc does not work
for Gtk+ 3.
2011-03-08 Glenn Morris <rgm@gnu.org>
* display.texi (Optional Mode Line): Don't mention exactly where

View File

@ -660,8 +660,11 @@ The color for the border shadow, on the top and the left.
@iftex
The most common way to customize the GTK widgets Emacs uses (menus, dialogs
tool bars and scroll bars) is by choosing an appropriate theme, for example
with the GNOME theme selector. You can also do Emacs specific customization
by inserting GTK style directives in the file @file{~/.emacs.d/gtkrc}. Some GTK
with the GNOME theme selector.
You can also do Emacs specific customization
by inserting GTK style directives in the file @file{~/.emacs.d/gtkrc},
but only if you have a Gtk+ version earlier than 3 (i.e. 2). Some GTK
themes ignore customizations in @file{~/.emacs.d/gtkrc} so not everything
works with all themes. To customize Emacs font, background, faces, etc., use
the normal X resources (@pxref{Resources}). We will present some examples of

View File

@ -1,3 +1,55 @@
2011-03-08 Jan Djärv <jan.h.d@swipnet.se>
* xterm.h (DEFAULT_GDK_DISPLAY): New define.
(GDK_WINDOW_XID, gtk_widget_get_preferred_size): New defines
for ! HAVE_GTK3.
(GTK_WIDGET_TO_X_WIN): Use GDK_WINDOW_XID.
* xmenu.c (menu_position_func): Call gtk_widget_get_preferred_size.
* gtkutil.c: Include gtkx.h if HAVE_GTK3. If ! HAVE_GTK3, define
gdk_window_get_screen, gdk_window_get_geometry,
gdk_x11_window_lookup_for_display and GDK_KEY_g.
(xg_set_screen): Use DEFAULT_GDK_DISPLAY.
(xg_get_pixbuf_from_pixmap): New function.
(xg_get_pixbuf_from_pix_and_mask): Change parameters from GdkPixmap
to Pixmap, take frame as parameter, remove GdkColormap parameter.
Call xg_get_pixbuf_from_pixmap instead of
gdk_pixbuf_get_from_drawable.
(xg_get_image_for_pixmap): Do not make GdkPixmaps, call
xg_get_pixbuf_from_pix_and_mask with Pixmap parameters instead.
(xg_check_special_colors): Use GtkStyleContext and its functions
for HAVE_GTK3.
(xg_prepare_tooltip, xg_hide_tooltip): Call gdk_window_get_screen.
(xg_prepare_tooltip, create_dialog, menubar_map_cb)
(xg_update_frame_menubar, xg_tool_bar_detach_callback)
(xg_tool_bar_attach_callback, xg_update_tool_bar_sizes): Call
gtk_widget_get_preferred_size.
(xg_frame_resized): gdk_window_get_geometry only takes 5
parameters.
(xg_win_to_widget, xg_event_is_for_menubar): Call
gdk_x11_window_lookup_for_display.
(xg_set_widget_bg): New function.
(delete_cb): New function.
(xg_create_frame_widgets): connect delete-event to delete_cb.
Call xg_set_widget_bg. Only set backgrund pixmap for ! HAVE_GTK3
(xg_set_background_color): Call xg_set_widget_bg.
(xg_set_frame_icon): Call xg_get_pixbuf_from_pix_and_mask.
(xg_create_scroll_bar): vadj is a GtkAdjustment for HAVE_GTK3.
Only call gtk_range_set_update_policy if ! HAVE_GTK3.
(xg_make_tool_item): Only connect xg_tool_bar_item_expose_callback
if ! HAVE_GTK3.
(update_frame_tool_bar): Call gtk_widget_hide.
(xg_initialize): Use GDK_KEY_g.
* xsmfns.c (gdk_set_sm_client_id): Define to gdk_set_sm_client_id
if ! HAVE_GTK3
(x_session_initialize): Call gdk_x11_set_sm_client_id.
* xterm.c (XFillRectangle): Use cairo routines for HAVE_GTK3.
(x_term_init): Disable Xinput(2) with GDK_CORE_DEVICE_EVENTS.
Load ~/emacs.d/gtkrc only for ! HAVE_GTK3.
2011-03-08 Juanma Barranquero <lekktu@gmail.com>
* w32xfns.c (select_palette): Check success of RealizePalette against

View File

@ -285,6 +285,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
/* Define to 1 if you have the `grantpt' function. */
#undef HAVE_GRANTPT
/* Define to 1 if using GTK 3 or later. */
#undef HAVE_GTK3
/* Define to 1 if you have the `gtk_adjustment_get_page_size' function. */
#undef HAVE_GTK_ADJUSTMENT_GET_PAGE_SIZE

View File

@ -40,6 +40,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <X11/Xft/Xft.h>
#endif
#ifdef HAVE_GTK3
#include <gtk/gtkx.h>
#endif
#define FRAME_TOTAL_PIXEL_HEIGHT(f) \
(FRAME_PIXEL_HEIGHT (f) + FRAME_MENUBAR_HEIGHT (f) + FRAME_TOOLBAR_HEIGHT (f))
@ -69,6 +73,15 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#define remove_submenu(w) gtk_menu_item_remove_submenu ((w))
#endif
#ifndef HAVE_GTK3
#define gdk_window_get_screen(w) gdk_drawable_get_screen (w)
#define gdk_window_get_geometry(w, a, b, c, d) \
gdk_window_get_geometry (w, a, b, c, d, 0)
#define gdk_x11_window_lookup_for_display(d, w) \
gdk_xid_table_lookup_for_display (d, w)
#define GDK_KEY_g GDK_g
#endif
#define XG_BIN_CHILD(x) gtk_bin_get_child (GTK_BIN (x))
@ -88,7 +101,7 @@ static GdkDisplay *gdpy_def;
static void
xg_set_screen (GtkWidget *w, FRAME_PTR f)
{
if (FRAME_X_DISPLAY (f) != GDK_DISPLAY ())
if (FRAME_X_DISPLAY (f) != DEFAULT_GDK_DISPLAY ())
{
GdkDisplay *gdpy = gdk_x11_lookup_xdisplay (FRAME_X_DISPLAY (f));
GdkScreen *gscreen = gdk_display_get_default_screen (gdpy);
@ -229,29 +242,55 @@ xg_create_default_cursor (Display *dpy)
return gdk_cursor_new_for_display (gdpy, GDK_LEFT_PTR);
}
static GdkPixbuf *
xg_get_pixbuf_from_pixmap (FRAME_PTR f, Pixmap pix)
{
int iunused;
GdkPixbuf *tmp_buf;
Window wunused;
unsigned int width, height, uunused;
XImage *xim;
XGetGeometry (FRAME_X_DISPLAY (f), pix, &wunused, &iunused, &iunused,
&width, &height, &uunused, &uunused);
xim = XGetImage (FRAME_X_DISPLAY (f), pix, 0, 0, width, height,
~0, XYPixmap);
if (!xim) return 0;
tmp_buf = gdk_pixbuf_new_from_data (xim->data,
GDK_COLORSPACE_RGB,
FALSE,
xim->bitmap_unit,
(int) width,
(int) height,
xim->bytes_per_line,
NULL,
NULL);
XDestroyImage (xim);
return tmp_buf;
}
/* Apply GMASK to GPIX and return a GdkPixbuf with an alpha channel. */
static GdkPixbuf *
xg_get_pixbuf_from_pix_and_mask (GdkPixmap *gpix,
GdkPixmap *gmask,
GdkColormap *cmap)
xg_get_pixbuf_from_pix_and_mask (FRAME_PTR f,
Pixmap pix,
Pixmap mask)
{
int width, height;
GdkPixbuf *icon_buf, *tmp_buf;
gdk_drawable_get_size (gpix, &width, &height);
tmp_buf = gdk_pixbuf_get_from_drawable (NULL, gpix, cmap,
0, 0, 0, 0, width, height);
tmp_buf = xg_get_pixbuf_from_pixmap (f, pix);
icon_buf = gdk_pixbuf_add_alpha (tmp_buf, FALSE, 0, 0, 0);
g_object_unref (G_OBJECT (tmp_buf));
if (gmask)
width = gdk_pixbuf_get_width (icon_buf);
height = gdk_pixbuf_get_height (icon_buf);
if (mask)
{
GdkPixbuf *mask_buf = gdk_pixbuf_get_from_drawable (NULL,
gmask,
NULL,
0, 0, 0, 0,
width, height);
GdkPixbuf *mask_buf = xg_get_pixbuf_from_pixmap (f, mask);
guchar *pixels = gdk_pixbuf_get_pixels (icon_buf);
guchar *mask_pixels = gdk_pixbuf_get_pixels (mask_buf);
int rowstride = gdk_pixbuf_get_rowstride (icon_buf);
@ -316,10 +355,6 @@ xg_get_image_for_pixmap (FRAME_PTR f,
GtkWidget *widget,
GtkImage *old_widget)
{
GdkPixmap *gpix;
GdkPixmap *gmask;
GdkDisplay *gdpy;
GdkColormap *cmap;
GdkPixbuf *icon_buf;
/* If we have a file, let GTK do all the image handling.
@ -347,10 +382,6 @@ xg_get_image_for_pixmap (FRAME_PTR f,
on a monochrome display, and sometimes bad on all displays with
certain themes. */
gdpy = gdk_x11_lookup_xdisplay (FRAME_X_DISPLAY (f));
gpix = gdk_pixmap_foreign_new_for_display (gdpy, img->pixmap);
gmask = img->mask ? gdk_pixmap_foreign_new_for_display (gdpy, img->mask) : 0;
/* This is a workaround to make icons look good on pseudo color
displays. Apparently GTK expects the images to have an alpha
channel. If they don't, insensitive and activated icons will
@ -360,18 +391,17 @@ xg_get_image_for_pixmap (FRAME_PTR f,
not associated with the img->pixmap. The img->pixmap may be removed
by clearing the image cache and then the tool bar redraw fails, since
Gtk+ assumes the pixmap is always there. */
cmap = gtk_widget_get_colormap (widget);
icon_buf = xg_get_pixbuf_from_pix_and_mask (gpix, gmask, cmap);
icon_buf = xg_get_pixbuf_from_pix_and_mask (f, img->pixmap, img->mask);
if (! old_widget)
old_widget = GTK_IMAGE (gtk_image_new_from_pixbuf (icon_buf));
else
gtk_image_set_from_pixbuf (old_widget, icon_buf);
if (icon_buf)
{
if (! old_widget)
old_widget = GTK_IMAGE (gtk_image_new_from_pixbuf (icon_buf));
else
gtk_image_set_from_pixbuf (old_widget, icon_buf);
g_object_unref (G_OBJECT (icon_buf));
g_object_unref (G_OBJECT (gpix));
if (gmask) g_object_unref (G_OBJECT (gmask));
g_object_unref (G_OBJECT (icon_buf));
}
return GTK_WIDGET (old_widget);
}
@ -514,28 +544,43 @@ xg_check_special_colors (struct frame *f,
XColor *color)
{
int success_p = 0;
if (FRAME_GTK_WIDGET (f))
{
if (strcmp ("gtk_selection_bg_color", color_name) == 0)
{
GtkStyle *gsty = gtk_widget_get_style (FRAME_GTK_WIDGET (f));
color->red = gsty->bg[GTK_STATE_SELECTED].red;
color->green = gsty->bg[GTK_STATE_SELECTED].green;
color->blue = gsty->bg[GTK_STATE_SELECTED].blue;
color->pixel = gsty->bg[GTK_STATE_SELECTED].pixel;
success_p = 1;
}
else if (strcmp ("gtk_selection_fg_color", color_name) == 0)
{
GtkStyle *gsty = gtk_widget_get_style (FRAME_GTK_WIDGET (f));
color->red = gsty->fg[GTK_STATE_SELECTED].red;
color->green = gsty->fg[GTK_STATE_SELECTED].green;
color->blue = gsty->fg[GTK_STATE_SELECTED].blue;
color->pixel = gsty->fg[GTK_STATE_SELECTED].pixel;
success_p = 1;
}
}
int get_bg = strcmp ("gtk_selection_bg_color", color_name) == 0;
int get_fg = !get_bg && strcmp ("gtk_selection_fg_color", color_name) == 0;
if (! FRAME_GTK_WIDGET (f) || ! (get_bg || get_fg))
return success_p;
BLOCK_INPUT;
{
#ifdef HAVE_GTK3
GtkStyleContext *gsty
= gtk_widget_get_style_context (FRAME_GTK_OUTER_WIDGET (f));
GdkRGBA col;
char buf[64];
int state = GTK_STATE_FLAG_SELECTED|GTK_STATE_FLAG_FOCUSED;
if (get_fg)
gtk_style_context_get_color (gsty, state, &col);
else
gtk_style_context_get_background_color (gsty, state, &col);
sprintf (buf, "rgbi:%lf/%lf/%lf", col.red, col.green, col.blue);
success_p = XParseColor (FRAME_X_DISPLAY (f), FRAME_X_COLORMAP (f),
buf, color);
#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];
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;
}
@ -629,7 +674,7 @@ xg_prepare_tooltip (FRAME_PTR f,
encoded_string = ENCODE_UTF_8 (string);
widget = GTK_WIDGET (x->ttip_lbl);
gwin = gtk_widget_get_window (GTK_WIDGET (x->ttip_window));
screen = gdk_drawable_get_screen (gwin);
screen = gdk_window_get_screen (gwin);
settings = gtk_settings_get_for_screen (screen);
g_object_get (settings, "gtk-enable-tooltips", &tt_enabled, NULL);
if (tt_enabled)
@ -650,7 +695,7 @@ xg_prepare_tooltip (FRAME_PTR f,
gtk_tooltip_set_custom (x->ttip_widget, widget);
gtk_tooltip_set_text (x->ttip_widget, SDATA (encoded_string));
gtk_widget_size_request (GTK_WIDGET (x->ttip_window), &req);
gtk_widget_get_preferred_size (GTK_WIDGET (x->ttip_window), NULL, &req);
if (width) *width = req.width;
if (height) *height = req.height;
@ -696,7 +741,7 @@ xg_hide_tooltip (FRAME_PTR f)
if (g_object_get_data (G_OBJECT (win), "restore-tt"))
{
GdkWindow *gwin = gtk_widget_get_window (GTK_WIDGET (win));
GdkScreen *screen = gdk_drawable_get_screen (gwin);
GdkScreen *screen = gdk_window_get_screen (gwin);
GtkSettings *settings = gtk_settings_get_for_screen (screen);
g_object_set (settings, "gtk-enable-tooltips", TRUE, NULL);
}
@ -797,7 +842,7 @@ xg_frame_resized (FRAME_PTR f, int pixelwidth, int pixelheight)
if (FRAME_GTK_WIDGET (f) && gtk_widget_get_mapped (FRAME_GTK_WIDGET (f)))
gdk_window_get_geometry (gtk_widget_get_window (FRAME_GTK_WIDGET (f)),
0, 0,
&pixelwidth, &pixelheight, 0);
&pixelwidth, &pixelheight);
else return;
}
@ -910,8 +955,8 @@ xg_win_to_widget (Display *dpy, Window wdesc)
BLOCK_INPUT;
gdkwin = gdk_xid_table_lookup_for_display (gdk_x11_lookup_xdisplay (dpy),
wdesc);
gdkwin = gdk_x11_window_lookup_for_display (gdk_x11_lookup_xdisplay (dpy),
wdesc);
if (gdkwin)
{
GdkEvent event;
@ -923,14 +968,29 @@ xg_win_to_widget (Display *dpy, Window wdesc)
return gwdesc;
}
/* Fill in the GdkColor C so that it represents PIXEL.
W is the widget that color will be used for. Used to find colormap. */
/* Set the background of widget W to PIXEL. */
static void
xg_pix_to_gcolor (GtkWidget *w, long unsigned int pixel, GdkColor *c)
xg_set_widget_bg (FRAME_PTR f, GtkWidget *w, long unsigned int pixel)
{
#ifdef HAVE_GTK3
GdkRGBA bg;
XColor xbg;
xbg.pixel = pixel;
if (XQueryColor (FRAME_X_DISPLAY (f), FRAME_X_COLORMAP (f), &xbg))
{
bg.red = (double)xbg.red/65536.0;
bg.green = (double)xbg.green/65536.0;
bg.blue = (double)xbg.blue/65536.0;
bg.alpha = 1.0;
gtk_widget_override_background_color (w, GTK_STATE_FLAG_NORMAL, &bg);
}
#else
GdkColor bg;
GdkColormap *map = gtk_widget_get_colormap (w);
gdk_colormap_query_color (map, pixel, c);
gdk_colormap_query_color (map, pixel, &bg);
gtk_widget_modify_bg (FRAME_GTK_WIDGET (f), GTK_STATE_NORMAL, &bg);
#endif
}
/* Callback called when the gtk theme changes.
@ -953,6 +1013,28 @@ style_changed_cb (GObject *go,
kbd_buffer_store_event (&event);
}
/* Called when a delete-event occurs on WIDGET. */
static gboolean
delete_cb (GtkWidget *widget,
GdkEvent *event,
gpointer user_data)
{
#ifdef HAVE_GTK3
/* The event doesn't arrive in the normal event loop. Send event
here. */
FRAME_PTR f = (FRAME_PTR) user_data;
struct input_event ie;
EVENT_INIT (ie);
ie.kind = DELETE_WINDOW_EVENT;
XSETFRAME (ie.frame_or_window, f);
kbd_buffer_store_event (&ie);
#endif
return TRUE;
}
/* Create and set up the GTK widgets for frame F.
Return 0 if creation failed, non-zero otherwise. */
@ -962,7 +1044,6 @@ xg_create_frame_widgets (FRAME_PTR f)
GtkWidget *wtop;
GtkWidget *wvbox, *whbox;
GtkWidget *wfixed;
GdkColor bg;
GtkRcStyle *style;
char *title = 0;
@ -1029,7 +1110,7 @@ xg_create_frame_widgets (FRAME_PTR f)
/* Add callback to do nothing on WM_DELETE_WINDOW. The default in
GTK is to destroy the widget. We want Emacs to do that instead. */
g_signal_connect (G_OBJECT (wtop), "delete-event",
G_CALLBACK (gtk_true), 0);
G_CALLBACK (delete_cb), f);
/* Convert our geometry parameters into a geometry string
and specify it.
@ -1057,9 +1138,9 @@ xg_create_frame_widgets (FRAME_PTR f)
/* Since GTK clears its window by filling with the background color,
we must keep X and GTK background in sync. */
xg_pix_to_gcolor (wfixed, FRAME_BACKGROUND_PIXEL (f), &bg);
gtk_widget_modify_bg (wfixed, GTK_STATE_NORMAL, &bg);
xg_set_widget_bg (f, wfixed, FRAME_BACKGROUND_PIXEL (f));
#ifndef HAVE_GTK3
/* Also, do not let any background pixmap to be set, this looks very
bad as Emacs overwrites the background pixmap with its own idea
of background color. */
@ -1068,6 +1149,9 @@ xg_create_frame_widgets (FRAME_PTR f)
/* Must use g_strdup because gtk_widget_modify_style does g_free. */
style->bg_pixmap_name[GTK_STATE_NORMAL] = g_strdup ("<none>");
gtk_widget_modify_style (wfixed, style);
#else
gtk_widget_set_can_focus (wfixed, TRUE);
#endif
#ifdef USE_GTK_TOOLTIP
/* Steal a tool tip window we can move ourselves. */
@ -1224,11 +1308,8 @@ xg_set_background_color (FRAME_PTR f, long unsigned int bg)
{
if (FRAME_GTK_WIDGET (f))
{
GdkColor gdk_bg;
BLOCK_INPUT;
xg_pix_to_gcolor (FRAME_GTK_WIDGET (f), bg, &gdk_bg);
gtk_widget_modify_bg (FRAME_GTK_WIDGET (f), GTK_STATE_NORMAL, &gdk_bg);
xg_set_widget_bg (f, FRAME_GTK_WIDGET (f), FRAME_BACKGROUND_PIXEL (f));
UNBLOCK_INPUT;
}
}
@ -1240,11 +1321,10 @@ xg_set_background_color (FRAME_PTR f, long unsigned int bg)
void
xg_set_frame_icon (FRAME_PTR f, Pixmap icon_pixmap, Pixmap icon_mask)
{
GdkDisplay *gdpy = gdk_x11_lookup_xdisplay (FRAME_X_DISPLAY (f));
GdkPixmap *gpix = gdk_pixmap_foreign_new_for_display (gdpy, icon_pixmap);
GdkPixmap *gmask = gdk_pixmap_foreign_new_for_display (gdpy, icon_mask);
GdkPixbuf *gp = xg_get_pixbuf_from_pix_and_mask (gpix, gmask, NULL);
GdkPixbuf *gp = xg_get_pixbuf_from_pix_and_mask (f,
icon_pixmap,
icon_mask);
if (gp)
gtk_window_set_icon (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)), gp);
}
@ -1381,7 +1461,7 @@ create_dialog (widget_value *wv,
/* Try to make dialog look better. Must realize first so
the widget can calculate the size it needs. */
gtk_widget_realize (w);
gtk_widget_size_request (w, &req);
gtk_widget_get_preferred_size (w, NULL, &req);
gtk_box_set_spacing (wvbox, req.height);
if (item->value && strlen (item->value) > 0)
button_spacing = 2*req.width/strlen (item->value);
@ -3028,7 +3108,7 @@ menubar_map_cb (GtkWidget *w, gpointer user_data)
{
GtkRequisition req;
FRAME_PTR f = (FRAME_PTR) user_data;
gtk_widget_size_request (w, &req);
gtk_widget_get_preferred_size (w, NULL, &req);
if (FRAME_MENUBAR_HEIGHT (f) != req.height)
{
FRAME_MENUBAR_HEIGHT (f) = req.height;
@ -3059,7 +3139,7 @@ xg_update_frame_menubar (FRAME_PTR f)
g_signal_connect (x->menubar_widget, "map", G_CALLBACK (menubar_map_cb), f);
gtk_widget_show_all (x->menubar_widget);
gtk_widget_size_request (x->menubar_widget, &req);
gtk_widget_get_preferred_size (x->menubar_widget, NULL, &req);
/* If menu bar doesn't know its height yet, cheat a little so the frame
doesn't jump so much when resized later in menubar_map_cb. */
@ -3120,7 +3200,7 @@ xg_event_is_for_menubar (FRAME_PTR f, XEvent *event)
return 0;
gdpy = gdk_x11_lookup_xdisplay (FRAME_X_DISPLAY (f));
gw = gdk_xid_table_lookup_for_display (gdpy, event->xbutton.window);
gw = gdk_x11_window_lookup_for_display (gdpy, event->xbutton.window);
if (! gw) return 0;
gevent.any.window = gw;
gwdesc = gtk_get_event_widget (&gevent);
@ -3284,8 +3364,12 @@ xg_create_scroll_bar (FRAME_PTR f,
{
GtkWidget *wscroll;
GtkWidget *webox;
GtkObject *vadj;
int scroll_id;
#ifdef HAVE_GTK3
GtkAdjustment *vadj;
#else
GtkObject *vadj;
#endif
/* Page, step increment values are not so important here, they
will be corrected in x_set_toolkit_scroll_bar_thumb. */
@ -3295,7 +3379,9 @@ xg_create_scroll_bar (FRAME_PTR f,
wscroll = gtk_vscrollbar_new (GTK_ADJUSTMENT (vadj));
webox = gtk_event_box_new ();
gtk_widget_set_name (wscroll, scroll_bar_name);
#ifndef HAVE_GTK3
gtk_range_set_update_policy (GTK_RANGE (wscroll), GTK_UPDATE_CONTINUOUS);
#endif
g_object_set_data (G_OBJECT (wscroll), XG_FRAME_DATA, (gpointer)f);
scroll_id = xg_store_widget_in_map (wscroll);
@ -3793,8 +3879,8 @@ xg_tool_bar_detach_callback (GtkHandleBox *wbox,
{
GtkRequisition req, req2;
FRAME_X_OUTPUT (f)->toolbar_detached = 1;
gtk_widget_size_request (GTK_WIDGET (wbox), &req);
gtk_widget_size_request (w, &req2);
gtk_widget_get_preferred_size (GTK_WIDGET (wbox), NULL, &req);
gtk_widget_get_preferred_size (w, NULL, &req2);
req.width -= req2.width;
req.height -= req2.height;
if (FRAME_TOOLBAR_TOP_HEIGHT (f) != 0)
@ -3828,8 +3914,8 @@ xg_tool_bar_attach_callback (GtkHandleBox *wbox,
{
GtkRequisition req, req2;
FRAME_X_OUTPUT (f)->toolbar_detached = 0;
gtk_widget_size_request (GTK_WIDGET (wbox), &req);
gtk_widget_size_request (w, &req2);
gtk_widget_get_preferred_size (GTK_WIDGET (wbox), NULL, &req);
gtk_widget_get_preferred_size (w, NULL, &req2);
req.width += req2.width;
req.height += req2.height;
if (FRAME_TOOLBAR_TOP_HEIGHT (f) != 0)
@ -3894,6 +3980,7 @@ xg_tool_bar_help_callback (GtkWidget *w,
Returns FALSE to tell GTK to keep processing this event. */
#ifndef HAVE_GTK3
static gboolean
xg_tool_bar_item_expose_callback (GtkWidget *w,
GdkEventExpose *event,
@ -3902,7 +3989,6 @@ xg_tool_bar_item_expose_callback (GtkWidget *w,
gint width, height;
gdk_drawable_get_size (event->window, &width, &height);
event->area.x -= width > event->area.width ? width-event->area.width : 0;
event->area.y -= height > event->area.height ? height-event->area.height : 0;
@ -3914,6 +4000,7 @@ xg_tool_bar_item_expose_callback (GtkWidget *w,
return FALSE;
}
#endif
#ifdef HAVE_GTK_ORIENTABLE_SET_ORIENTATION
#define toolbar_set_orientation(w, o) \
@ -4063,13 +4150,14 @@ xg_make_tool_item (FRAME_PTR f,
g_object_set_data (G_OBJECT (weventbox), XG_FRAME_DATA, (gpointer)f);
#ifndef HAVE_GTK3
/* Catch expose events to overcome an annoying redraw bug, see
comment for xg_tool_bar_item_expose_callback. */
g_signal_connect (G_OBJECT (ti),
"expose-event",
G_CALLBACK (xg_tool_bar_item_expose_callback),
0);
#endif
gtk_tool_item_set_homogeneous (ti, FALSE);
/* Callback to save modifyer mask (Shift/Control, etc). GTK makes
@ -4153,7 +4241,7 @@ xg_update_tool_bar_sizes (FRAME_PTR f)
GtkRequisition req;
int nl = 0, nr = 0, nt = 0, nb = 0;
gtk_widget_size_request (GTK_WIDGET (x->handlebox_widget), &req);
gtk_widget_get_preferred_size (GTK_WIDGET (x->handlebox_widget), NULL, &req);
if (x->toolbar_in_hbox)
{
int pos;
@ -4203,7 +4291,6 @@ update_frame_tool_bar (FRAME_PTR f)
GtkToolItem *ti;
GtkTextDirection dir;
int pack_tool_bar = x->handlebox_widget == NULL;
Lisp_Object style;
int text_image, horiz;
@ -4551,13 +4638,13 @@ xg_initialize (void)
/* Make dialogs close on C-g. Since file dialog inherits from
dialog, this works for them also. */
binding_set = gtk_binding_set_by_class (g_type_class_ref (GTK_TYPE_DIALOG));
gtk_binding_entry_add_signal (binding_set, GDK_g, GDK_CONTROL_MASK,
gtk_binding_entry_add_signal (binding_set, GDK_KEY_g, GDK_CONTROL_MASK,
"close", 0);
/* Make menus close on C-g. */
binding_set = gtk_binding_set_by_class (g_type_class_ref
(GTK_TYPE_MENU_SHELL));
gtk_binding_entry_add_signal (binding_set, GDK_g, GDK_CONTROL_MASK,
gtk_binding_entry_add_signal (binding_set, GDK_KEY_g, GDK_CONTROL_MASK,
"cancel", 0);
}

View File

@ -1390,7 +1390,7 @@ menu_position_func (GtkMenu *menu, gint *x, gint *y, gboolean *push_in, gpointer
/* Check if there is room for the menu. If not, adjust x/y so that
the menu is fully visible. */
gtk_widget_size_request (GTK_WIDGET (menu), &req);
gtk_widget_get_preferred_size (GTK_WIDGET (menu), NULL, &req);
if (data->x + req.width > disp_width)
*x -= data->x + req.width - disp_width;
if (data->y + req.height > disp_height)

View File

@ -41,6 +41,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include "process.h"
#include "keyboard.h"
#ifndef HAVE_GTK3
#define gdk_x11_set_sm_client_id(w) gdk_set_sm_client_id (w)
#endif
/* This is the event used when SAVE_SESSION_EVENT occurs. */
static struct input_event emacs_event;
@ -459,7 +463,7 @@ x_session_initialize (struct x_display_info *dpyinfo)
#ifdef USE_GTK
/* GTK creats a leader window by itself, but we need to tell
it about our client_id. */
gdk_set_sm_client_id (client_id);
gdk_x11_set_sm_client_id (client_id);
#else
create_client_leader_window (dpyinfo, client_id);
#endif

View File

@ -3021,6 +3021,17 @@ XTflash (struct frame *f)
/* Use Gdk routines to draw. This way, we won't draw over scroll bars
when the scroll bars and the edit widget share the same X window. */
GdkWindow *window = gtk_widget_get_window (FRAME_GTK_WIDGET (f));
#ifdef HAVE_GTK3
cairo_t *cr = gdk_cairo_create (window);
cairo_set_source_rgb (cr, 1, 1, 1);
cairo_set_operator (cr, CAIRO_OPERATOR_DIFFERENCE);
#define XFillRectangle(d, win, gc, x, y, w, h) \
do { \
cairo_rectangle (cr, x, y, w, h); \
cairo_fill (cr); \
} \
while (0)
#else /* ! HAVE_GTK3 */
GdkGCValues vals;
GdkGC *gc;
vals.foreground.pixel = (FRAME_FOREGROUND_PIXEL (f)
@ -3030,7 +3041,8 @@ XTflash (struct frame *f)
&vals, GDK_GC_FUNCTION | GDK_GC_FOREGROUND);
#define XFillRectangle(d, win, gc, x, y, w, h) \
gdk_draw_rectangle (window, gc, TRUE, x, y, w, h)
#else
#endif /* ! HAVE_GTK3 */
#else /* ! USE_GTK */
GC gc;
/* Create a GC that will use the GXxor function to flip foreground
@ -3151,7 +3163,11 @@ XTflash (struct frame *f)
width, height - 2 * FRAME_INTERNAL_BORDER_WIDTH (f));
#ifdef USE_GTK
#ifdef HAVE_GTK3
cairo_destroy (cr);
#else
g_object_unref (G_OBJECT (gc));
#endif
#undef XFillRectangle
#else
XFreeGC (FRAME_X_DISPLAY (f), gc);
@ -9863,6 +9879,13 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
XSetLocaleModifiers ("");
/* Emacs can only handle core input events, so make sure
Gtk doesn't use Xinput or Xinput2 extensions. */
{
static char fix_events[] = "GDK_CORE_DEVICE_EVENTS=1";
putenv (fix_events);
}
/* Work around GLib bug that outputs a faulty warning. See
https://bugzilla.gnome.org/show_bug.cgi?id=563627. */
id = g_log_set_handler ("GLib", G_LOG_LEVEL_WARNING | G_LOG_FLAG_FATAL
@ -9874,11 +9897,12 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
fixup_locale ();
xg_initialize ();
dpy = GDK_DISPLAY ();
dpy = DEFAULT_GDK_DISPLAY ();
/* NULL window -> events for all windows go to our function */
gdk_window_add_filter (NULL, event_handler_gdk, NULL);
#if GTK_MAJOR_VERSION <= 2 && GTK_MINOR_VERSION <= 90
/* Load our own gtkrc if it exists. */
{
const char *file = "~/.emacs.d/gtkrc";
@ -9890,6 +9914,7 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
if (! NILP (abs_file) && !NILP (Ffile_readable_p (abs_file)))
gtk_rc_parse (SSDATA (abs_file));
}
#endif
XSetErrorHandler (x_error_handler);
XSetIOErrorHandler (x_io_error_quitter);

View File

@ -675,9 +675,20 @@ enum
#define gtk_adjustment_get_upper(w) ((w)->upper)
#endif
#ifdef HAVE_GTK3
#define DEFAULT_GDK_DISPLAY() \
gdk_x11_display_get_xdisplay (gdk_display_get_default ())
#else
#undef GDK_WINDOW_XID
#define GDK_WINDOW_XID(w) GDK_WINDOW_XWINDOW (w)
#define DEFAULT_GDK_DISPLAY() GDK_DISPLAY ()
#define gtk_widget_get_preferred_size(a, ign, b) \
gtk_widget_size_request(a, b)
#endif
#define GTK_WIDGET_TO_X_WIN(w) \
((w) && gtk_widget_get_window (w) \
? GDK_WINDOW_XWINDOW (gtk_widget_get_window (w)) : 0)
? GDK_WINDOW_XID (gtk_widget_get_window (w)) : 0)
#define FRAME_GTK_OUTER_WIDGET(f) ((f)->output_data.x->widget)
#define FRAME_GTK_WIDGET(f) ((f)->output_data.x->edit_widget)