diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/emacsgtkfixed.c | 48 | ||||
-rw-r--r-- | src/xwidget.c | 31 | ||||
-rw-r--r-- | src/xwidget.h | 2 |
3 files changed, 70 insertions, 11 deletions
diff --git a/src/emacsgtkfixed.c b/src/emacsgtkfixed.c index 0b57e2cdf36..d07788f3193 100644 --- a/src/emacsgtkfixed.c +++ b/src/emacsgtkfixed.c @@ -27,7 +27,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include "lisp.h" #include "frame.h" #include "xterm.h" - +#include "xwidget.h" struct _EmacsFixedPrivate { struct frame *f; @@ -42,6 +42,49 @@ static void emacs_fixed_get_preferred_height (GtkWidget *widget, gint *natural); G_DEFINE_TYPE (EmacsFixed, emacs_fixed, GTK_TYPE_FIXED) + + +void aloc_callback(GtkWidget* child, GtkWidget* fixed){ + GtkAllocation child_allocation; + GtkRequisition child_requisition; + + //TODO + // if child is an xwidget, find its clipping area and modify allocation + + struct xwidget_view* xv = (struct xwidget_viev*) g_object_get_data (G_OBJECT (child), XG_XWIDGET_VIEW); + printf("aloc callback %d %s\n", xv, gtk_widget_get_name(child)); + if(xv){ + printf(" allocation modification for xw\n"); + gtk_widget_get_allocation(child, &child_allocation); + child_allocation.width = xv->clipx; + child_allocation.height = xv->clipy; + gtk_widget_size_allocate (child, &child_allocation); + } + +} + +static void emacs_fixed_gtk_widget_size_allocate (GtkWidget *widget, + GtkAllocation *allocation){ + //for xwidgets + printf(" emacs_fixed_gtk_widget_size_allocate\n"); + + //TODO 1st call base class method + EmacsFixedClass *klass; + GtkWidgetClass *parent_class; + klass = EMACS_FIXED_GET_CLASS (widget); + parent_class = g_type_class_peek_parent (klass); + parent_class->size_allocate (widget, allocation); + + + //then modify allocations + gtk_container_foreach (widget, + aloc_callback, + widget); + +} + + + static void emacs_fixed_class_init (EmacsFixedClass *klass) { @@ -53,6 +96,9 @@ emacs_fixed_class_init (EmacsFixedClass *klass) widget_class->get_preferred_width = emacs_fixed_get_preferred_width; widget_class->get_preferred_height = emacs_fixed_get_preferred_height; + + widget_class->size_allocate = emacs_fixed_gtk_widget_size_allocate; + g_type_class_add_private (klass, sizeof (EmacsFixedPrivate)); } diff --git a/src/xwidget.c b/src/xwidget.c index b612bc3b283..841e3ee2144 100644 --- a/src/xwidget.c +++ b/src/xwidget.c @@ -75,6 +75,7 @@ #ifdef HAVE_GTK3 //for gtk3; sockets and plugs #include <gtk/gtkx.h> +#include "emacsgtkfixed.h" #endif #include <librsvg/rsvg.h> @@ -129,8 +130,6 @@ Lisp_Object Qbutton, Qtoggle, Qslider, Qsocket, Qcairo, Qwebkit, extern Lisp_Object QCtype; extern Lisp_Object QCwidth, QCheight; -#define XG_XWIDGET "emacs_xwidget" -#define XG_XWIDGET_VIEW "emacs_xwidget_view" struct xwidget_view* xwidget_view_lookup(struct xwidget* xw, struct window *w); int @@ -555,7 +554,9 @@ xwidget_init_view ( //xv->widgetwindow = GTK_CONTAINER (gtk_fixed_new ()); //works well for clipping on gtk2 not gtk3 //xv->widgetwindow = GTK_CONTAINER (gtk_event_box_new ()); //doesnt help clipping gtk3 - xv->widgetwindow = GTK_CONTAINER (gtk_scrolled_window_new (NULL, NULL)); //doesnt help clipping gtk3 + //xv->widgetwindow = GTK_CONTAINER (gtk_scrolled_window_new (NULL, NULL)); //clips in gtk3 + xv->widgetwindow = GTK_CONTAINER (gtk_viewport_new (NULL, NULL)); //clips in gtk3 + gtk_widget_set_size_request (GTK_WIDGET (xv->widgetwindow), xww->width, xww->height); /* GtkAllocation a; */ @@ -573,21 +574,24 @@ xwidget_init_view ( //gtk_layout_set_size (GTK_LAYOUT (xw->widgetwindow), xw->width, xw->height); - //gtk_container_add (xv->widgetwindow, xv->widget); + gtk_container_add (xv->widgetwindow, xv->widget); - gtk_scrolled_window_add_with_viewport (xv->widgetwindow, xv->widget); - - gtk_widget_set_size_request (GTK_WIDGET (xv->widget), xww->width, xww->height); - gtk_fixed_put (GTK_FIXED (s->f->gwfixed), GTK_WIDGET (xv->widgetwindow), x, y); - xv->x = x; xv->y = y; - gtk_widget_show_all (GTK_WIDGET (xv->widgetwindow)); + //gtk_scrolled_window_add_with_viewport (xv->widgetwindow, xv->widget); // when using scrollw //store some xwidget data in the gtk widgets g_object_set_data (G_OBJECT (xv->widget), XG_FRAME_DATA, (gpointer) (s->f)); //the emacs frame g_object_set_data (G_OBJECT (xv->widget), XG_XWIDGET, (gpointer) (xww)); //the xwidget g_object_set_data (G_OBJECT (xv->widget), XG_XWIDGET_VIEW, (gpointer) (xv)); //the xwidget g_object_set_data (G_OBJECT (xv->widgetwindow), XG_XWIDGET, (gpointer) (xww)); //the xwidget + g_object_set_data (G_OBJECT (xv->widgetwindow), XG_XWIDGET_VIEW, (gpointer) (xv)); //the xwidget + + gtk_widget_set_size_request (GTK_WIDGET (xv->widget), xww->width, xww->height); + gtk_fixed_put (EMACS_FIXED (s->f->gwfixed), GTK_WIDGET (xv->widgetwindow), x, y); + xv->x = x; xv->y = y; + gtk_widget_show_all (GTK_WIDGET (xv->widgetwindow)); + + //this seems to enable xcomposition. later we need to paint ourselves somehow, //since the widget is no longer responsible for painting itself //if(xw->type!=3) //im having trouble with compositing and sockets. hmmm. @@ -701,6 +705,13 @@ x_draw_xwidget_glyph_string (struct glyph_string *s) gtk_widget_set_size_request (GTK_WIDGET (xv->widgetwindow), clipx, clipy); printf("reclip %d %d -> %d %d\n",xv->clipx, xv->clipy, clipx, clipy ); + + //allocation debugging. the correct values cant be expected to show upp immediately, but eventually they should get to be ok + // this is because we dont know when the container gets around to doing layout + GtkAllocation galloc; + gtk_widget_get_allocation(GTK_WIDGET (xv->widgetwindow), &galloc); + printf("allocation %d %d , %d %d\n", galloc.x,galloc.y,galloc.width,galloc.height); + xv->clipx = clipx; xv->clipy = clipy; } //a live xwidget paints itself. when using composition, that diff --git a/src/xwidget.h b/src/xwidget.h index d54d4e649d8..36e33c5dfbf 100644 --- a/src/xwidget.h +++ b/src/xwidget.h @@ -83,3 +83,5 @@ void xwidget_touch (struct xwidget_view *xw); void assert_valid_xwidget_id(int id,char *str); int lookup_xwidget (Lisp_Object spec); +#define XG_XWIDGET "emacs_xwidget" +#define XG_XWIDGET_VIEW "emacs_xwidget_view" |