aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoakim Verona2011-07-01 09:26:06 +0200
committerJoakim Verona2011-07-01 09:26:06 +0200
commit9f13671c09bfdc18336132c40a0cf5b715c8da86 (patch)
treec79aa19a2d65fd7c307fe9d1350fb205a89db139
parent46ddfc9dd50ea017041f969cdf715cda1118a8d2 (diff)
downloademacs-9f13671c09bfdc18336132c40a0cf5b715c8da86.tar.gz
emacs-9f13671c09bfdc18336132c40a0cf5b715c8da86.zip
gtk3 tests, tried clipping using a scrolled windew. this works but results in unwanted scrollbars.
-rw-r--r--README.xwidget37
-rw-r--r--src/xwidget.c11
2 files changed, 45 insertions, 3 deletions
diff --git a/README.xwidget b/README.xwidget
index 24b11286ca2..fd6c769866a 100644
--- a/README.xwidget
+++ b/README.xwidget
@@ -361,3 +361,40 @@ http://gtkplus-p3.0.sourcearchive.com/documentation/2.91.5-0ubuntu1/testoffscree
361*** firefox 361*** firefox
362http://www-archive.mozilla.org/unix/gtk-embedding.html 362http://www-archive.mozilla.org/unix/gtk-embedding.html
363seems to be severly bitrotted 363seems to be severly bitrotted
364
365** TODO clipping of controllers
366
367Emacs uses a big GTK window and does its own clipping against Emacs
368windows inside this area. So, in order to layout gtk widgets in emacs
369windows we must clip thim ourselves.
370
371The following method worked well for a long time:
372- make a gtk widget, say a button, xw
373- make a clipping area, of type gtkfixed(many types have been tested)
374- put the clip area in the main emacs gtk window
375- figure out clip area changes during emacs redisplay
376
377the only weirdness was that one has to tell gtk the clip area has a
378window in order to get clipping. This is weird because all gtkwidgets
379are windows in a sense and a window is almost by definition also a
380clipping area.
381
382Anyway, in GTK3 the gtk_widget_set_has_window(GTK_WIDGET (
383xv->widgetwindow), TRUE); call is ignored.
384
385The gtkeventbox which is documented to have its own window doesnt work
386either.
387
388http://www.lanedo.com/~carlos/gtk3-doc/chap-drawing-model.html
389
390*** TODO subclass my own clipping widget
391http://www.lanedo.com/~carlos/gtk3-doc/GtkWidget.html#gtk-widget-set-has-window
392mentions that it has_window can only be called inside a widget
393impementation.
394
395*** TODO try scrolled window
396clipping does in fact work with
397gtk_scrolled_window_add_with_viewport (xv->widgetwindow, xv->widget);
398!!
399
400I get unwanted scrollbars in the widget though.
diff --git a/src/xwidget.c b/src/xwidget.c
index ea880458dc1..b612bc3b283 100644
--- a/src/xwidget.c
+++ b/src/xwidget.c
@@ -553,14 +553,16 @@ xwidget_init_view (
553 //xw->widgetwindow = GTK_CONTAINER (gtk_layout_new (NULL, NULL)); 553 //xw->widgetwindow = GTK_CONTAINER (gtk_layout_new (NULL, NULL));
554 //xw->widgetwindow = GTK_CONTAINER (gtk_offscreen_window_new ()); 554 //xw->widgetwindow = GTK_CONTAINER (gtk_offscreen_window_new ());
555 555
556 xv->widgetwindow = GTK_CONTAINER (gtk_fixed_new ()); //works well for clipping on gtk2 not gtk3 556 //xv->widgetwindow = GTK_CONTAINER (gtk_fixed_new ()); //works well for clipping on gtk2 not gtk3
557 //xv->widgetwindow = GTK_CONTAINER (gtk_event_box_new ()); //doesnt help clipping gtk3 557 //xv->widgetwindow = GTK_CONTAINER (gtk_event_box_new ()); //doesnt help clipping gtk3
558 xv->widgetwindow = GTK_CONTAINER (gtk_scrolled_window_new (NULL, NULL)); //doesnt help clipping gtk3
559
558 gtk_widget_set_size_request (GTK_WIDGET (xv->widgetwindow), xww->width, xww->height); 560 gtk_widget_set_size_request (GTK_WIDGET (xv->widgetwindow), xww->width, xww->height);
559 /* GtkAllocation a; */ 561 /* GtkAllocation a; */
560 /* a.x=0; a.y=0; a.width=xww->width; a.height=xww->height; */ 562 /* a.x=0; a.y=0; a.width=xww->width; a.height=xww->height; */
561 /* gtk_widget_set_allocation (GTK_WIDGET (xv->widget), &a); */ 563 /* gtk_widget_set_allocation (GTK_WIDGET (xv->widget), &a); */
562 564
563 gtk_widget_set_has_window(GTK_WIDGET ( xv->widgetwindow), TRUE); 565 //gtk_widget_set_has_window(GTK_WIDGET ( xv->widgetwindow), TRUE);
564 //if gtk_fixed doesnt have a window it will surprisingly not honor 566 //if gtk_fixed doesnt have a window it will surprisingly not honor
565 //setsize so that children gets clipped later. the documentation is 567 //setsize so that children gets clipped later. the documentation is
566 //not consistent regarding if its legal to call this method. 568 //not consistent regarding if its legal to call this method.
@@ -571,7 +573,10 @@ xwidget_init_view (
571 573
572 574
573 //gtk_layout_set_size (GTK_LAYOUT (xw->widgetwindow), xw->width, xw->height); 575 //gtk_layout_set_size (GTK_LAYOUT (xw->widgetwindow), xw->width, xw->height);
574 gtk_container_add (xv->widgetwindow, xv->widget); 576 //gtk_container_add (xv->widgetwindow, xv->widget);
577
578 gtk_scrolled_window_add_with_viewport (xv->widgetwindow, xv->widget);
579
575 gtk_widget_set_size_request (GTK_WIDGET (xv->widget), xww->width, xww->height); 580 gtk_widget_set_size_request (GTK_WIDGET (xv->widget), xww->width, xww->height);
576 gtk_fixed_put (GTK_FIXED (s->f->gwfixed), GTK_WIDGET (xv->widgetwindow), x, y); 581 gtk_fixed_put (GTK_FIXED (s->f->gwfixed), GTK_WIDGET (xv->widgetwindow), x, y);
577 xv->x = x; xv->y = y; 582 xv->x = x; xv->y = y;