Commit 0afb4571 authored by Jan D's avatar Jan D

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.
parent 25bbfb31
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.
......
......@@ -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'.])])
......
This diff is collapsed.
......@@ -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
......
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
......
......@@ -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
......
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
......@@ -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
......
This diff is collapsed.
......@@ -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)
......
......@@ -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
......
......@@ -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);
......
......@@ -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)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment