/* this is piece by piece taken from gtk+ 2.9.0 (CVS-head with a patch applied regarding XShape's input-masks) so people without gtk+ >= 2.9.0 can compile and run input_shape_test.c */ static void do_shape_combine_mask (GdkWindow* window, GdkBitmap* mask, gint x, gint y) { Pixmap pixmap; int ignore; int maj; int min; if (!XShapeQueryExtension (GDK_WINDOW_XDISPLAY (window), &ignore, &ignore)) return; if (!XShapeQueryVersion (GDK_WINDOW_XDISPLAY (window), &maj, &min)) return; /* for shaped input we need at least XShape 1.1 */ if (maj != 1 && min < 1) return; if (mask) pixmap = GDK_DRAWABLE_XID (mask); else { x = 0; y = 0; pixmap = None; } XShapeCombineMask (GDK_WINDOW_XDISPLAY (window), GDK_DRAWABLE_XID (window), ShapeInput, x, y, pixmap, ShapeSet); }
gint gdk_selection_property_get(GdkWindow * requestor, guchar ** data, GdkAtom * ret_type, gint * ret_format) { GdkSelProp *prop; g_return_val_if_fail(requestor != NULL, 0); g_return_val_if_fail(GDK_IS_WINDOW(requestor), 0); if (GDK_DRAWABLE_DESTROYED(requestor)) return 0; GDK_NOTE(DND, g_print("gdk_selection_property_get: %#x", GDK_DRAWABLE_XID(requestor))); prop = g_hash_table_lookup(sel_prop_table, &GDK_DRAWABLE_XID(requestor)); if (prop == NULL) { GDK_NOTE(DND, g_print(": NULL\n")); *data = NULL; return 0; } GDK_NOTE(DND, g_print(": %d bytes\n", prop->length)); *data = g_malloc(prop->length); if (prop->length > 0) memmove(*data, prop->data, prop->length); if (ret_type) *ret_type = prop->type; if (ret_format) *ret_format = prop->format; return prop->length; }
gint gdk_selection_owner_set(GdkWindow * owner, GdkAtom selection, guint32 time, gint send_event) { gchar *sel_name; HWND xwindow; GDK_NOTE(DND, (sel_name = gdk_atom_name(selection), g_print("gdk_selection_owner_set: %#x %#x (%s)\n", (owner ? GDK_DRAWABLE_XID(owner) : 0), selection, sel_name), g_free(sel_name))); if (selection != gdk_clipboard_atom) return FALSE; if (owner != NULL) xwindow = GDK_DRAWABLE_XID(owner); else xwindow = NULL; GDK_NOTE(DND, g_print("...OpenClipboard(%#x)\n", xwindow)); if (!OpenClipboard(xwindow)) { WIN32_API_FAILED("OpenClipboard"); return FALSE; } GDK_NOTE(DND, g_print("...EmptyClipboard()\n")); if (!EmptyClipboard()) { WIN32_API_FAILED("EmptyClipboard"); CloseClipboard(); return FALSE; } #if 0 /* No delayed rendering */ if (xwindow != NULL) SetClipboardData(CF_TEXT, NULL); #endif GDK_NOTE(DND, g_print("...CloseClipboard()\n")); if (!CloseClipboard()) { WIN32_API_FAILED("CloseClipboard"); return FALSE; } if (owner != NULL) { /* Send ourselves an ersatz selection request message so that * gdk_property_change will be called to store the clipboard data. */ SendMessage(xwindow, gdk_selection_request_msg, selection, 0); } return TRUE; }
void gdk_selection_property_delete(GdkWindow * window) { GdkSelProp *prop; GDK_NOTE(DND, g_print("gdk_selection_property_delete: %#x", GDK_DRAWABLE_XID(window))); prop = g_hash_table_lookup(sel_prop_table, &GDK_DRAWABLE_XID(window)); if (prop != NULL) { g_free(prop->data); g_hash_table_remove(sel_prop_table, &GDK_DRAWABLE_XID(window)); } else g_warning("gdk_selection_property_delete: not found"); }
/* Does not require locking: meant to be called after the drawing surface is locked. */ Drawable classpath_jawt_get_drawable (JNIEnv* env, jobject canvas) { GtkWidget *widget; int drawable; void *ptr; jobject peer; jclass class_id; jmethodID method_id; class_id = (*env)->GetObjectClass (env, canvas); method_id = (*env)->GetMethodID (env, class_id, "getPeer", "()Ljava/awt/peer/ComponentPeer;"); peer = (*env)->CallObjectMethod (env, canvas, method_id); ptr = gtkpeer_get_widget (env, peer); widget = GTK_WIDGET (ptr); if (GTK_WIDGET_REALIZED (widget)) { drawable = GDK_DRAWABLE_XID (widget->window); return drawable; } else return (Drawable) NULL; }
// This code can only run after thumbnailer's drawing_area has been realized, // and after the main loop has run so that wnck_window is initialized. static void initialize_thumbnailer_pictures (SSThumbnailer *thumbnailer) { Display *display; GdkScreen *screen; XRenderPictFormat *format; XRenderPictureAttributes pa; display = gdk_x11_get_default_xdisplay (); screen = gtk_widget_get_screen (thumbnailer->drawing_area); format = XRenderFindVisualFormat (display, DefaultVisual ( display, gdk_screen_get_number (screen))); thumbnailer->thumbnail_pixmap = gdk_pixmap_new ( thumbnailer->drawing_area->window, THUMBNAIL_SIZE, THUMBNAIL_SIZE, -1); thumbnailer->thumbnail_picture = XRenderCreatePicture (display, GDK_DRAWABLE_XID (thumbnailer->thumbnail_pixmap), format, 0, NULL); pa.subwindow_mode = IncludeInferiors; thumbnailer->window_picture = XRenderCreatePicture (display, wnck_window_get_xid (thumbnailer->wnck_window), format, CPSubwindowMode, &pa); XRenderSetPictureFilter (display, thumbnailer->window_picture, "good", NULL, 0); }
/** * gdk_gl_window_new: * @glconfig: a #GdkGLConfig. * @window: the #GdkWindow to be used as the rendering area. * @attrib_list: (array) (allow-none): this must be set to NULL or empty (first attribute of None). * * Creates an on-screen rendering area. * attrib_list is currently unused. This must be set to NULL or empty * (first attribute of None). See GLX 1.3 spec. * * Return value: the new #GdkGLWindow. **/ GdkGLWindow * gdk_gl_window_new (GdkGLConfig *glconfig, GdkWindow *window, const int *attrib_list) { GDK_GL_NOTE_FUNC (); g_return_val_if_fail (GDK_IS_GL_CONFIG (glconfig), NULL); g_return_val_if_fail (GDK_IS_WINDOW (window), NULL); /* * Get X Window. */ Window glxwindow = GDK_DRAWABLE_XID (GDK_DRAWABLE (window)); /* * Instantiate the GdkGLWindowImplX11 object. */ GdkGLWindow *glwindow = g_object_new (GDK_TYPE_GL_WINDOW, NULL); glwindow->drawable = GDK_DRAWABLE (window); g_object_add_weak_pointer (G_OBJECT (glwindow->drawable), (gpointer *) &(glwindow->drawable)); glwindow->glxwindow = glxwindow; glwindow->glconfig = glconfig; g_object_ref (G_OBJECT (glwindow->glconfig)); glwindow->is_destroyed = FALSE; return glwindow; }
void gdk_draw_point (GdkDrawable *drawable, GdkGC *gc, gint x, gint y) { g_return_if_fail (drawable != NULL); g_return_if_fail (gc != NULL); gi_point_t tmp_points[1]; if (GDK_DRAWABLE_DESTROYED(drawable)) return; gi_gc_attch_window(GDK_GC_XGC(gc), GDK_DRAWABLE_XID(drawable)); //GrPoint (GDK_DRAWABLE_XID(drawable), GDK_GC_XGC(gc), x, y); tmp_points[0].x =x; tmp_points[0].y = y; gi_draw_points ( GDK_GC_XGC (gc), tmp_points, 1); }
void gdk_draw_rectangle (GdkDrawable *drawable, GdkGC *gc, gint filled, gint x, gint y, gint width, gint height) { g_return_if_fail (drawable != NULL); g_return_if_fail (gc != NULL); if (GDK_DRAWABLE_DESTROYED(drawable)) return; if (width == -1) width = ((GdkWindowPrivate*)drawable)->width; if (height == -1) height = ((GdkWindowPrivate*)drawable)->height; gi_gc_attch_window(GDK_GC_XGC(gc), GDK_DRAWABLE_XID(drawable)); if (filled){ gi_fill_rect( GDK_GC_XGC(gc), x, y, width, height); } else gi_draw_rect(GDK_GC_XGC(gc),x,y,width,height); //For some reason, nano-X draw wider and higher }
void gdk_draw_points (GdkDrawable *drawable, GdkGC *gc, GdkPoint *points, gint npoints) { gi_point_t *nanoPoints; guint i; g_return_if_fail (drawable != NULL); g_return_if_fail ((points != NULL) && (npoints > 0)); g_return_if_fail (gc != NULL); if (GDK_DRAWABLE_DESTROYED(drawable)) return; gi_gc_attch_window(GDK_GC_XGC(gc), GDK_DRAWABLE_XID(drawable)); nanoPoints = g_new(gi_point_t,npoints); // GdkPoint (gint16) to gi_point_t (int) for (i=0;i<npoints;i++) { nanoPoints[i].x = points[i].x; nanoPoints[i].y = points[i].y; } gi_draw_points(GDK_GC_XGC(gc), npoints, nanoPoints); g_free(nanoPoints); }
GdkWindow *gdk_selection_owner_get(GdkAtom selection) { GdkWindow *window; gchar *sel_name; #if 0 /* XXX Hmm, gtk selections seem to work best with this. This causes * gtk to always get the clipboard contents from Windows, and not * from the editable's own stashed-away copy. */ return NULL; #else if (selection != gdk_clipboard_atom) window = NULL; else { window = gdk_window_lookup(GetClipboardOwner()); if (window == NULL) window = (GdkWindow *)GetClipboardOwner(); } #endif GDK_NOTE(DND, (sel_name = gdk_atom_name(selection), g_print("gdk_selection_owner_get: %#x (%s) = %#x\n", selection, sel_name, (window ? GDK_DRAWABLE_XID(window) : 0)), g_free(sel_name))); return window; }
void gdk_draw_segments (GdkDrawable *drawable, GdkGC *gc, GdkSegment *segs, gint nsegs) { int i; gi_point_t pts[2]; PRINTFILE("gdk_draw_segments"); // not used by any exists widget if (nsegs <= 0) return; g_return_if_fail (drawable != NULL); g_return_if_fail (segs != NULL); g_return_if_fail (gc != NULL); if(GDK_DRAWABLE_DESTROYED(drawable)) return; gi_gc_attch_window(GDK_GC_XGC(gc), GDK_DRAWABLE_XID(drawable)); for (i = 0; i < nsegs; i++) { pts[0].x = segs[i].x1; pts[0].y = segs[i].y1; pts[1].x = segs[i].x2; pts[1].y = segs[i].y2; gi_draw_lines( GDK_GC_XGC (gc), pts,2); } }
static cairo_t * gdk_cairo_create (GdkDrawable *drawable) { int width, height; cairo_t *cr = NULL; cairo_surface_t *surface = NULL; GdkVisual *visual = gdk_drawable_get_visual (drawable); gdk_drawable_get_size (drawable, &width, &height); if (visual) surface = cairo_xlib_surface_create (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable), GDK_VISUAL_XVISUAL (visual), width, height); else if (gdk_drawable_get_depth (drawable) == 1) surface = cairo_xlib_surface_create_for_bitmap (GDK_PIXMAP_XDISPLAY (drawable), GDK_PIXMAP_XID (drawable), GDK_SCREEN_XSCREEN (gdk_drawable_get_screen (drawable)), width, height); else { g_warning ("Using Cairo rendering requires the drawable argument to\n" "have a specified colormap. All windows have a colormap,\n" "however, pixmaps only have colormap by default if they\n" "were created with a non-NULL window argument. Otherwise\n" "a colormap must be set on them with " "gdk_drawable_set_colormap"); return NULL; } if (surface) { cr = cairo_create (surface); cairo_surface_destroy (surface); } return cr; }
Drawable classpath_jawt_get_drawable (JNIEnv* env, jobject canvas) { GtkWidget *widget; int drawable; void *ptr; jobject peer; jclass class_id; jmethodID method_id; class_id = (*env)->GetObjectClass (env, canvas); method_id = (*env)->GetMethodID (env, class_id, "getPeer", "()Ljava/awt/peer/ComponentPeer;"); peer = (*env)->CallObjectMethod (env, canvas, method_id); ptr = NSA_GET_PTR (env, peer); gdk_threads_enter (); widget = GTK_WIDGET (ptr); g_assert (GTK_WIDGET_REALIZED (widget)); drawable = GDK_DRAWABLE_XID (widget->window); gdk_threads_leave (); return drawable; }
void gdk_draw_lines (GdkDrawable *drawable, GdkGC *gc, GdkPoint *points, gint npoints) { gi_point_t *nanoPoints; gint i; PRINTFILE("gdk_draw_lines"); // only used by gtkctree widget if (npoints <= 0) return; g_return_if_fail (drawable != NULL); g_return_if_fail (points != NULL); g_return_if_fail (gc != NULL); if(GDK_DRAWABLE_DESTROYED(drawable)) return; gi_gc_attch_window(GDK_GC_XGC(gc), GDK_DRAWABLE_XID(drawable)); nanoPoints = g_new(gi_point_t,npoints); for (i=0;i<npoints;i++) { nanoPoints[i].x = points[i].x; nanoPoints[i].y = points[i].y; } gi_draw_lines( GDK_GC_XGC(gc), npoints, nanoPoints); g_free(nanoPoints); }
/* gdk_draw_text * * Modified by Li-Da Lho to draw 16 bits and Multibyte strings * * Interface changed: add "GdkFont *font" to specify font or fontset explicitely */ void gdk_draw_text (GdkDrawable *drawable, GdkFont *font, GdkGC *gc, gint x, gint y, const gchar *text, gint text_length) { GR_FONT_INFO fid; g_return_if_fail (drawable != NULL); g_return_if_fail (font != NULL); g_return_if_fail (gc != NULL); g_return_if_fail (text!= NULL); gi_gc_attch_window(GDK_GC_XGC(gc), GDK_DRAWABLE_XID(drawable)); //printf("fontid is %d at %d\n", ((GdkFontPrivate*)font)->fid, GDK_GC_XGC(gc)); //GrGetFontInfo(((GdkFontPrivate*)font)->fid, &fid); //GrSetGCUseBackground(GDK_GC_XGC(gc), FALSE); int r,g,b; gi_pixel_to_color(&gdk_screen_info,GDK_GC_XGC(gc)->values.foreground,&r, &g,&b); gi_ufont_set_text_attr(GDK_GC_XGC(gc),GDK_FONT_XFONT(font),FALSE,GI_RGB(r,g,b),0); //dpp, fixme gi_ufont_draw(GDK_GC_XGC(gc),GDK_FONT_XFONT(font),text, x,y,text_length); //GrSetGCFont(GDK_GC_XGC(gc), ((GdkFontPrivate*)font)->fid); /* [00/08/30] @@@ NANOGTK: begin modification @@@ */ //GrText(GDK_DRAWABLE_XID(drawable), GDK_GC_XGC (gc), x, y, text, text_length); /* [00/08/30] @@@ NANOGTK: end modification @@@ */ }
void gdk_sel_prop_store(GdkWindow * owner, GdkAtom type, gint format, guchar * data, gint length) { GdkSelProp *prop; prop = g_hash_table_lookup(sel_prop_table, &GDK_DRAWABLE_XID(owner)); if (prop != NULL) { g_free(prop->data); g_hash_table_remove(sel_prop_table, &GDK_DRAWABLE_XID(owner)); } prop = g_new(GdkSelProp, 1); prop->data = data; prop->length = length; prop->format = format; prop->type = type; g_hash_table_insert(sel_prop_table, &GDK_DRAWABLE_XID(owner), prop); }
void gdk_draw_arc (GdkDrawable *drawable, GdkGC *gc, gint filled, gint x, gint y, gint width, gint height, gint angle1, gint angle2) { g_return_if_fail (drawable != NULL); g_return_if_fail (gc != NULL); PRINTFILE("gdk_draw_arc"); // only used by gtkctree widget if (GDK_DRAWABLE_DESTROYED(drawable)) return; gi_gc_attch_window(GDK_GC_XGC(gc), GDK_DRAWABLE_XID(drawable)); if (width == -1) width = ((GdkWindowPrivate*)drawable)->width; if (height == -1) height = ((GdkWindowPrivate*)drawable)->height; if (filled) { gi_fill_arc(GDK_DRAWABLE_XID(drawable),GDK_GC_XGC(gc), x, y, width, height, angle1, angle2); } else{ gi_draw_arc(GDK_DRAWABLE_XID(drawable),GDK_GC_XGC(gc), x, y, width, height, angle1, angle2); } //GrArcAngle(GDK_DRAWABLE_XID(drawable), GDK_GC_XGC(gc), x, y, // width, height, angle1, angle2, filled); }
void gdk_draw_text_wc (GdkDrawable *drawable, GdkFont *font, GdkGC *gc, gint x, gint y, const GdkWChar *text, gint text_length) { g_return_if_fail (drawable != NULL); g_return_if_fail (font != NULL); g_return_if_fail (gc != NULL); g_return_if_fail (text!= NULL); //GrSetGCUseBackground(GDK_GC_XGC(gc), FALSE); //fixme GDK_GC_XGC(gc)->values.font = GDK_FONT_XFONT(font); //GrSetGCFont(GDK_GC_XGC(gc), ((GdkFontPrivate*)font)->fid); /* [00/08/30] @@@ NANOGTK: begin modification @@@ */ //GrText (GDK_DRAWABLE_XID(drawable), GDK_GC_XGC (gc), // x, y, text, text_length, GR_TFUC32|GR_TFBASELINE); { gchar* mstr; GdkWChar* str; gint i; str = g_new(GdkWChar, text_length + 1); for (i = 0; i < text_length; i++) { str[i] = text[i]; } str[i] = 0; mstr = gdk_wcstombs(str); gi_gc_attch_window(GDK_GC_XGC(gc), GDK_DRAWABLE_XID(drawable)); //GrText (GDK_DRAWABLE_XID(drawable), GDK_GC_XGC (gc), // x, y, mstr, strlen(mstr)); int r,g,b; gi_pixel_to_color(&gdk_screen_info,GDK_GC_XGC(gc)->values.foreground,&r, &g,&b); gi_ufont_set_text_attr(GDK_GC_XGC(gc),GDK_FONT_XFONT(font),FALSE,GI_RGB(r,g,b),0); // gi_ufont_draw(GDK_GC_XGC(gc),GDK_FONT_XFONT(font),mstr, x,y,strlen(mstr)); g_free(str); g_free(mstr); } /* [00/08/30] @@@ NANOGTK: end modification @@@ */ }
static gboolean do_inhibit_for_window (GdkWindow *window) { GError *error; gboolean res; const char UNUSED_VARIABLE *startup_id; const char *app_id; const char *reason; guint toplevel_xid; guint flags; startup_id = g_getenv ("DESKTOP_AUTOSTART_ID"); #if 1 app_id = "caja-cd-burner"; reason = "A CD burn is in progress."; #else app_id = "caja"; reason = "A file transfer is in progress."; #endif #if GTK_CHECK_VERSION (3, 0, 0) toplevel_xid = gdk_x11_window_get_xid (window); #else toplevel_xid = GDK_DRAWABLE_XID (window); #endif flags = GSM_INHIBITOR_FLAG_LOGOUT | GSM_INHIBITOR_FLAG_SWITCH_USER | GSM_INHIBITOR_FLAG_SUSPEND; error = NULL; res = dbus_g_proxy_call (sm_proxy, "Inhibit", &error, G_TYPE_STRING, app_id, G_TYPE_UINT, toplevel_xid, G_TYPE_STRING, reason, G_TYPE_UINT, flags, G_TYPE_INVALID, G_TYPE_UINT, &cookie, G_TYPE_INVALID); if (! res) { g_warning ("Failed to inhibit: %s", error->message); g_error_free (error); return FALSE; } g_debug ("Inhibiting session manager: %u", cookie); return TRUE; }
/* * auto-close the points if the last point not equal to first point */ void gdk_draw_polygon (GdkDrawable *drawable, GdkGC *gc, gint filled, GdkPoint *points, gint npoints) { GdkWindowPrivate *drawable_private; GdkGCPrivate *gc_private; gi_point_t * nanoPoints; gint nano_npoints = npoints; int i; g_return_if_fail (drawable != NULL); g_return_if_fail (gc != NULL); drawable_private = (GdkWindowPrivate*) drawable; if (drawable_private->destroyed) return; gi_gc_attch_window(GDK_GC_XGC(gc), GDK_DRAWABLE_XID(drawable)); gc_private = (GdkGCPrivate*) gc; if (points[npoints-1].x != points[0].x || points[npoints-1].y != points[0].y) nano_npoints = npoints + 1; nanoPoints = g_new(gi_point_t, nano_npoints); // GdkPoint (gint16) to gi_point_t (int) for (i=0;i<npoints;i++) { nanoPoints[i].x = points[i].x; nanoPoints[i].y = points[i].y; } if (nano_npoints > npoints) { nanoPoints[npoints].x = points[0].x; nanoPoints[npoints].y = points[0].y; } if (filled) { gi_fill_polygon ( gc_private->xgc, nano_npoints, nanoPoints,GI_SHAPE_Complex, GI_POLY_CoordOrigin); } else { gi_draw_lines ( gc_private->xgc, nano_npoints, nanoPoints); } g_free(nanoPoints); }
void gdk_draw_line (GdkDrawable *drawable, GdkGC *gc, gint x1, gint y1, gint x2, gint y2) { g_return_if_fail (drawable != NULL); g_return_if_fail (gc != NULL); if( GDK_DRAWABLE_DESTROYED(drawable)) return; gi_gc_attch_window(GDK_GC_XGC(gc), GDK_DRAWABLE_XID(drawable)); gi_draw_line(GDK_GC_XGC(gc),x1,y1,x2,y2); }
void GtkAggVaapiGlue::render() { VaapiGlobalContext * const gvactx = VaapiGlobalContext::get(); if (!gvactx) return; if (!_window_is_setup) return; if (!_vaapi_image.get() || !_vaapi_surface.get()) return; if (!_vaapi_image->unmap()) { printf("ERROR: failed to unmap VA-API image\n"); return; } VAStatus status; status = vaPutSurface(gvactx->display(), _vaapi_surface->get(), GDK_DRAWABLE_XID(_drawing_area->window), 0, 0, _vaapi_surface->width(), _vaapi_surface->height(), 0, 0, _window_width, _window_height, NULL, 0, VA_FRAME_PICTURE); if (!vaapi_check_status(status, "vaPutSurface() canvas")) return; Renderer_agg_base::RenderImages::const_iterator img, first_img, last_img; first_img = _agg_renderer->getFirstRenderImage(); last_img = _agg_renderer->getLastRenderImage(); if (first_img != last_img) { for (img = first_img; img != last_img; ++img) { boost::shared_ptr<VaapiSurface> surface = (*img)->surface(); VaapiRectangle src_rect; src_rect.x = (*img)->x(); src_rect.y = (*img)->y(); src_rect.width = (*img)->width(); src_rect.height = (*img)->height(); VaapiRectangle dst_rect; const float xscale = _window_width / (float)_vaapi_image_width; const float yscale = _window_height / (float)_vaapi_image_height; dst_rect.x = src_rect.x * xscale; dst_rect.y = src_rect.y * yscale; dst_rect.width = src_rect.width * xscale; dst_rect.height = src_rect.height * yscale; VaapiVideoWindow *videoWindow; videoWindow = getVideoWindow(surface, _drawing_area->window, dst_rect); if (!videoWindow) { log_debug(_("ERROR: failed to setup video window for surface 0x%08x."), surface->get()); continue; } videoWindow->moveResize(dst_rect); VaapiRectangle pic_rect(surface->width(), surface->height()); if (!surface->associateSubpicture(_vaapi_subpicture, src_rect, pic_rect)) { log_debug(_("ERROR: failed to associate subpicture to surface 0x%08x."), surface->get()); continue; } status = vaPutSurface(gvactx->display(), surface->get(), videoWindow->xid(), 0, 0, surface->width(), surface->height(), 0, 0, dst_rect.width, dst_rect.height, NULL, 0, VA_FRAME_PICTURE); if (!vaapi_check_status(status, "vaPutSurface() video")) continue; surface->deassociateSubpicture(_vaapi_subpicture); } for (img = first_img; img != last_img; ++img) { boost::shared_ptr<VaapiSurface> surface = (*img)->surface(); status = vaSyncSurface(gvactx->display(), surface->get()); if (!vaapi_check_status(status, "vaSyncSurface() video")) continue; } } }
MetaWindowMenu* meta_window_menu_new (MetaFrames *frames, MetaMenuOp ops, MetaMenuOp insensitive, Window client_xwindow, unsigned long active_workspace, int n_workspaces, MetaWindowMenuFunc func, gpointer data) { int i; MetaWindowMenu *menu; /* FIXME: Modifications to 'ops' should happen in meta_window_show_menu */ if (n_workspaces < 2) ops &= ~(META_MENU_OP_STICK | META_MENU_OP_UNSTICK | META_MENU_OP_WORKSPACES); else if (n_workspaces == 2) /* #151183: If we only have two workspaces, disable the menu listing them. */ ops &= ~(META_MENU_OP_WORKSPACES); menu = g_new (MetaWindowMenu, 1); menu->frames = frames; menu->client_xwindow = client_xwindow; menu->func = func; menu->data = data; menu->ops = ops; menu->insensitive = insensitive; menu->menu = gtk_menu_new (); gtk_menu_set_screen (GTK_MENU (menu->menu), gtk_widget_get_screen (GTK_WIDGET (frames))); for (i = 0; i < (int) G_N_ELEMENTS (menuitems); i++) { MenuItem menuitem = menuitems[i]; if (ops & menuitem.op || menuitem.op == 0) { GtkWidget *mi; MenuData *md; unsigned int key; MetaVirtualModifier mods; mi = menu_item_new (&menuitem, -1); /* Set the activeness of radiobuttons. */ switch (menuitem.op) { case META_MENU_OP_STICK: gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (mi), active_workspace == 0xFFFFFFFF); break; case META_MENU_OP_UNSTICK: gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (mi), active_workspace != 0xFFFFFFFF); break; default: break; } if (menuitem.type == MENU_ITEM_WORKSPACE_LIST) { if (ops & META_MENU_OP_WORKSPACES) { Display *display; Window xroot; GdkScreen *screen; GtkWidget *submenu; int j; MenuItem to_another_workspace = { 0, MENU_ITEM_NORMAL, NULL, FALSE, N_("Move to Another _Workspace") }; meta_verbose ("Creating %d-workspace menu current space %lu\n", n_workspaces, active_workspace); display = gdk_x11_drawable_get_xdisplay (GTK_WIDGET (frames)->window); screen = gdk_drawable_get_screen (GTK_WIDGET (frames)->window); xroot = GDK_DRAWABLE_XID (gdk_screen_get_root_window (screen)); submenu = gtk_menu_new (); g_assert (mi==NULL); mi = menu_item_new (&to_another_workspace, -1); gtk_menu_item_set_submenu (GTK_MENU_ITEM (mi), submenu); for (j = 0; j < n_workspaces; j++) { char *label; MenuData *md; unsigned int key; MetaVirtualModifier mods; MenuItem moveitem; GtkWidget *submi; meta_core_get_menu_accelerator (META_MENU_OP_WORKSPACES, j + 1, &key, &mods); label = get_workspace_name_with_accel (display, xroot, j); moveitem.type = MENU_ITEM_NORMAL; moveitem.op = META_MENU_OP_WORKSPACES; moveitem.label = label; submi = menu_item_new (&moveitem, j + 1); g_free (label); if ((active_workspace == (unsigned)j) && (ops & META_MENU_OP_UNSTICK)) gtk_widget_set_sensitive (submi, FALSE); md = g_new (MenuData, 1); md->menu = menu; md->op = META_MENU_OP_WORKSPACES; g_object_set_data (G_OBJECT (submi), "workspace", GINT_TO_POINTER (j)); gtk_signal_connect_full (GTK_OBJECT (submi), "activate", G_CALLBACK (activate_cb), NULL, md, g_free, FALSE, FALSE); gtk_menu_shell_append (GTK_MENU_SHELL (submenu), submi); gtk_widget_show (submi); } } else meta_verbose ("not creating workspace menu\n"); } else if (menuitem.type != MENU_ITEM_SEPARATOR) { meta_core_get_menu_accelerator (menuitems[i].op, -1, &key, &mods); if (insensitive & menuitem.op) gtk_widget_set_sensitive (mi, FALSE); md = g_new (MenuData, 1); md->menu = menu; md->op = menuitem.op; gtk_signal_connect_full (GTK_OBJECT (mi), "activate", G_CALLBACK (activate_cb), NULL, md, g_free, FALSE, FALSE); } if (mi) { gtk_menu_shell_append (GTK_MENU_SHELL (menu->menu), mi); gtk_widget_show (mi); } } } g_signal_connect (menu->menu, "selection_done", G_CALLBACK(menu_closed), menu); return menu; }
/** * gdk_gl_pixmap_new: * @glconfig: a #GdkGLConfig. * @pixmap: the #GdkPixmap to be used as the rendering area. * @attrib_list: this must be set to NULL or empty (first attribute of None). * * Creates an off-screen rendering area. * attrib_list is currently unused. This must be set to NULL or empty * (first attribute of None). See GLX 1.3 spec. * * Return value: the new #GdkGLPixmap. **/ GdkGLPixmap * gdk_gl_pixmap_new (GdkGLConfig *glconfig, GdkPixmap *pixmap, const int *attrib_list) { GdkGLPixmap *glpixmap; GdkGLPixmapImplX11 *impl; Display *xdisplay; XVisualInfo *xvinfo; Pixmap xpixmap; GLXPixmap glxpixmap; Window root_return; int x_return, y_return; unsigned int width_return, height_return; unsigned int border_width_return; unsigned int depth_return; GdkGL_GLX_MESA_pixmap_colormap *mesa_ext; GDK_GL_NOTE_FUNC (); g_return_val_if_fail (GDK_IS_GL_CONFIG_IMPL_X11 (glconfig), NULL); g_return_val_if_fail (GDK_IS_PIXMAP (pixmap), NULL); xdisplay = GDK_GL_CONFIG_XDISPLAY (glconfig); xvinfo = GDK_GL_CONFIG_XVINFO (glconfig); /* * Get X Pixmap. */ xpixmap = GDK_DRAWABLE_XID (GDK_DRAWABLE (pixmap)); /* * Check depth of the X pixmap. */ if (!XGetGeometry (xdisplay, xpixmap, &root_return, &x_return, &y_return, &width_return, &height_return, &border_width_return, &depth_return)) return NULL; if (depth_return != (unsigned int) xvinfo->depth) return NULL; /* * Create GLXPixmap. */ mesa_ext = gdk_gl_get_GLX_MESA_pixmap_colormap (glconfig); if (mesa_ext) { /* If GLX_MESA_pixmap_colormap is supported. */ GDK_GL_NOTE_FUNC_IMPL ("glXCreateGLXPixmapMESA"); glxpixmap = mesa_ext->glXCreateGLXPixmapMESA (xdisplay, xvinfo, xpixmap, GDK_GL_CONFIG_XCOLORMAP (glconfig)); } else { GDK_GL_NOTE_FUNC_IMPL ("glXCreateGLXPixmap"); glxpixmap = glXCreateGLXPixmap (xdisplay, xvinfo, xpixmap); } if (glxpixmap == None) return NULL; /* * Instantiate the GdkGLPixmapImplX11 object. */ glpixmap = g_object_new (GDK_TYPE_GL_PIXMAP_IMPL_X11, NULL); impl = GDK_GL_PIXMAP_IMPL_X11 (glpixmap); glpixmap->drawable = GDK_DRAWABLE (pixmap); g_object_add_weak_pointer (G_OBJECT (glpixmap->drawable), (gpointer *) &(glpixmap->drawable)); impl->glxpixmap = glxpixmap; impl->glconfig = glconfig; g_object_ref (G_OBJECT (impl->glconfig)); impl->is_destroyed = FALSE; return glpixmap; }
static GdkPixmap * create_text_pixmap(GtkWidget *drawing_area, FT_Face face) { gint i, pixmap_width, pixmap_height, pos_y, textlen; GdkPixmap *pixmap = NULL; const gchar *text; Display *xdisplay; Drawable xdrawable; Visual *xvisual; Colormap xcolormap; XftDraw *draw; XftColor colour; XGlyphInfo extents; XftFont *font; gint *sizes = NULL, n_sizes, alpha_size; FcCharSet *charset = NULL; cairo_t *cr; GdkWindow *window = gtk_widget_get_window (drawing_area); text = pango_language_get_sample_string(NULL); if (! check_font_contain_text (face, text)) { pango_language_get_sample_string (pango_language_from_string ("en_US")); } textlen = strlen(text); /* create the XftDraw */ xdisplay = GDK_PIXMAP_XDISPLAY(window); #if GTK_CHECK_VERSION(3, 0, 0) xvisual = GDK_VISUAL_XVISUAL(gdk_window_get_visual(window)); #else xvisual = GDK_VISUAL_XVISUAL(gdk_drawable_get_visual(window)); #endif xcolormap = GDK_COLORMAP_XCOLORMAP(gdk_drawable_get_colormap(window)); XftColorAllocName(xdisplay, xvisual, xcolormap, "black", &colour); /* work out what sizes to render */ if (FT_IS_SCALABLE(face)) { n_sizes = 8; sizes = g_new(gint, n_sizes); sizes[0] = 8; sizes[1] = 10; sizes[2] = 12; sizes[3] = 18; sizes[4] = 24; sizes[5] = 36; sizes[6] = 48; sizes[7] = 72; alpha_size = 24; } else { /* use fixed sizes */ n_sizes = face->num_fixed_sizes; sizes = g_new(gint, n_sizes); alpha_size = 0; for (i = 0; i < face->num_fixed_sizes; i++) { sizes[i] = face->available_sizes[i].height; /* work out which font size to render */ if (face->available_sizes[i].height <= 24) alpha_size = face->available_sizes[i].height; } } /* calculate size of pixmap to use (with 4 pixels padding) ... */ pixmap_width = 8; pixmap_height = 8; font = get_font(xdisplay, face, alpha_size, charset); charset = FcCharSetCopy (font->charset); XftTextExtentsUtf8(xdisplay, font, (guchar *)lowercase_text, strlen(lowercase_text), &extents); pixmap_height += extents.height + 4; pixmap_width = MAX(pixmap_width, 8 + extents.width); XftTextExtentsUtf8(xdisplay, font, (guchar *)uppercase_text, strlen(uppercase_text), &extents); pixmap_height += extents.height + 4; pixmap_width = MAX(pixmap_width, 8 + extents.width); XftTextExtentsUtf8(xdisplay, font, (guchar *)punctuation_text, strlen(punctuation_text), &extents); pixmap_height += extents.height + 4; pixmap_width = MAX(pixmap_width, 8 + extents.width); XftFontClose(xdisplay, font); pixmap_height += 8; for (i = 0; i < n_sizes; i++) { font = get_font(xdisplay, face, sizes[i], charset); if (!font) continue; XftTextExtentsUtf8(xdisplay, font, (guchar *)text, textlen, &extents); pixmap_height += extents.height + 4; pixmap_width = MAX(pixmap_width, 8 + extents.width); XftFontClose(xdisplay, font); } /* create pixmap */ gtk_widget_set_size_request(drawing_area, pixmap_width, pixmap_height); pixmap = gdk_pixmap_new(window, pixmap_width, pixmap_height, -1); if (!pixmap) goto end; cr = gdk_cairo_create (pixmap); cairo_set_source_rgb (cr, 1, 1, 1); cairo_paint (cr); cairo_destroy (cr); xdrawable = GDK_DRAWABLE_XID(pixmap); draw = XftDrawCreate(xdisplay, xdrawable, xvisual, xcolormap); /* draw text */ pos_y = 4; font = get_font(xdisplay, face, alpha_size, charset); draw_string(xdisplay, draw, font, &colour, lowercase_text, &pos_y); draw_string(xdisplay, draw, font, &colour, uppercase_text, &pos_y); draw_string(xdisplay, draw, font, &colour, punctuation_text, &pos_y); XftFontClose(xdisplay, font); pos_y += 8; for (i = 0; i < n_sizes; i++) { font = get_font(xdisplay, face, sizes[i], charset); if (!font) continue; draw_string(xdisplay, draw, font, &colour, text, &pos_y); XftFontClose(xdisplay, font); } g_signal_connect(drawing_area, "expose-event", G_CALLBACK(expose_event), pixmap); end: g_free(sizes); FcCharSetDestroy (charset); return pixmap; }
void my_gdk_draw_text(GdkDrawable *drawable, GdkFont *font, GdkGC *gc, gint x, gint y, const gchar *text, gint text_length) { #ifdef MOZ_WIDGET_GTK GdkWindowPrivate *drawable_private; GdkFontPrivate *font_private; GdkGCPrivate *gc_private; #endif /* MOZ_WIDGET_GTK */ g_return_if_fail (drawable != NULL); g_return_if_fail (font != NULL); g_return_if_fail (gc != NULL); g_return_if_fail (text != NULL); #ifdef MOZ_WIDGET_GTK drawable_private = (GdkWindowPrivate*) drawable; if (drawable_private->destroyed) return; gc_private = (GdkGCPrivate*) gc; font_private = (GdkFontPrivate*) font; #endif /* MOZ_WIDGET_GTK */ #ifdef MOZ_WIDGET_GTK2 if (GDK_IS_WINDOW(drawable) && GDK_WINDOW_OBJECT(drawable)->destroyed) return; #endif /* MOZ_WIDGET_GTK2 */ if (font->type == GDK_FONT_FONT) { #ifdef MOZ_WIDGET_GTK XFontStruct *xfont = (XFontStruct *) font_private->xfont; #endif /* MOZ_WIDGET_GTK */ #ifdef MOZ_WIDGET_GTK2 XFontStruct *xfont = (XFontStruct *) GDK_FONT_XFONT(font); #endif /* MOZ_WIDGET_GTK2 */ // gdk does this... we don't need it.. // XSetFont(drawable_private->xdisplay, gc_private->xgc, xfont->fid); // We clamp the sizes down to 32768 which is the maximum width of // a window. Even if a font was 1 pixel high and started at the // left, the maximum size of a draw request could only be 32k. if ((xfont->min_byte1 == 0) && (xfont->max_byte1 == 0)) { #ifdef MOZ_WIDGET_GTK XDrawString (drawable_private->xdisplay, drawable_private->xwindow, gc_private->xgc, x, y, text, MIN(text_length, 32768)); #endif /* MOZ_WIDGET_GTK */ #ifdef MOZ_WIDGET_GTK2 XDrawString (GDK_WINDOW_XDISPLAY(drawable), GDK_DRAWABLE_XID(drawable), GDK_GC_XGC(gc), x, y, text, MIN(text_length, 32768)); #endif /* MOZ_WIDGET_GTK2 */ } else { #ifdef MOZ_WIDGET_GTK XDrawString16 (drawable_private->xdisplay, drawable_private->xwindow, gc_private->xgc, x, y, (XChar2b *) text, MIN((text_length / 2), 32768)); #endif /* MOZ_WIDGET_GTK */ #ifdef MOZ_WIDGET_GTK2 XDrawString16 (GDK_WINDOW_XDISPLAY(drawable), GDK_DRAWABLE_XID(drawable), GDK_GC_XGC(gc), x, y, (XChar2b *) text, MIN((text_length / 2), 32768)); #endif /* MOZ_WIDGET_GTK2 */ } } else if (font->type == GDK_FONT_FONTSET) { #ifdef MOZ_WIDGET_GTK XFontSet fontset = (XFontSet) font_private->xfont; XmbDrawString (drawable_private->xdisplay, drawable_private->xwindow, fontset, gc_private->xgc, x, y, text, text_length); #endif /* MOZ_WIDGET_GTK */ #ifdef MOZ_WIDGET_GTK2 XFontSet fontset = (XFontSet) GDK_FONT_XFONT(font); XmbDrawString (GDK_WINDOW_XDISPLAY(drawable), GDK_DRAWABLE_XID(drawable), fontset, GDK_GC_XGC(gc), x, y, text, text_length); #endif /* MOZ_WIDGET_GTK2 */ } else g_error("undefined font type\n"); }
/* Code to find the active window in order to collect stats for social * application browsing. */ static void get_active_application_properties(HippoIdleMonitor *monitor, char **wm_class, char **title) { Display *xdisplay = GDK_DISPLAY_XDISPLAY(monitor->display); int n_screens = gdk_display_get_n_screens(monitor->display); Atom net_active_window_x = gdk_x11_get_xatom_by_name_for_display(monitor->display, "_NET_ACTIVE_WINDOW"); GdkAtom net_active_window_gdk = gdk_atom_intern("_NET_ACTIVE_WINDOW", FALSE); Window active_window = None; int i; Atom type; int format; unsigned long n_items; unsigned long bytes_after; guchar *data; if (wm_class) *wm_class = NULL; if (title) *title = NULL; /* Find the currently focused window by looking at the _NET_ACTIVE_WINDOW property * on all the screens of the display. */ for (i = 0; i < n_screens; i++) { GdkScreen *screen = gdk_display_get_screen(monitor->display, i); GdkWindow *root = gdk_screen_get_root_window(screen); if (!gdk_x11_screen_supports_net_wm_hint (screen, net_active_window_gdk)) continue; XGetWindowProperty (xdisplay, GDK_DRAWABLE_XID(root), net_active_window_x, 0, 1, False, XA_WINDOW, &type, &format, &n_items, &bytes_after, &data); if (type == XA_WINDOW) { active_window = *(Window *)data; XFree(data); break; } } /* Now that we have the active window, figure out the application name and WM class */ gdk_error_trap_push(); if (active_window && wm_class) { if (XGetWindowProperty (xdisplay, active_window, XA_WM_CLASS, 0, G_MAXLONG, False, XA_STRING, &type, &format, &n_items, &bytes_after, &data) == Success && type == XA_STRING) { if (format == 8) { char **list; int count; count = gdk_text_property_to_utf8_list_for_display(monitor->display, GDK_TARGET_STRING, 8, data, n_items, &list); if (count > 1) *wm_class = g_strdup(list[1]); if (list) g_strfreev(list); } XFree(data); } } if (active_window && title) { Atom utf8_string = gdk_x11_get_xatom_by_name_for_display(monitor->display, "UTF8_STRING"); if (XGetWindowProperty (xdisplay, active_window, gdk_x11_get_xatom_by_name_for_display(monitor->display, "_NET_WM_NAME"), 0, G_MAXLONG, False, utf8_string, &type, &format, &n_items, &bytes_after, &data) == Success && type == utf8_string) { if (format == 8 && g_utf8_validate((char *)data, -1, NULL)) { *title = g_strdup((char *)data); } XFree(data); } } if (active_window && title && *title == NULL) { if (XGetWindowProperty (xdisplay, active_window, XA_WM_NAME, 0, G_MAXLONG, False, AnyPropertyType, &type, &format, &n_items, &bytes_after, &data) == Success && type != None) { if (format == 8) { char **list; int count; count = gdk_text_property_to_utf8_list_for_display(monitor->display, gdk_x11_xatom_to_atom_for_display(monitor->display, type), 8, data, n_items, &list); if (count > 0) *title = g_strdup(list[0]); if (list) g_strfreev(list); } XFree(data); } } gdk_error_trap_pop(); }
static void setup_font_sample(GtkWidget* darea, Antialiasing antialiasing, Hinting hinting) { const char* string1 = "abcfgop AO "; const char* string2 = "abcfgop"; XftColor black, white; XRenderColor rendcolor; Display* xdisplay = gdk_x11_get_default_xdisplay(); #if GTK_CHECK_VERSION (3, 0, 0) Colormap xcolormap = DefaultColormap(xdisplay, 0); #else GdkColormap* colormap = gdk_rgb_get_colormap(); Colormap xcolormap = GDK_COLORMAP_XCOLORMAP(colormap); #endif #if GTK_CHECK_VERSION (3, 0, 0) GdkVisual* visual = gdk_visual_get_system (); #else GdkVisual* visual = gdk_colormap_get_visual(colormap); #endif Visual* xvisual = GDK_VISUAL_XVISUAL(visual); FcPattern* pattern; XftFont* font1; XftFont* font2; XGlyphInfo extents1 = { 0 }; XGlyphInfo extents2 = { 0 }; #if !GTK_CHECK_VERSION (3, 0, 0) GdkPixmap* pixmap; #endif XftDraw* draw; GdkPixbuf* tmp_pixbuf; GdkPixbuf* pixbuf; int width, height; int ascent, descent; pattern = FcPatternBuild (NULL, FC_FAMILY, FcTypeString, "Serif", FC_SLANT, FcTypeInteger, FC_SLANT_ROMAN, FC_SIZE, FcTypeDouble, 18., NULL); font1 = open_pattern (pattern, antialiasing, hinting); FcPatternDestroy (pattern); pattern = FcPatternBuild (NULL, FC_FAMILY, FcTypeString, "Serif", FC_SLANT, FcTypeInteger, FC_SLANT_ITALIC, FC_SIZE, FcTypeDouble, 20., NULL); font2 = open_pattern (pattern, antialiasing, hinting); FcPatternDestroy (pattern); ascent = 0; descent = 0; if (font1) { XftTextExtentsUtf8 (xdisplay, font1, (unsigned char*) string1, strlen (string1), &extents1); ascent = MAX (ascent, font1->ascent); descent = MAX (descent, font1->descent); } if (font2) { XftTextExtentsUtf8 (xdisplay, font2, (unsigned char*) string2, strlen (string2), &extents2); ascent = MAX (ascent, font2->ascent); descent = MAX (descent, font2->descent); } width = extents1.xOff + extents2.xOff + 4; height = ascent + descent + 2; #if !GTK_CHECK_VERSION (3, 0, 0) pixmap = gdk_pixmap_new (NULL, width, height, visual->depth); #endif #if GTK_CHECK_VERSION (3, 0, 0) draw = XftDrawCreate (xdisplay, GDK_WINDOW_XID (gdk_screen_get_root_window (gdk_screen_get_default ())), xvisual, xcolormap); #else draw = XftDrawCreate (xdisplay, GDK_DRAWABLE_XID (pixmap), xvisual, xcolormap); #endif rendcolor.red = 0; rendcolor.green = 0; rendcolor.blue = 0; rendcolor.alpha = 0xffff; XftColorAllocValue(xdisplay, xvisual, xcolormap, &rendcolor, &black); rendcolor.red = 0xffff; rendcolor.green = 0xffff; rendcolor.blue = 0xffff; rendcolor.alpha = 0xffff; XftColorAllocValue(xdisplay, xvisual, xcolormap, &rendcolor, &white); XftDrawRect(draw, &white, 0, 0, width, height); if (font1) { XftDrawStringUtf8(draw, &black, font1, 2, 2 + ascent, (unsigned char*) string1, strlen(string1)); } if (font2) { XftDrawStringUtf8(draw, &black, font2, 2 + extents1.xOff, 2 + ascent, (unsigned char*) string2, strlen(string2)); } XftDrawDestroy(draw); if (font1) { XftFontClose(xdisplay, font1); } if (font2) { XftFontClose(xdisplay, font2); } #if GTK_CHECK_VERSION (3, 0, 0) tmp_pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE,8, width, height); #else tmp_pixbuf = gdk_pixbuf_get_from_drawable(NULL, pixmap, colormap, 0, 0, 0, 0, width, height); #endif pixbuf = gdk_pixbuf_scale_simple(tmp_pixbuf, 1 * width, 1 * height, GDK_INTERP_TILES); #if !GTK_CHECK_VERSION (3, 0, 0) g_object_unref(pixmap); #endif g_object_unref(tmp_pixbuf); g_object_set_data_full(G_OBJECT(darea), "sample-pixbuf", pixbuf, (GDestroyNotify) g_object_unref); #if GTK_CHECK_VERSION (3, 0, 0) gtk_widget_set_size_request (GTK_WIDGET(darea), width + 2, height + 2); g_signal_connect(darea, "draw", G_CALLBACK(sample_draw), NULL); #else g_signal_connect(darea, "size_request", G_CALLBACK(sample_size_request), NULL); g_signal_connect(darea, "expose_event", G_CALLBACK(sample_expose), NULL); #endif }
/// Return GDK window XID XID xid() const { return GDK_DRAWABLE_XID(_window); }