diff options
| author | Joakim Verona | 2010-09-15 11:49:07 +0200 |
|---|---|---|
| committer | Joakim Verona | 2010-09-15 11:49:07 +0200 |
| commit | 0699485f1c0f0fef9983e9f12e48036ddba5dc16 (patch) | |
| tree | 5c6195f4286d13c7e0ec405a99abaddda8438cff | |
| parent | ffce6496f1e23dbe524b8c3c0e3530cf610e1b08 (diff) | |
| download | emacs-0699485f1c0f0fef9983e9f12e48036ddba5dc16.tar.gz emacs-0699485f1c0f0fef9983e9f12e48036ddba5dc16.zip | |
this doesnt actually work at all, but it does do some interesting things with composition, and contains lots of random experimental code. so i commit now, remove junk, and continue
| -rw-r--r-- | src/xwidget.c | 66 |
1 files changed, 10 insertions, 56 deletions
diff --git a/src/xwidget.c b/src/xwidget.c index ea32ea841ab..acfe3450b2c 100644 --- a/src/xwidget.c +++ b/src/xwidget.c | |||
| @@ -94,7 +94,7 @@ extern Lisp_Object QCdata, QCtype; | |||
| 94 | extern Lisp_Object QCwidth, QCheight; | 94 | extern Lisp_Object QCwidth, QCheight; |
| 95 | 95 | ||
| 96 | 96 | ||
| 97 | 97 | #define XG_XWIDGET "emacs_xwidget" | |
| 98 | 98 | ||
| 99 | 99 | ||
| 100 | 100 | ||
| @@ -160,59 +160,12 @@ int i; | |||
| 160 | 160 | ||
| 161 | if(gdk_display_supports_composite(gdk_display_get_default ())){ | 161 | if(gdk_display_supports_composite(gdk_display_get_default ())){ |
| 162 | hasNamePixmap = 1; | 162 | hasNamePixmap = 1; |
| 163 | }else{ | 163 | }else{ |
| 164 | return 0; | 164 | return 0; |
| 165 | } | 165 | } |
| 166 | |||
| 167 | //redirect all toplevel windows to backing store. | ||
| 168 | //this should probably be optimized so only the gtk sockets we care for get redirected | ||
| 169 | //otoh, the wm might quite possibly already have requested backing store so the code is | ||
| 170 | //probably noop anyway | ||
| 171 | printf("enabling composition\n"); | ||
| 172 | for ( i = 0; i < ScreenCount( dpy ); i++ ) | ||
| 173 | XCompositeRedirectSubwindows( dpy, RootWindow( dpy, i ), | ||
| 174 | CompositeRedirectAutomatic ); | ||
| 175 | return 1; | 166 | return 1; |
| 176 | |||
| 177 | |||
| 178 | } | 167 | } |
| 179 | 168 | ||
| 180 | void | ||
| 181 | xwidget_setup_socket_composition(struct xwidget* xw) | ||
| 182 | { | ||
| 183 | //do this for every gtk_socket | ||
| 184 | //XCompositeRedirectWindow(); should probably replace the global backing request | ||
| 185 | //now residing in xwidget_has_composition() | ||
| 186 | |||
| 187 | int xid = gtk_socket_get_plug_window (GTK_SOCKET (xw->widget)); | ||
| 188 | Display* dpy = GDK_DISPLAY (); | ||
| 189 | XCompositeRedirectSubwindows( dpy, xid, | ||
| 190 | CompositeRedirectAutomatic ); | ||
| 191 | |||
| 192 | |||
| 193 | /* | ||
| 194 | XWindowAttributes attr; | ||
| 195 | XGetWindowAttributes( dpy, xid, &attr ); | ||
| 196 | |||
| 197 | XRenderPictFormat *format = XRenderFindVisualFormat( dpy, attr.visual ); | ||
| 198 | int hasAlpha = ( format->type == PictTypeDirect && format->direct.alphaMask ); | ||
| 199 | int x = attr.x; | ||
| 200 | int y = attr.y; | ||
| 201 | int width = attr.width; | ||
| 202 | int height = attr.height; | ||
| 203 | |||
| 204 | |||
| 205 | XRenderPictureAttributes pa; | ||
| 206 | pa.subwindow_mode = IncludeInferiors; // Don't clip child widgets | ||
| 207 | |||
| 208 | Picture picture = XRenderCreatePicture( dpy, xid, format, CPSubwindowMode, &pa ); | ||
| 209 | // p_xid = XCompositeNameWindowPixmap( GDK_DISPLAY (), GDK_WINDOW_XID(xid)) ; | ||
| 210 | |||
| 211 | //this is the actual drawing call that probably should be somewhere else: | ||
| 212 | XRenderComposite( dpy, hasAlpha ? PictOpOver : PictOpSrc, picture, None, | ||
| 213 | dest.x11RenderHandle(), 0, 0, 0, 0, destX, destY, width, height ); | ||
| 214 | */ | ||
| 215 | } | ||
| 216 | 169 | ||
| 217 | void | 170 | void |
| 218 | xwidget_end_composition(struct xwidget* w){ | 171 | xwidget_end_composition(struct xwidget* w){ |
| @@ -230,12 +183,13 @@ xwidget_show (struct xwidget *xw) | |||
| 230 | } | 183 | } |
| 231 | 184 | ||
| 232 | 185 | ||
| 186 | static gboolean | ||
| 233 | xwidget_composite_draw(GtkWidget *widget, | 187 | xwidget_composite_draw(GtkWidget *widget, |
| 234 | GdkEventExpose *event, | 188 | GdkEventExpose *event, |
| 235 | gpointer data) | 189 | gpointer data) |
| 236 | //struct xwidget *xw) | ||
| 237 | { | 190 | { |
| 238 | FRAME_PTR f = (FRAME_PTR) g_object_get_data (G_OBJECT (widget), XG_FRAME_DATA); | 191 | //FRAME_PTR f = (FRAME_PTR) g_object_get_data (G_OBJECT (widget), XG_FRAME_DATA); |
| 192 | struct xwidget* xw = (struct xwidget*) g_object_get_data (G_OBJECT (widget), XG_XWIDGET); | ||
| 239 | //////////////////////////////////////////////////////////////// | 193 | //////////////////////////////////////////////////////////////// |
| 240 | //Example 7. Composited windows | 194 | //Example 7. Composited windows |
| 241 | GdkRegion *region; | 195 | GdkRegion *region; |
| @@ -244,7 +198,7 @@ xwidget_composite_draw(GtkWidget *widget, | |||
| 244 | /* get our child (in this case, the event box) */ | 198 | /* get our child (in this case, the event box) */ |
| 245 | child = widget; //gtk_bin_get_child (GTK_BIN (widget)); | 199 | child = widget; //gtk_bin_get_child (GTK_BIN (widget)); |
| 246 | /* create a cairo context to draw to the window */ | 200 | /* create a cairo context to draw to the window */ |
| 247 | cr = gdk_cairo_create (gtk_widget_get_window(f->gwfixed));//xw->widgetwindow));//widget->window); | 201 | cr = gdk_cairo_create (gtk_widget_get_window(xw->widgetwindow));//widget->window); |
| 248 | /* the source data is the (composited) event box */ | 202 | /* the source data is the (composited) event box */ |
| 249 | gdk_cairo_set_source_pixmap (cr, child->window, | 203 | gdk_cairo_set_source_pixmap (cr, child->window, |
| 250 | child->allocation.x, | 204 | child->allocation.x, |
| @@ -303,9 +257,9 @@ xwidget_init (struct xwidget *xw, struct glyph_string *s, int x, int y) | |||
| 303 | y); | 257 | y); |
| 304 | gtk_widget_show_all (GTK_WIDGET (xw->widgetwindow)); | 258 | gtk_widget_show_all (GTK_WIDGET (xw->widgetwindow)); |
| 305 | 259 | ||
| 306 | //a bit inconsistent, but the rest of emacs stores stuff in the widgets, | 260 | //store some xwidget data in the gtk widgets |
| 307 | //like frame data. in my case it might as well reside in the xwidget struct i think | 261 | g_object_set_data (G_OBJECT (xw->widget), XG_FRAME_DATA, (gpointer) (s->f)); //the emacs frame |
| 308 | g_object_set_data (G_OBJECT (xw->widget), XG_FRAME_DATA, (gpointer) (s->f)); | 262 | g_object_set_data (G_OBJECT (xw->widget), XG_XWIDGET, (gpointer) (xw)); //the xwidget |
| 309 | 263 | ||
| 310 | //this seems to enable xcomposition. later we need to paint ourselves somehow, | 264 | //this seems to enable xcomposition. later we need to paint ourselves somehow, |
| 311 | //since the widget is no longer responsible for painting itself | 265 | //since the widget is no longer responsible for painting itself |