summaryrefslogtreecommitdiff
path: root/src/emacsgtkfixed.c
diff options
context:
space:
mode:
authorJoakim Verona <joakim@verona.se>2016-01-19 20:27:12 +0100
committerJoakim Verona <joakim@verona.se>2016-01-19 20:58:22 +0100
commit7c1f66a94bf236a427606ef537b4629a48a1665b (patch)
tree8661f512f7bcf35bfb1e7d915e5b6ef8df6229d8 /src/emacsgtkfixed.c
parent663d379bbc2fde5e9bded157365e9d48ea01c027 (diff)
downloademacs-7c1f66a94bf236a427606ef537b4629a48a1665b.tar.gz
Support for the new Xwidget feature.
* configure.ac: (HAVE_XWIDGETS, WIDGET_OBJ, EMACS_CONFIG_FEATURES): * xterm.c (x_draw_glyph_string, x_draw_bar_cursor): * xdisp.c: (handle_display_spec, handle_single_display_spec, push_it) (pop_it, set_iterator_to_next, dump_glyph) (calc_pixel_width_or_height, fill_xwidget_glyph_string) (BUILD_XWIDGET_GLYPH_STRING, BUILD_GLYPH_STRINGS) (produce_xwidget_glyph, x_produce_glyphs) (get_window_cursor_type): * window.c (Fdelete_window_internal): * termhooks.h (e): * print.c (print_object): * lisp.h (ptrdiff_t): * keyboard.c (kbd_buffer_get_event, make_lispy_event) (syms_of_keyboard): * emacs.c (main): * dispnew.c (update_window, scrolling_window): * dispextern.h (g, i): * Makefile.in (XWIDGETS_OBJ, WEBKIT_CFLAGS, WEBKIT_LIBS) (GIR_LIBS, ALL_CFLAGS, base_obj, LIBES): * keyboard.c (kbd_buffer_get_event): * emacsgtkfixed.c (emacs_fixed_gtk_widget_size_allocate) (emacs_fixed_class_init): Add case for an xwidget view. * xwidget.c, xwidget.h, xwidget.el: New files for xwidgets Co-authored-by: Grégoire Jadi <daimrod@gmail.com> Various improvements to the Xwidget feature. * xwidgets.c: * emacsgtkfixed.c: * xwidget.el:
Diffstat (limited to 'src/emacsgtkfixed.c')
-rw-r--r--src/emacsgtkfixed.c105
1 files changed, 87 insertions, 18 deletions
diff --git a/src/emacsgtkfixed.c b/src/emacsgtkfixed.c
index cdcaf803ba5..da1017df2ae 100644
--- a/src/emacsgtkfixed.c
+++ b/src/emacsgtkfixed.c
@@ -23,6 +23,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include "lisp.h"
#include "frame.h"
#include "xterm.h"
+#ifdef HAVE_XWIDGETS
+# include "xwidget.h"
+#endif
#include "emacsgtkfixed.h"
/* Silence a bogus diagnostic; see GNOME bug 683906. */
@@ -31,27 +34,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
# pragma GCC diagnostic ignored "-Wunused-local-typedefs"
#endif
-#define EMACS_TYPE_FIXED emacs_fixed_get_type ()
-#define EMACS_FIXED(obj) \
- G_TYPE_CHECK_INSTANCE_CAST (obj, EMACS_TYPE_FIXED, EmacsFixed)
-
typedef struct _EmacsFixed EmacsFixed;
typedef struct _EmacsFixedPrivate EmacsFixedPrivate;
typedef struct _EmacsFixedClass EmacsFixedClass;
-struct _EmacsFixed
-{
- GtkFixed container;
-
- /*< private >*/
- EmacsFixedPrivate *priv;
-};
-
-struct _EmacsFixedClass
-{
- GtkFixedClass parent_class;
-};
-
struct _EmacsFixedPrivate
{
struct frame *f;
@@ -64,9 +50,87 @@ static void emacs_fixed_get_preferred_width (GtkWidget *widget,
static void emacs_fixed_get_preferred_height (GtkWidget *widget,
gint *minimum,
gint *natural);
-static GType emacs_fixed_get_type (void);
G_DEFINE_TYPE (EmacsFixed, emacs_fixed, GTK_TYPE_FIXED)
+#ifdef HAVE_XWIDGETS
+
+struct GtkFixedPrivateL
+{
+ GList *children;
+};
+
+static void emacs_fixed_gtk_widget_size_allocate (GtkWidget *widget,
+ GtkAllocation *allocation)
+{
+ // For xwidgets.
+
+ // This basically re-implements the base class method and adds an
+ // additional case for an xwidget view.
+
+ // It would be nicer if the bse class method could be called first,
+ // and the the xview modification only would remain here. It wasn't
+ // possible to solve it that way yet.
+ EmacsFixedClass *klass;
+ GtkWidgetClass *parent_class;
+ struct GtkFixedPrivateL* priv;
+
+ klass = EMACS_FIXED_GET_CLASS (widget);
+ parent_class = g_type_class_peek_parent (klass);
+ parent_class->size_allocate (widget, allocation);
+
+ priv = G_TYPE_INSTANCE_GET_PRIVATE (widget,
+ GTK_TYPE_FIXED,
+ struct GtkFixedPrivateL);
+
+ gtk_widget_set_allocation (widget, allocation);
+
+ if (gtk_widget_get_has_window (widget))
+ {
+ if (gtk_widget_get_realized (widget))
+ gdk_window_move_resize (gtk_widget_get_window (widget),
+ allocation->x,
+ allocation->y,
+ allocation->width,
+ allocation->height);
+ }
+
+ for (GList *children = priv->children; children; children = children->next)
+ {
+ GtkFixedChild *child = children->data;
+
+ if (!gtk_widget_get_visible (child->widget))
+ continue;
+
+ GtkRequisition child_requisition;
+ gtk_widget_get_preferred_size (child->widget, &child_requisition, NULL);
+
+ GtkAllocation child_allocation;
+ child_allocation.x = child->x;
+ child_allocation.y = child->y;
+
+ if (!gtk_widget_get_has_window (widget))
+ {
+ child_allocation.x += allocation->x;
+ child_allocation.y += allocation->y;
+ }
+
+ child_allocation.width = child_requisition.width;
+ child_allocation.height = child_requisition.height;
+
+ struct xwidget_view *xv
+ = g_object_get_data (G_OBJECT (child->widget), XG_XWIDGET_VIEW);
+ if (xv)
+ {
+ child_allocation.width = xv->clip_right;
+ child_allocation.height = xv->clip_bottom - xv->clip_top;
+ }
+
+ gtk_widget_size_allocate (child->widget, &child_allocation);
+ }
+}
+
+#endif /* HAVE_XWIDGETS */
+
static void
emacs_fixed_class_init (EmacsFixedClass *klass)
{
@@ -74,11 +138,16 @@ emacs_fixed_class_init (EmacsFixedClass *klass)
widget_class = (GtkWidgetClass*) klass;
+
widget_class->get_preferred_width = emacs_fixed_get_preferred_width;
widget_class->get_preferred_height = emacs_fixed_get_preferred_height;
+#ifdef HAVE_XWIDGETS
+ widget_class->size_allocate = emacs_fixed_gtk_widget_size_allocate;
+#endif
g_type_class_add_private (klass, sizeof (EmacsFixedPrivate));
}
+
static void
emacs_fixed_init (EmacsFixed *fixed)
{