static cairo_surface_t *_cairo_dock_create_dialog_icon_surface (const gchar *cImageFilePath, Icon *pIcon, int iDesiredSize, int *iIconSize) { if (cImageFilePath == NULL) return NULL; if (iDesiredSize == 0) iDesiredSize = myDialogsParam.iDialogIconSize; cairo_surface_t *pIconBuffer = NULL; if (strcmp (cImageFilePath, "same icon") == 0) { if (pIcon && pIcon->image.pSurface) { int iWidth, iHeight; cairo_dock_get_icon_extent (pIcon, &iWidth, &iHeight); pIconBuffer = cairo_dock_duplicate_surface (pIcon->image.pSurface, iWidth, iHeight, iDesiredSize, iDesiredSize); } else if (pIcon && pIcon->cFileName) { pIconBuffer = cairo_dock_create_surface_from_image_simple (pIcon->cFileName, iDesiredSize, iDesiredSize); } } else { pIconBuffer = cairo_dock_create_surface_from_image_simple (cImageFilePath, iDesiredSize, iDesiredSize); } if (pIconBuffer != NULL) *iIconSize = iDesiredSize; return pIconBuffer; }
static cairo_surface_t *cairo_dock_duplicate_inhibator_surface_for_appli (cairo_t *pSourceContext, Icon *pInhibatorIcon, double fMaxScale, double *fWidth, double *fHeight) { double fIconWidthSaturationFactor, fIconHeightSaturationFactor; cairo_dock_calculate_size_fill (fWidth, fHeight, g_tIconAuthorizedWidth[CAIRO_DOCK_APPLI], g_tIconAuthorizedHeight[CAIRO_DOCK_APPLI], FALSE, &fIconWidthSaturationFactor, &fIconHeightSaturationFactor); CairoContainer *pInhibhatorContainer= cairo_dock_search_container_from_icon (pInhibatorIcon); double fInhibatorMaxScale = (CAIRO_DOCK_IS_DOCK (pInhibhatorContainer) ? (1 + g_fAmplitude) / CAIRO_DOCK (pInhibhatorContainer)->fRatio : 1); cairo_surface_t *pSurface = cairo_dock_duplicate_surface (pInhibatorIcon->pIconBuffer, pSourceContext, pInhibatorIcon->fWidth * fInhibatorMaxScale, pInhibatorIcon->fHeight * fInhibatorMaxScale, *fWidth * fMaxScale, *fHeight * fMaxScale); return pSurface; }
static gchar *_make_screenshot (gboolean bActiveWindow, const gchar *cFolder, const gchar *cFileName) { // create a surface that points on the root window. Display *display = gdk_x11_get_default_xdisplay (); Screen *screen = XDefaultScreenOfDisplay (display); Visual *visual = DefaultVisualOfScreen (screen); int w, h; Window Xid; if (bActiveWindow) { GldiWindowActor *pActiveWindow = gldi_windows_get_active (); Xid = gldi_window_get_id (pActiveWindow); // cairo_dock_get_active_xwindow () Window root_return; int x_return=1, y_return=1; unsigned int width_return, height_return, border_width_return, depth_return; XGetGeometry (display, Xid, &root_return, &x_return, &y_return, &width_return, &height_return, &border_width_return, &depth_return); // we can't use the data from the WindowActor, because it takes into account the window border. w = width_return; h = height_return; } else { Xid = DefaultRootWindow (display); w = g_desktopGeometry.Xscreen.width; h = g_desktopGeometry.Xscreen.height; } cairo_surface_t *s = cairo_xlib_surface_create (display, Xid, visual, w, h); gchar *cName = NULL; if (s) { // save the surface on the disk cName = _make_image_name (cFolder, cFileName); cairo_surface_write_to_png (s, cName); // apply the surface on the icon, with a transition. int iWidth, iHeight; CD_APPLET_GET_MY_ICON_EXTENT (&iWidth, &iHeight); cairo_dock_free_image_buffer (myData.pCurrentImage); myData.pCurrentImage = g_new0 (CairoDockImageBuffer, 1); double ratio = MIN ((double)iWidth / w, (double)iHeight / h); // keep ratio. int w0 = w * ratio; int h0 = h * ratio; cairo_surface_t *pSurface = cairo_dock_duplicate_surface (s, w, h, w0, h0); // we must duplicate the surface, because it's an Xlib surface, not a data surface (plus it's way too large anyway). cairo_dock_load_image_buffer_from_surface (myData.pCurrentImage, pSurface, w0, h0); cairo_dock_free_image_buffer (myData.pOldImage); myData.pOldImage = cairo_dock_create_image_buffer (myIcon->cFileName, iWidth, iHeight, 0); // maybe we could use the current icon image ... CD_APPLET_SET_TRANSITION_ON_MY_ICON (_render_step_cairo, _render_step_opengl, g_bUseOpenGL, // bFastPace : vite si opengl, lent si cairo. 2000, // 2s transition TRUE); // bRemoveWhenFinished cairo_surface_destroy (s); } return cName; }
void gldi_dialog_set_icon_surface (CairoDialog *pDialog, cairo_surface_t *pNewIconSurface, int iNewIconSize) { int iIconSize = (pDialog->iIconSize != 0 ? pDialog->iIconSize : myDialogsParam.iDialogIconSize); cairo_surface_t *pIconBuffer = cairo_dock_duplicate_surface (pNewIconSurface, iNewIconSize, iNewIconSize, iIconSize, iIconSize); _set_icon_surface (pDialog, pIconBuffer, iIconSize); }