summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.xwidget79
-rw-r--r--src/emacsgtkfixed.c48
-rw-r--r--src/xwidget.c31
-rw-r--r--src/xwidget.h2
4 files changed, 148 insertions, 12 deletions
diff --git a/README.xwidget b/README.xwidget
index fd6c769866a..1e584869592 100644
--- a/README.xwidget
+++ b/README.xwidget
@@ -357,11 +357,31 @@ crash in gtk_window_get_size instead. great.
http://gtkplus-p3.0.sourcearchive.com/documentation/2.91.5-0ubuntu1/testoffscreenwindow_8c-source.html
+after many atempts, the basic issue remains. for some reason the
+offscreen widget isnt ok when I want to snapshot it, so i simply get
+emptiness. the surface is only ok someimes.
+
+
+
+
+**** on-screen rendering to separate window
+an alternative might be to open a separate window and snapshot it. the
+idea is that whatever oddness webkit does so that offscreen rendering
+doesnt work, doesnt happen on-screen. the window could be opened
+somewhere not in the way.
*** firefox
http://www-archive.mozilla.org/unix/gtk-embedding.html
seems to be severly bitrotted
+heres a newer aproach
+http://hg.mozilla.org/incubator/embedding/file/29ac0fe51754/gtk/tests/test.cpp
+
+while webkit clearly has the best traction as an embeddee, the
+offscreen rendering issues makes it interesting to see what ff brings
+to the table.
+
+
** TODO clipping of controllers
Emacs uses a big GTK window and does its own clipping against Emacs
@@ -392,9 +412,66 @@ http://www.lanedo.com/~carlos/gtk3-doc/GtkWidget.html#gtk-widget-set-has-window
mentions that it has_window can only be called inside a widget
impementation.
-*** TODO try scrolled window
+*** DONE try scrolled window
+ CLOSED: [2011-07-01 Fri 10:56]
clipping does in fact work with
gtk_scrolled_window_add_with_viewport (xv->widgetwindow, xv->widget);
!!
I get unwanted scrollbars in the widget though.
+
+ gtk_scrolled_window_set_policy ( xv->widgetwindow,
+ GTK_POLICY_NEVER, GTK_POLICY_NEVER);
+
+stops clipping from working!
+
+
+*** DONE try viewport
+ CLOSED: [2011-07-01 Fri 10:56]
+gtkviewport is used in scrolled window so in order to remove
+scrollbars it should be possible to use viewport directly. however,
+viewport ignores size requests.
+
+
+*** TODO debug allocation
+the container determines how much size to allocate to child widgets.
+
+ 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);
+
+after my clipping attemp shows that my size request is ignored! this
+might be logical, since the container provided by emacs is a
+gtkfixed. gtkfixed might choose to heed the widgets size desires and
+allocate the entire widget size. but we want clipping!
+
+since i cant reasonably expect to change the emacs main container, i
+can maybe overide the setallocation method in gwfixed, and adjust
+allocation to clipping if its an xwidget asking for allocation.
+
+**** subclass gtkfixed
+possibly i need to subclass gtkfixed and override
+
+void gtk_widget_size_allocate (GtkWidget *widget,
+ GtkAllocation *allocation);
+
+http://developer.gnome.org/gobject/stable/howto-gobject.html
+
+turns out emacs already does this for gtk3 according to jan D:
+>>For GTK3, Emacs already subclasses GtkFixed, see emacsgtkfixed.[ch].
+
+- widgets may not be underallocated, aparently
+http://mail.gnome.org/archives/commits-list/2011-April/msg10950.html
+
+- how to call base class method/chain up
+http://developer.gnome.org/gobject/stable/howto-gobject-chainup.html
+
+- the allocation modification could happen in the container or the
+ child. it feels more apropiate in the container
+
+it is however unexpectedy inconvenient to modify allocation because
+the needed data is private to the base class. to overcome this:
+
+ - run base class method 1st.
+ - then, iterate all children, and modify allocation for xwidget
+ children only. x y will then be set.
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"