diff options
| author | Joakim Verona | 2011-07-01 09:26:06 +0200 |
|---|---|---|
| committer | Joakim Verona | 2011-07-01 09:26:06 +0200 |
| commit | 9f13671c09bfdc18336132c40a0cf5b715c8da86 (patch) | |
| tree | c79aa19a2d65fd7c307fe9d1350fb205a89db139 | |
| parent | 46ddfc9dd50ea017041f969cdf715cda1118a8d2 (diff) | |
| download | emacs-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.xwidget | 37 | ||||
| -rw-r--r-- | src/xwidget.c | 11 |
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 |
| 362 | http://www-archive.mozilla.org/unix/gtk-embedding.html | 362 | http://www-archive.mozilla.org/unix/gtk-embedding.html |
| 363 | seems to be severly bitrotted | 363 | seems to be severly bitrotted |
| 364 | |||
| 365 | ** TODO clipping of controllers | ||
| 366 | |||
| 367 | Emacs uses a big GTK window and does its own clipping against Emacs | ||
| 368 | windows inside this area. So, in order to layout gtk widgets in emacs | ||
| 369 | windows we must clip thim ourselves. | ||
| 370 | |||
| 371 | The 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 | |||
| 377 | the only weirdness was that one has to tell gtk the clip area has a | ||
| 378 | window in order to get clipping. This is weird because all gtkwidgets | ||
| 379 | are windows in a sense and a window is almost by definition also a | ||
| 380 | clipping area. | ||
| 381 | |||
| 382 | Anyway, in GTK3 the gtk_widget_set_has_window(GTK_WIDGET ( | ||
| 383 | xv->widgetwindow), TRUE); call is ignored. | ||
| 384 | |||
| 385 | The gtkeventbox which is documented to have its own window doesnt work | ||
| 386 | either. | ||
| 387 | |||
| 388 | http://www.lanedo.com/~carlos/gtk3-doc/chap-drawing-model.html | ||
| 389 | |||
| 390 | *** TODO subclass my own clipping widget | ||
| 391 | http://www.lanedo.com/~carlos/gtk3-doc/GtkWidget.html#gtk-widget-set-has-window | ||
| 392 | mentions that it has_window can only be called inside a widget | ||
| 393 | impementation. | ||
| 394 | |||
| 395 | *** TODO try scrolled window | ||
| 396 | clipping does in fact work with | ||
| 397 | gtk_scrolled_window_add_with_viewport (xv->widgetwindow, xv->widget); | ||
| 398 | !! | ||
| 399 | |||
| 400 | I 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; |