From c1a5b51f2bb636d87d2315a68a074da113d82177 Mon Sep 17 00:00:00 2001 From: Joakim Verona Date: Sat, 6 Apr 2013 00:41:37 +0200 Subject: [PATCH] some cleanups --- README.xwidget | 69 +++++++++++++++++++++++++++++++++++++++++--- lisp/xwidget-test.el | 7 +++++ src/xwidget.c | 58 ------------------------------------- 3 files changed, 72 insertions(+), 62 deletions(-) diff --git a/README.xwidget b/README.xwidget index 6ca6f1a62ca..e13834ba04c 100644 --- a/README.xwidget +++ b/README.xwidget @@ -404,7 +404,9 @@ Missing separate debuginfos, use: debuginfo-install hunspell-1.2.15-2.fc15.x86_6 CLOSED: [2011-07-19 Tue 14:26] now we just hard code sizes. but webkit widgets for instance can report sizes that suit the content. support that. -** TODO BUG xwidget view ghosts +** DONE BUG xwidget view ghosts + CLOSED: [2013-04-05 Fri 23:35] +(havent seen this in quite a while) - xwidget-webkit-browse-url somewhere - split window. now theres 2 webkit views @@ -929,7 +931,9 @@ http://developer.gnome.org/gdk/stable/gdk-Windows.html#GdkWindow-from-embedder turned out to be not so hard, captured events, copied them and forwarded them offscreen! -** TODO investigate gdk_window_redirect_to_drawable +** CANCELLED investigate gdk_window_redirect_to_drawable + CLOSED: [2013-04-05 Fri 23:37] +(cancelled this, the current approach seems okay) http://developer.gnome.org/gdk/stable/gdk-Windows.html#gdk-offscreen-window-set-embedder maybe could be used in place of my own copy hacks? to work it must support a chain of redirects, which seems unlikely. the benefit would @@ -1397,7 +1401,9 @@ isn't needed if emacs bg erase disabled might be some annoying local issues with my install because it is not reliably reproducible. (went away during merges) -** TODO low impact xwidget based image viewer +** CANCELLED low impact xwidget based image viewer + CLOSED: [2013-04-05 Fri 23:38] +(cancelled this because it no longer seems like a good idea) for instance to render SVG using webkit, or some other canvas. that way it would be possible to merge to trunk in stages. @@ -1558,7 +1564,6 @@ when an xwidget is removed from xwidget-alist, and there are no other references(mostly views) the xwidget should be garbage collected. special finalization would go into gc_sweep() -<<<<<<< TREE ** TODO embedding evince http://developer.gnome.org/libevview/3.2/libevview-ev-view.html would be useful for reading PDF:s and other document types. @@ -1623,3 +1628,59 @@ Current limitation: xwgir methods, emacs crashes. +** TODO investigate gdk_offscreen_window_set_embedder() +https://developer.gnome.org/gdk/unstable/gdk-Windows.html + +,---- +| Offscreen windows are more general than composited windows, since they +| allow not only to modify the rendering of the child window onto its +| parent, but also to apply coordinate transformations. +| +| To integrate an offscreen window into a window hierarchy, one has to +| call gdk_offscreen_window_set_embedder() and handle a number of +| signals. The "pick-embedded-child" signal on the embedder window is +| used to select an offscreen child at given coordinates, and the +| "to-embedder" and "from-embedder" signals on the offscreen window are +| used to translate coordinates between the embedder and the offscreen +| window. +| +| For rendering an offscreen window onto its embedder, the contents of +| the offscreen window are available as a pixmap, via +| gdk_offscreen_window_get_pixmap(). +`---- + +okay, [2013-04-03 Wed] I finally suceeded in this approach! +it was pretty hard to make it work and currently works like this: +- the on screen dravwing area is the embedder +- you must implement "pick child" +event forwarding is done automatically! + +BUT its not really super, because it only works well with a single +embedder. + +perhaps the strategy could be refined: +- the window frame would be the embedder for all xwidgets. (but what + about several frames then?) +- in the from-embedder signal handler, which maps container coords to + embedded widget coords, find out which xw-view i clicked on, and + compute the coords. + +[2013-04-04 Thu] I had a strategy working for a xwgir button but not +a webkit. set_embedded in the motion event handler for the xv. it +even works for 2 frames! but not webkit :( + +[2013-04-05 Fri] it works for xwgir osr components, but not for +webkit. Webkit retains the previous event forwarding system. + +Now it works like this: +- the offscreen widget is created as before +- the on-screen views also as before, painting and copying as before. +- gdk_offscreen_window_set_embedder() is now used to embedd the + offscreen widget in the onscreen one, upon view creation +- only one widget can embedd one other. This means that the embedding + widget must be switched between the onscreen ones. This is now done + in the mouse motion event handler. + +The above approach has been tested for xwgir created buttons and seems +to work. it doesnt work for webkit, so the old scheme is preserved +for webkit. diff --git a/lisp/xwidget-test.el b/lisp/xwidget-test.el index ba434f3d79a..6d4953c0ae0 100644 --- a/lisp/xwidget-test.el +++ b/lisp/xwidget-test.el @@ -98,6 +98,13 @@ (xwidget-insert (point-min) 'xwgirCheckButton "xwgir label didnt work..." 700 700) (define-key (current-local-map) [xwidget-event] 'xwidget-handler-demo-basic)) +(xwidget-demo "a-xwgir-slider" + (xwgir-require-namespace "Gtk" "3.0") + (put 'xwgirSlider :xwgir-class '("Gtk" "Slider")) + + (xwidget-insert (point-min) 'xwgirSlider "xwgir label didnt work..." 700 700) + (define-key (current-local-map) [xwidget-event] 'xwidget-handler-demo-basic)) + (xwidget-demo "a-xwgir-webkit" (xwgir-require-namespace "WebKit" "3.0") (put 'xwgirWebkit :xwgir-class '("WebKit" "WebView")) diff --git a/src/xwidget.c b/src/xwidget.c index c6714ad40a5..8a88a596163 100644 --- a/src/xwidget.c +++ b/src/xwidget.c @@ -238,11 +238,6 @@ DEFUN ("make-xwidget", Fmake_xwidget, Smake_xwidget, 7, 7, 0, xw->widget_osr = xwgir_create( SDATA(Fcar(Fcdr(Fget(xw->type, Qcxwgir_class)))), SDATA(Fcar(Fget(xw->type, Qcxwgir_class)))); - ///debug xwgir - /* gdk_offscreen_window_set_embedder ( gtk_widget_get_window (xw->widget_osr), */ - /* gtk_widget_get_window (GTK_WIDGET (xw->widgetwindow_osr)) */ - /* ); */ - /// gtk_widget_set_size_request (GTK_WIDGET (xw->widget_osr), xw->width, xw->height); gtk_container_add (xw->widgetwindow_osr, xw->widget_osr); @@ -254,9 +249,6 @@ DEFUN ("make-xwidget", Fmake_xwidget, Smake_xwidget, 7, 7, 0, /* signals */ g_signal_connect (G_OBJECT ( xw->widgetwindow_osr), "damage-event", G_CALLBACK (xwidget_osr_damage_event_callback), NULL); - //TODO these were just a test hack - /* g_signal_connect (G_OBJECT ( xw->widget_osr), "key-press-event", G_CALLBACK (webkit_osr_key_event_callback), NULL); */ - /* g_signal_connect (G_OBJECT ( xw->widget_osr), "key-release-event", G_CALLBACK (webkit_osr_key_event_callback), NULL); */ if (EQ(xw->type, Qwebkit_osr)){ g_signal_connect (G_OBJECT ( xw->widget_osr), @@ -303,56 +295,6 @@ DEFUN ("make-xwidget", Fmake_xwidget, Smake_xwidget, 7, 7, 0, } #endif - /* if (EQ(xw->type, Qsocket_osr)){ */ - /* printf("init socket osr\n"); */ - /* block_input(); */ - /* xw->widgetwindow_osr = GTK_CONTAINER (gtk_offscreen_window_new ()); */ - /* gtk_window_resize( GTK_WINDOW(xw->widgetwindow_osr), xw->width, xw->height); */ - - /* //////////////////// */ - /* //xw->widget_osr = webkit_web_view_new(); */ - /* xw->widget_osr = gtk_socket_new(); */ - /* //g_signal_connect_after(xv->widget, "plug-added", G_CALLBACK(xwidget_plug_added), "plug added"); */ - /* //g_signal_connect_after(xv->widget, "plug-removed", G_CALLBACK(xwidget_plug_removed), "plug removed"); */ - /* /////////////////// */ - - /* gtk_widget_set_size_request (GTK_WIDGET (xw->widget_osr), xw->width, xw->height); */ - /* gtk_container_add (xw->widgetwindow_osr, xw->widget_osr); */ - - /* gtk_widget_show_all (GTK_WIDGET (xw->widgetwindow_osr)); */ - - /* /\* store some xwidget data in the gtk widgets for convenient retrieval in the event handlers. *\/ */ - /* g_object_set_data (G_OBJECT (xw->widget_osr), XG_XWIDGET, (gpointer) (xw)); */ - /* g_object_set_data (G_OBJECT (xw->widgetwindow_osr), XG_XWIDGET, (gpointer) (xw)); */ - /* g_signal_connect (G_OBJECT ( xw->widgetwindow_osr), "damage-event", G_CALLBACK (xwidget_osr_damage_event_callback), NULL); */ - - /* //webkit_web_view_load_uri(WEBKIT_WEB_VIEW(xw->widget_osr), "http://www.fsf.org"); */ - /* unblock_input(); */ - - /* } */ - - - /* ////////////////////////////// */ - /* gtk_widget_set_size_request (GTK_WIDGET (xw->widget_osr), xw->width, xw->height); */ - /* gtk_container_add (xw->widgetwindow_osr, xw->widget_osr); */ - - /* gtk_widget_show_all (GTK_WIDGET (xw->widgetwindow_osr)); */ - - /* /\* store some xwidget data in the gtk widgets for convenient retrieval in the event handlers. *\/ */ - /* g_object_set_data (G_OBJECT (xw->widget_osr), XG_XWIDGET, (gpointer) (xw)); */ - /* g_object_set_data (G_OBJECT (xw->widgetwindow_osr), XG_XWIDGET, (gpointer) (xw)); */ - /* /\* signals *\/ */ - /* g_signal_connect (G_OBJECT ( xw->widgetwindow_osr), "damage-event", G_CALLBACK (xwidget_osr_damage_event_callback), NULL); */ - /* g_signal_connect (G_OBJECT ( xw->widget_osr), "button-press-event", G_CALLBACK (xwgir_event_callback), xw); */ - - - /* unblock_input(); */ - /* } */ - - //////////////////////////////////////////////////////// - - - UNGCPRO; return val; } -- 2.39.2