aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/xwidget.c75
1 files changed, 55 insertions, 20 deletions
diff --git a/src/xwidget.c b/src/xwidget.c
index 1ad74db1ced..cd32b3e9bd7 100644
--- a/src/xwidget.c
+++ b/src/xwidget.c
@@ -177,9 +177,8 @@ xwidget_show (struct xwidget *xw)
177{ 177{
178 //printf("xwidget %d shown\n",xw->id); 178 //printf("xwidget %d shown\n",xw->id);
179 xw->hidden = 0; 179 xw->hidden = 0;
180 //gtk_widget_show(GTK_WIDGET(xw->widgetwindow)); 180 gtk_widget_show(GTK_WIDGET(xw->widgetwindow));
181 gtk_fixed_move (GTK_FIXED (xw->emacswindow), GTK_WIDGET (xw->widgetwindow), 181 gtk_fixed_move (GTK_FIXED (xw->emacswindow), GTK_WIDGET (xw->widgetwindow), xw->x, xw->y);
182 xw->x, xw->y);
183} 182}
184 183
185 184
@@ -188,7 +187,8 @@ static gboolean
188xwidget_composite_draw_2(GtkWidget *widget, 187xwidget_composite_draw_2(GtkWidget *widget,
189 GdkEventExpose *event, 188 GdkEventExpose *event,
190 gpointer data, 189 gpointer data,
191 int x, int y) 190 int x, int y,
191 int phantom)
192{ 192{
193 FRAME_PTR f = (FRAME_PTR) g_object_get_data (G_OBJECT (widget), XG_FRAME_DATA); 193 FRAME_PTR f = (FRAME_PTR) g_object_get_data (G_OBJECT (widget), XG_FRAME_DATA);
194 struct xwidget* xw = (struct xwidget*) g_object_get_data (G_OBJECT (widget), XG_XWIDGET); 194 struct xwidget* xw = (struct xwidget*) g_object_get_data (G_OBJECT (widget), XG_XWIDGET);
@@ -197,18 +197,22 @@ xwidget_composite_draw_2(GtkWidget *widget,
197 GdkRegion *region; 197 GdkRegion *region;
198 GtkWidget *child; 198 GtkWidget *child;
199 cairo_t *cr; 199 cairo_t *cr;
200 printf("xwidget_composite_draw_2 at:%d %d\n", x,y);
200 /* get our child (in this case, the event box) */ 201 /* get our child (in this case, the event box) */
201 child = widget; //gtk_bin_get_child (GTK_BIN (widget)); 202 child = widget; //gtk_bin_get_child (GTK_BIN (widget));
202 /* create a cairo context to draw to the emacs window */ 203 /* create a cairo context to draw to the emacs window */
203 cr = gdk_cairo_create (gtk_widget_get_window (f->gwfixed));//GTK_WIDGET(xw->emacswindow));//xw->widgetwindow));//widget->window); 204 // cr = gdk_cairo_create (gtk_widget_get_window (f->gwfixed));//GTK_WIDGET(xw->emacswindow));//xw->widgetwindow));//widget->window);
205 cr = gdk_cairo_create (gtk_widget_get_window (phantom ? f->gwfixed : xw->widgetwindow));//GTK_WIDGET(xw->emacswindow));//));//widget->window);
204 /* the source data is the (composited) xwidget */ 206 /* the source data is the (composited) xwidget */
205 //cairo_move_to(cr, xw->x, xw->y); 207 //cairo_move_to(cr, xw->x, xw->y);
206 cairo_set_source_rgb(cr,1.0,0,0); 208 if(phantom){
207 cairo_rectangle(cr,x,y,xw->width,xw->height); 209 cairo_set_source_rgb(cr,1.0,0,0);
208 cairo_fill(cr); 210 cairo_rectangle(cr,x,y,xw->width,xw->height);
211 cairo_fill(cr);
212 }
209 gdk_cairo_set_source_pixmap (cr, child->window, 213 gdk_cairo_set_source_pixmap (cr, child->window,
210 x,//child->allocation.x, 214 phantom ? x : 0,//child->allocation.x,
211 y//child->allocation.y 215 phantom ? y : 0//child->allocation.y
212 ); 216 );
213 /* draw no more than our expose event intersects our child */ 217 /* draw no more than our expose event intersects our child */
214 /* region = gdk_region_rectangle (&child->allocation); 218 /* region = gdk_region_rectangle (&child->allocation);
@@ -217,8 +221,9 @@ xwidget_composite_draw_2(GtkWidget *widget,
217 cairo_clip (cr); */ 221 cairo_clip (cr); */
218 /* composite, with a 50% opacity */ 222 /* composite, with a 50% opacity */
219 cairo_set_operator (cr, CAIRO_OPERATOR_OVER); 223 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
220 //cairo_paint_with_alpha (cr, 0.5);//transparency); 224 //cairo_paint_with_alpha (cr, phantom ? 0.5 : 0);
221 cairo_paint(cr);//transparency); 225 cairo_paint_with_alpha (cr, 0.9);
226 //cairo_paint(cr);//transparency);
222 /* we're done */ 227 /* we're done */
223 cairo_destroy (cr); 228 cairo_destroy (cr);
224 return FALSE; 229 return FALSE;
@@ -234,10 +239,33 @@ xwidget_composite_draw(GtkWidget *widget,
234 xwidget_composite_draw_2(widget, 239 xwidget_composite_draw_2(widget,
235 event, 240 event,
236 data, 241 data,
237 xw->x, xw->y); 242 xw->x, xw->y, 0);
238 243 return FALSE;
239} 244}
240 245
246static gboolean
247xwidget_composite_draw_widgetwindow(GtkWidget *widget,
248 GdkEventExpose *event,
249 gpointer data)
250{
251 struct xwidget* xw = (struct xwidget*) g_object_get_data (G_OBJECT (widget), XG_XWIDGET);
252 cairo_t *cr;
253 cr = gdk_cairo_create (gtk_widget_get_window (widget));
254 cairo_set_source_rgb(cr,0,1.0,0);
255 cairo_rectangle(cr, 0,0, xw->width,xw->height);
256 cairo_fill(cr);
257 gdk_cairo_set_source_pixmap (cr, xw->widget->window,
258 0,0
259 );
260
261 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
262 cairo_paint_with_alpha (cr, 0.9);
263 //cairo_paint(cr);
264 cairo_destroy (cr);
265
266 return FALSE;
267}
268
241void 269void
242xwidget_init (struct xwidget *xw, struct glyph_string *s, int x, int y) 270xwidget_init (struct xwidget *xw, struct glyph_string *s, int x, int y)
243{ 271{
@@ -282,12 +310,15 @@ xwidget_init (struct xwidget *xw, struct glyph_string *s, int x, int y)
282 //store some xwidget data in the gtk widgets 310 //store some xwidget data in the gtk widgets
283 g_object_set_data (G_OBJECT (xw->widget), XG_FRAME_DATA, (gpointer) (s->f)); //the emacs frame 311 g_object_set_data (G_OBJECT (xw->widget), XG_FRAME_DATA, (gpointer) (s->f)); //the emacs frame
284 g_object_set_data (G_OBJECT (xw->widget), XG_XWIDGET, (gpointer) (xw)); //the xwidget 312 g_object_set_data (G_OBJECT (xw->widget), XG_XWIDGET, (gpointer) (xw)); //the xwidget
313 g_object_set_data (G_OBJECT (xw->widgetwindow), XG_XWIDGET, (gpointer) (xw)); //the xwidget
285 314
286 //this seems to enable xcomposition. later we need to paint ourselves somehow, 315 //this seems to enable xcomposition. later we need to paint ourselves somehow,
287 //since the widget is no longer responsible for painting itself 316 //since the widget is no longer responsible for painting itself
288 gdk_window_set_composited (xw->widget->window, TRUE); 317 gdk_window_set_composited (xw->widget->window, TRUE);
289 g_signal_connect(xw->widget, "expose-event", G_CALLBACK(xwidget_composite_draw), "exposed"); 318 //gdk_window_set_composited (xw->widgetwindow, TRUE);
290 g_signal_connect(xw->widget, "damage-event", G_CALLBACK(xwidget_composite_draw), "damaged"); 319 //g_signal_connect_after(xw->widget, "expose-event", G_CALLBACK(xwidget_composite_draw), "widget exposed");
320 g_signal_connect_after(xw->widgetwindow, "expose-event", G_CALLBACK(xwidget_composite_draw_widgetwindow), "widgetwindow exposed");
321 // g_signal_connect_after(xw->widget, "damage-event", G_CALLBACK(xwidget_composite_draw), "damaged");
291 322
292 //widgettype specific initialization only possible after realization 323 //widgettype specific initialization only possible after realization
293 switch (xw->type) 324 switch (xw->type)
@@ -309,7 +340,7 @@ xwidget_draw_phantom (struct xwidget *xw,
309 int x, int y, 340 int x, int y,
310 int clipx, int clipy, 341 int clipx, int clipy,
311 struct glyph_string *s, 342 struct glyph_string *s,
312 float transparency) 343 int phantom)
313{ 344{
314 //we cant always get real widgets, so here we try to fetch a snapshot of 345 //we cant always get real widgets, so here we try to fetch a snapshot of
315 //the real xwidget and paint that as a phantom image. if that fails, we 346 //the real xwidget and paint that as a phantom image. if that fails, we
@@ -358,7 +389,7 @@ xwidget_draw_phantom (struct xwidget *xw,
358 gdkgc, xw_snapshot, 0, 0, x, y, clipx, clipy); 389 gdkgc, xw_snapshot, 0, 0, x, y, clipx, clipy);
359#else 390#else
360 391
361 xwidget_composite_draw_2(xw->widget, NULL, NULL,x,y); 392 xwidget_composite_draw_2(xw->widget, NULL, NULL,x,y, phantom);
362#endif 393#endif
363 //////////////////////////////////////////////////////////////// 394 ////////////////////////////////////////////////////////////////
364 395
@@ -450,12 +481,14 @@ x_draw_xwidget_glyph_string (struct glyph_string *s)
450 481
451 //if we are using compositing, we are always responsible for drawing the widget on the screen 482 //if we are using compositing, we are always responsible for drawing the widget on the screen
452 //just reuse the phantom routine for now 483 //just reuse the phantom routine for now
453 xwidget_draw_phantom (xw, x, y, clipx, clipy, s, 1.0); 484 printf("draw live xwidget at:%d %d\n",x,y);
485 xwidget_draw_phantom (xw, x, y, clipx, clipy, s, 1);
454 } 486 }
455 else 487 else
456 { 488 {
457 //xwidget is hidden, hide it offscreen somewhere, still realized, so we may snapshot it 489 //xwidget is hidden, hide it offscreen somewhere, still realized, so we may snapshot it
458 //gtk_fixed_move(GTK_FIXED(s->f->gwfixed),GTK_WIDGET(xw->widgetwindow) ,10000,10000); 490 //gtk_fixed_move(GTK_FIXED(s->f->gwfixed),GTK_WIDGET(xw->widgetwindow) ,10000,10000);
491 //gtk_widget_hide(GTK_WIDGET(xw->widgetwindow));
459 } 492 }
460 //xw refers to the *live* instance of the xwidget 493 //xw refers to the *live* instance of the xwidget
461 xw->x = x; 494 xw->x = x;
@@ -466,7 +499,9 @@ x_draw_xwidget_glyph_string (struct glyph_string *s)
466 else 499 else
467 { 500 {
468 //ok, we are painting the xwidgets in non-selected window, so draw a phantom 501 //ok, we are painting the xwidgets in non-selected window, so draw a phantom
469 xwidget_draw_phantom (xw, x, y, clipx, clipy, s, 0.1); 502 printf("draw phantom xwidget at:%d %d\n",x,y);
503
504 xwidget_draw_phantom (xw, x, y, clipx, clipy, s, 1);
470 505
471 } 506 }
472 507