aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoakim Verona2011-07-05 01:06:32 +0200
committerJoakim Verona2011-07-05 01:06:32 +0200
commita218ae21ecda33aea853063f7bdc50fe4290ddf6 (patch)
treee6f477f42ae8f96b481d12f59fd0fd447b15a447
parent303da42474c7a4a59b2e86dda88ec74509bcd91f (diff)
downloademacs-a218ae21ecda33aea853063f7bdc50fe4290ddf6.tar.gz
emacs-a218ae21ecda33aea853063f7bdc50fe4290ddf6.zip
work on clipleft. not fantastic yet
-rw-r--r--src/emacsgtkfixed.c5
-rw-r--r--src/xwidget.c38
-rw-r--r--src/xwidget.h2
3 files changed, 23 insertions, 22 deletions
diff --git a/src/emacsgtkfixed.c b/src/emacsgtkfixed.c
index 0eacd2eaa2d..e7d1690605c 100644
--- a/src/emacsgtkfixed.c
+++ b/src/emacsgtkfixed.c
@@ -56,11 +56,10 @@ void aloc_callback(GtkWidget* child, GtkWidget* fixed){
56 if(xv){ 56 if(xv){
57 printf(" allocation modification for xw\n"); 57 printf(" allocation modification for xw\n");
58 gtk_widget_get_allocation(child, &child_allocation); 58 gtk_widget_get_allocation(child, &child_allocation);
59 child_allocation.width = xv->clipx; 59 child_allocation.width = xv->clip_right;
60 child_allocation.height = xv->clipy - xv->cliptop; 60 child_allocation.height = xv->clip_bottom - xv->clip_top;
61 gtk_widget_size_allocate (child, &child_allocation); 61 gtk_widget_size_allocate (child, &child_allocation);
62 //TODO find a way to remove this feeble workaround 62 //TODO find a way to remove this feeble workaround
63 //gtk_adjustment_set_value (gtk_viewport_get_vadjustment(GTK_VIEWPORT(xv->widgetwindow)), 1.0*xv->cliptop);
64 } 63 }
65 64
66} 65}
diff --git a/src/xwidget.c b/src/xwidget.c
index 90c9f225c77..3b3b96399e9 100644
--- a/src/xwidget.c
+++ b/src/xwidget.c
@@ -200,7 +200,7 @@ xwidget_show_view (struct xwidget_view *xv)
200 //printf("xwidget %d shown\n",xw->id); 200 //printf("xwidget %d shown\n",xw->id);
201 xv->hidden = 0; 201 xv->hidden = 0;
202 gtk_widget_show(GTK_WIDGET(xv->widgetwindow)); 202 gtk_widget_show(GTK_WIDGET(xv->widgetwindow));
203 gtk_fixed_move (GTK_FIXED (xv->emacswindow), GTK_WIDGET (xv->widgetwindow), xv->x, xv->y + xv->cliptop); //TODO refactor 203 gtk_fixed_move (GTK_FIXED (xv->emacswindow), GTK_WIDGET (xv->widgetwindow), xv->x + xv->clip_left, xv->y + xv->clip_top); //TODO refactor
204} 204}
205 205
206 206
@@ -397,7 +397,7 @@ xwidget_osr_draw_callback (GtkWidget *widget, cairo_t *cr, gpointer data)
397 printf("xwidget_osr_draw_callback gtk3 xw.id:%d xw.type:%d window:%d vis:%d\n", 397 printf("xwidget_osr_draw_callback gtk3 xw.id:%d xw.type:%d window:%d vis:%d\n",
398 xw->id,xw->type, gtk_widget_get_window (widget), gtk_widget_get_visible (xw->widget_osr)); 398 xw->id,xw->type, gtk_widget_get_window (widget), gtk_widget_get_visible (xw->widget_osr));
399 399
400 cairo_rectangle(cr, 0,0, xv->clipx, xv->clipy);//xw->width, xw->height); 400 cairo_rectangle(cr, 0,0, xv->clip_right, xv->clip_bottom);//xw->width, xw->height);
401 cairo_clip(cr); 401 cairo_clip(cr);
402 402
403 gtk_widget_draw (xw->widget_osr, cr); 403 gtk_widget_draw (xw->widget_osr, cr);
@@ -627,7 +627,7 @@ x_draw_xwidget_glyph_string (struct glyph_string *s)
627 int height = s->height; 627 int height = s->height;
628 struct xwidget *xww = &xwidgets[s->xwidget_id]; 628 struct xwidget *xww = &xwidgets[s->xwidget_id];
629 struct xwidget_view *xv = xwidget_view_lookup(xww, (s->w)); 629 struct xwidget_view *xv = xwidget_view_lookup(xww, (s->w));
630 int clipx; int clipy; int cliptop; 630 int clip_right; int clip_bottom; int clip_top; int clip_left;
631 631
632 int x = s->x; 632 int x = s->x;
633 int y = s->y + (s->height / 2) - (xww->height / 2); 633 int y = s->y + (s->height / 2) - (xww->height / 2);
@@ -644,16 +644,15 @@ x_draw_xwidget_glyph_string (struct glyph_string *s)
644 } 644 }
645 645
646 //calculate clip width and height, which is used for all manner of onscreen xwidget views 646 //calculate clip width and height, which is used for all manner of onscreen xwidget views
647 clipx = min (xww->width, WINDOW_RIGHT_EDGE_X (s->w) - x - WINDOW_RIGHT_SCROLL_BAR_AREA_WIDTH(s->w) - WINDOW_RIGHT_FRINGE_WIDTH(s->w)); 647 clip_right = min (xww->width, WINDOW_RIGHT_EDGE_X (s->w) - x - WINDOW_RIGHT_SCROLL_BAR_AREA_WIDTH(s->w) - WINDOW_RIGHT_FRINGE_WIDTH(s->w));
648 clipy = min (xww->height, 648 clip_left = max (0, WINDOW_LEFT_EDGE_X (s->w) - x - WINDOW_LEFT_SCROLL_BAR_AREA_WIDTH(s->w) - WINDOW_LEFT_FRINGE_WIDTH(s->w));
649 WINDOW_BOTTOM_EDGE_Y (s->w) - WINDOW_MODE_LINE_HEIGHT (s->w) - y); 649
650 //TODO figure out how to clip the upper part of a widget 650 clip_bottom = min (xww->height, WINDOW_BOTTOM_EDGE_Y (s->w) - WINDOW_MODE_LINE_HEIGHT (s->w) - y);
651 cliptop = max(0, WINDOW_TOP_EDGE_Y(s->w) -y ); //how much to cut from the topside of an xwidget 651 clip_top = max(0, WINDOW_TOP_EDGE_Y(s->w) -y ); //how much to cut from the topside of an xwidget
652 printf("cliptop %d\n", cliptop);
653
654 652
655 moved = (xv->x != x) || ((xv->y + xv->cliptop)!= (y+cliptop)); 653 moved = (xv->x + xv->clip_left != x+clip_left)
656 if(moved) printf ("live xwidget moved: id:%d (%d,%d)->(%d,%d) y+cliptop:%d\n", xww->id, xv->x, xv->y, x, y, y + cliptop); 654 || ((xv->y + xv->clip_top)!= (y+clip_top));
655 if(moved) printf ("live xwidget moved: id:%d (%d,%d)->(%d,%d) y+clip_top:%d\n", xww->id, xv->x, xv->y, x, y, y + clip_top);
657 xv->x = x; 656 xv->x = x;
658 xv->y = y; 657 xv->y = y;
659 if (moved) //has it moved? 658 if (moved) //has it moved?
@@ -663,16 +662,19 @@ x_draw_xwidget_glyph_string (struct glyph_string *s)
663 //TODO should be possible to use xwidget_show_view here 662 //TODO should be possible to use xwidget_show_view here
664 gtk_fixed_move (GTK_FIXED (s->f->gwfixed), 663 gtk_fixed_move (GTK_FIXED (s->f->gwfixed),
665 GTK_WIDGET (xv->widgetwindow), 664 GTK_WIDGET (xv->widgetwindow),
666 x, y + cliptop); 665 x + clip_left, y + clip_top);
667 } 666 }
668 } 667 }
669 //clip the widget window if some parts happen to be outside drawable area 668 //clip the widget window if some parts happen to be outside drawable area
670 //an emacs window is not a gtk window, a gtk window covers the entire frame 669 //an emacs window is not a gtk window, a gtk window covers the entire frame
671 //cliping might have changed even if we havent actualy moved, we try figure out when we need to reclip for real 670 //cliping might have changed even if we havent actualy moved, we try figure out when we need to reclip for real
672 if((xv->clipx != clipx) || (xv->clipy != clipy)|| (xv->cliptop != cliptop)){ 671 if((xv->clip_right != clip_right)
673 gtk_widget_set_size_request (GTK_WIDGET (xv->widgetwindow), clipx, clipy + cliptop); 672 || (xv->clip_bottom != clip_bottom)
674 gtk_fixed_put(GTK_FIXED(xv->widgetwindow), xv->widget, 0, -cliptop); 673 || (xv->clip_top != clip_top)
675 printf("reclip %d %d -> %d %d cliptop:%d\n",xv->clipx, xv->clipy, clipx, clipy, cliptop ); 674 || (xv->clip_left != clip_left)){
675 gtk_widget_set_size_request (GTK_WIDGET (xv->widgetwindow), clip_right + clip_left, clip_bottom + clip_top);
676 gtk_fixed_put(GTK_FIXED(xv->widgetwindow), xv->widget, -clip_left, -clip_top);
677 printf("reclip %d %d -> %d %d clip_top:%d clip_left:%d\n",xv->clip_right, xv->clip_bottom, clip_right, clip_bottom, clip_top , clip_left);
676 678
677 //allocation debugging. the correct values cant be expected to show upp immediately, but eventually they should get to be ok 679 //allocation debugging. the correct values cant be expected to show upp immediately, but eventually they should get to be ok
678 // this is because we dont know when the container gets around to doing layout 680 // this is because we dont know when the container gets around to doing layout
@@ -680,7 +682,7 @@ x_draw_xwidget_glyph_string (struct glyph_string *s)
680 //gtk_widget_get_allocation(GTK_WIDGET (xv->widgetwindow), &galloc); 682 //gtk_widget_get_allocation(GTK_WIDGET (xv->widgetwindow), &galloc);
681 //printf("allocation %d %d , %d %d\n", galloc.x,galloc.y,galloc.width,galloc.height); 683 //printf("allocation %d %d , %d %d\n", galloc.x,galloc.y,galloc.width,galloc.height);
682 684
683 xv->clipx = clipx; xv->clipy = clipy; xv->cliptop = cliptop; 685 xv->clip_right = clip_right; xv->clip_bottom = clip_bottom; xv->clip_top = clip_top;xv->clip_left = clip_left;
684 } 686 }
685 //a live xwidget paints itself. when using composition, that 687 //a live xwidget paints itself. when using composition, that
686 //happens through the expose handler for the xwidget 688 //happens through the expose handler for the xwidget
diff --git a/src/xwidget.h b/src/xwidget.h
index 1abbd59afcb..d5077bb0623 100644
--- a/src/xwidget.h
+++ b/src/xwidget.h
@@ -45,7 +45,7 @@ struct xwidget_view{
45 GtkContainer* widgetwindow; 45 GtkContainer* widgetwindow;
46 GtkContainer* emacswindow; 46 GtkContainer* emacswindow;
47 int x; int y; 47 int x; int y;
48 int clipx; int clipy; int cliptop; 48 int clip_right; int clip_bottom; int clip_top; int clip_left;
49 struct window *w; 49 struct window *w;
50 50
51 long handler_id; 51 long handler_id;