static GdkWindow * find_current_window (char **window_title) { GdkWindow *window; if (!screenshot_grab_lock ()) exit (0); if (take_window_shot) { window = screenshot_find_current_window (); if (!window) { take_window_shot = FALSE; window = gdk_get_default_root_window (); } else { gchar *tmp, *sanitized; tmp = screenshot_get_window_title (window); sanitized = screenshot_sanitize_filename (tmp); g_free (tmp); *window_title = sanitized; } } else { window = gdk_get_default_root_window (); } return window; }
PasteClip Ctrl::GtkDnd(GtkWidget *widget, GdkDragContext *context, gint x, gint y, guint time, gpointer user_data, bool paste) { DndTargets(context); g_object_ref(context); // make sure these always survive the action... g_object_ref(widget); dnd_context = context; dnd_widget = widget; dnd_time = time; PasteClip clip; clip.type = 1; clip.paste = paste; clip.accepted = false; clip.allowed = DND_MOVE|DND_COPY; gint dummy; GdkModifierType mod; gdk_window_get_pointer(gdk_get_default_root_window(), &dummy, &dummy, &mod); clip.action = mod & GDK_CONTROL_MASK ? DND_COPY : DND_MOVE; Ctrl *w = DragWnd(user_data); if(w) { gint mx, my; GdkModifierType mod; gdk_window_get_pointer(gdk_get_default_root_window(), &mx, &my, &mod); CurrentState = mod; CurrentMousePos = Point(x, y) + w->GetScreenRect().TopLeft(); w->DnD(CurrentMousePos, clip); } gdk_drag_status(context, clip.IsAccepted() ? clip.GetAction() == DND_MOVE ? GDK_ACTION_MOVE : GDK_ACTION_COPY : GdkDragAction(0), time); return clip; }
static GdkPixbuf* accessx_status_applet_get_glyph_pixbuf(AccessxStatusApplet* sapplet, GtkWidget* widget, GdkPixbuf* base, GdkColor* fg, GdkColor* bg, gchar* glyphstring) { GdkPixbuf* glyph_pixbuf; #if GTK_CHECK_VERSION (3, 0, 0) cairo_surface_t *surface; #else GdkPixbuf *alpha_pixbuf; GdkPixmap* pixmap; #endif PangoLayout* layout; PangoRectangle ink, logic; PangoContext* pango_context; gint w = gdk_pixbuf_get_width(base); gint h = gdk_pixbuf_get_height(base); cairo_t *cr; #if GTK_CHECK_VERSION (3, 0, 0) surface = gdk_window_create_similar_surface (gdk_get_default_root_window (), CAIRO_CONTENT_COLOR_ALPHA, w, h); #else pixmap = gdk_pixmap_new(gdk_get_default_root_window (),w, h, -1); #endif pango_context = gtk_widget_get_pango_context(widget); layout = pango_layout_new(pango_context); pango_layout_set_alignment(layout, PANGO_ALIGN_CENTER); pango_layout_set_text(layout, glyphstring, -1); #if GTK_CHECK_VERSION (3, 0, 0) cr = cairo_create (surface); #else cr = gdk_cairo_create (pixmap); #endif gdk_cairo_set_source_color (cr, bg); cairo_paint (cr); gdk_cairo_set_source_color (cr, fg); pango_layout_get_pixel_extents(layout, &ink, &logic); cairo_move_to (cr, (w - ink.x - ink.width)/2, (h - ink.y - ink.height)/2); pango_cairo_show_layout (cr, layout); cairo_destroy (cr); g_object_unref(layout); #if GTK_CHECK_VERSION (3, 0, 0) glyph_pixbuf = gdk_pixbuf_get_from_surface (surface, 0, 0, w, h); cairo_surface_destroy (surface); return glyph_pixbuf; #else glyph_pixbuf = gdk_pixbuf_get_from_drawable(NULL, pixmap, NULL, 0, 0, 0, 0, w, h); g_object_unref(pixmap); alpha_pixbuf = gdk_pixbuf_add_alpha(glyph_pixbuf, TRUE, bg->red >> 8, bg->green >> 8, bg->blue >> 8); g_object_unref(G_OBJECT(glyph_pixbuf)); return alpha_pixbuf; #endif }
int main (int argc, char **argv) { ByzanzSession *rec; GOptionContext* context; GError *error = NULL; GFile *file; g_set_prgname (argv[0]); #ifdef GETTEXT_PACKAGE bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); #endif context = g_option_context_new (_("record your current desktop session")); #ifdef GETTEXT_PACKAGE g_option_context_set_translation_domain(context, GETTEXT_PACKAGE); #endif g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE); g_option_context_add_group (context, gtk_get_option_group (TRUE)); if (!g_option_context_parse (context, &argc, &argv, &error)) { g_print (_("Wrong option: %s\n"), error->message); usage (); return 1; } if (argc != 2) { usage (); return 0; } if (!clamp_to_window (&area, gdk_get_default_root_window (), &area)) { g_print (_("Given area is not inside desktop.\n")); return 1; } file = g_file_new_for_commandline_arg (argv[1]); rec = byzanz_session_new (file, byzanz_encoder_get_type_from_file (file), gdk_get_default_root_window (), &area, cursor, audio); g_object_unref (file); g_signal_connect (rec, "notify", G_CALLBACK (session_notify_cb), NULL); delay = MAX (delay, 1); delay = (delay - 1) * 1000; duration = MAX (duration, 0); duration *= 1000; g_timeout_add (delay, start_recording, rec); gtk_main (); g_object_unref (rec); return 0; }
static void camo_engine_render_background (GtkThemingEngine *engine, cairo_t *cr, gdouble x, gdouble y, gdouble width, gdouble height) { GdkRGBA color; GtkStateFlags flags = gtk_theming_engine_get_state (engine); gboolean generate = FALSE; gint scr_width, scr_height; gtk_theming_engine_get_background_color (engine, flags, &color); cairo_save (cr); if ((color.red == 0) && (color.green == 0) && (color.blue == 0)) { if (width > pool_width) { generate = TRUE; pool_width = width; } if (height > pool_height) { generate = TRUE; pool_height = height; } if (generate) { scr_width = gdk_screen_get_width (gdk_window_get_screen (gdk_get_default_root_window ())); scr_height = gdk_screen_get_height (gdk_window_get_screen (gdk_get_default_root_window ())); if (scr_width > pool_width) pool_width = scr_width; if (scr_height > pool_height) pool_height = scr_height; pool_gen (); } cairo_set_source_surface (cr, pool, 0, 0); } else gdk_cairo_set_source_rgba (cr, &color); cairo_rectangle (cr, x, y, width, height); cairo_fill (cr); cairo_restore (cr); }
/** * shell_global_create_root_pixmap_actor: * @global: a #ShellGlobal * * Creates an actor showing the root window pixmap. * * Return value: (transfer none): a #ClutterActor with the root window pixmap. * The actor is floating, hence (transfer none). */ ClutterActor * shell_global_create_root_pixmap_actor (ShellGlobal *global) { GdkWindow *window; ClutterActor *stage; ClutterColor stage_color; /* The actor created is actually a ClutterClone of global->root_pixmap. */ if (global->root_pixmap == NULL) { global->root_pixmap = clutter_glx_texture_pixmap_new (); clutter_texture_set_repeat (CLUTTER_TEXTURE (global->root_pixmap), TRUE, TRUE); /* The low and medium quality filters give nearest-neighbor resizing. */ clutter_texture_set_filter_quality (CLUTTER_TEXTURE (global->root_pixmap), CLUTTER_TEXTURE_QUALITY_HIGH); /* Initialize to the stage color, since that's what will be seen * in the main view if there's no actual background window. */ stage = mutter_plugin_get_stage (global->plugin); clutter_stage_get_color (CLUTTER_STAGE (stage), &stage_color); clutter_texture_set_from_rgb_data (CLUTTER_TEXTURE (global->root_pixmap), /* ClutterColor has the same layout * as one pixel of RGB(A) data. */ (const guchar *)&stage_color, FALSE, /* w, h, rowstride, bpp, flags */ 1, 1, 3, 3, 0, NULL); /* We can only clone an actor within a stage, so we hide the source * texture then add it to the stage */ clutter_actor_hide (global->root_pixmap); clutter_container_add_actor (CLUTTER_CONTAINER (stage), global->root_pixmap); /* This really should never happen; but just in case... */ g_signal_connect (global->root_pixmap, "destroy", G_CALLBACK (root_pixmap_destroy), global); /* Metacity handles changes to some root window properties in its global * event filter, though not _XROOTPMAP_ID. For all root window property * changes, the global filter returns GDK_FILTER_CONTINUE, so our * window specific filter will be called after the global one. * * Because Metacity is already handling root window property updates, * we don't have to worry about adding the PropertyChange mask to the * root window to get PropertyNotify events. */ window = gdk_get_default_root_window (); gdk_window_add_filter (window, root_window_filter, global); update_root_window_pixmap (global); } return clutter_clone_new (global->root_pixmap); }
static void assistive_registry_start (void) { GdkWindow *root; guint tid; root = gdk_get_default_root_window (); if ( ! AT_SPI_IOR) { AT_SPI_IOR = XInternAtom (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), "AT_SPI_IOR", False); } gdk_window_set_events (root, GDK_PROPERTY_CHANGE_MASK); if ( ! assistive_registry_launch ()) { g_warning ("The accessibility registry could not be started."); return; } gdk_window_add_filter (root, filter_watch, NULL); tid = g_timeout_add_seconds (5, filter_timeout, NULL); gtk_main (); gdk_window_remove_filter (root, filter_watch, NULL); g_source_remove (tid); }
/* Stolen from xfwm4 and modified. * FALSE on error. Call initModifiers before this. */ static gboolean grabKey(MyKey *key) { Window root; Display *dpy = GDK_DISPLAY(); static gboolean need_init = TRUE; if (need_init) { need_init = FALSE; gdk_window_add_filter(gdk_get_default_root_window(), filter_keys, NULL); } gdk_error_trap_push(); root = GDK_ROOT_WINDOW(); GRAB(key, 0); /* Here we grab all combinations of well known modifiers */ GRAB(key, ScrollLockMask); GRAB(key, NumLockMask); GRAB(key, CapsLockMask); GRAB(key, ScrollLockMask | NumLockMask); GRAB(key, ScrollLockMask | CapsLockMask); GRAB(key, CapsLockMask | NumLockMask); GRAB(key, ScrollLockMask | CapsLockMask | NumLockMask); gdk_flush(); return gdk_error_trap_pop() == Success; }
static Window find_wm_window (GdkWindow *window) { Window xid, root, parent, *children; unsigned int nchildren; if (window == gdk_get_default_root_window ()) return None; xid = GDK_WINDOW_XID (window); do { if (XQueryTree (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), xid, &root, &parent, &children, &nchildren) == 0) { g_warning ("Couldn't find window manager window"); return None; } if (root == parent) return xid; xid = parent; } while (TRUE); }
static GdkPixbuf* get_screenshot () { GdkWindow *root_window = gdk_get_default_root_window (); gint x, y; gint swidth, sheight; guint m_offset_x = 0, m_offset_y = 0; gint monitors = gdk_screen_get_n_monitors (gdk_screen_get_default ()); if (monitors > 1) { gint px = 0, py = 0; gdk_display_get_pointer (gdk_display_get_default (), NULL, &px, &py, NULL); gint current_monitor = gdk_screen_get_monitor_at_point (gdk_screen_get_default (), px, py); for (int i = 0; i < current_monitor; i++) { GdkRectangle mon_rect; gdk_screen_get_monitor_geometry (gdk_screen_get_default (), i, &mon_rect); m_offset_x += mon_rect.width; m_offset_y += mon_rect.height; } } gdk_drawable_get_size (root_window, &swidth, &sheight); gdk_window_get_origin (root_window, &x, &y); if (swidth <= m_offset_x) m_offset_x = 0; if (sheight <= m_offset_y) m_offset_y = 0; return gdk_pixbuf_get_from_drawable (NULL, root_window, NULL, x + options.screenshot_offset_x + m_offset_x, y + options.screenshot_offset_y + m_offset_y, 0, 0, swidth - options.screenshot_offset_x - m_offset_x, sheight - options.screenshot_offset_y - m_offset_y); }
// this function will make sure that everything has been initialized. nsresult nsScreenManagerGtk :: EnsureInit() { if (mCachedScreenArray.Count() > 0) return NS_OK; mRootWindow = gdk_get_default_root_window(); if (!mRootWindow) { // Sometimes we don't initial X (e.g., xpcshell) return NS_OK; } g_object_ref(mRootWindow); // GDK_PROPERTY_CHANGE_MASK ==> PropertyChangeMask, for PropertyNotify gdk_window_set_events(mRootWindow, GdkEventMask(gdk_window_get_events(mRootWindow) | GDK_PROPERTY_CHANGE_MASK)); g_signal_connect(gdk_screen_get_default(), "monitors-changed", G_CALLBACK(monitors_changed), this); #ifdef MOZ_X11 gdk_window_add_filter(mRootWindow, root_window_event_filter, this); if (GDK_IS_X11_DISPLAY(gdk_display_get_default())) mNetWorkareaAtom = XInternAtom(GDK_WINDOW_XDISPLAY(mRootWindow), "_NET_WORKAREA", False); #endif return Init(); }
static GdkPixbuf* get_pixbuf (void) { GdkPixbuf *screenshot; GdkPixbuf *magnified; #if 0 g_print ("Size %d x %d\n", last_grab_width, last_grab_height); #endif screenshot = gdk_pixbuf_get_from_window(gdk_get_default_root_window(), last_grab_x, last_grab_y, last_grab_width, last_grab_height); if (screenshot == NULL) { g_printerr ("Screenshot failed\n"); exit (1); } magnified = gdk_pixbuf_scale_simple (screenshot, last_grab_width * width_factor, last_grab_height * height_factor, interp_mode); g_object_unref (G_OBJECT (screenshot)); return magnified; }
void ungrab_key (int key_code) { GdkWindow *root=gdk_get_default_root_window(); gdk_error_trap_push (); XUngrabKey (GDK_DISPLAY (), key_code, AnyModifier, (GDK_WINDOW_XID (root) ? GDK_WINDOW_XID (root) : DefaultRootWindow (GDK_DISPLAY()))); XUngrabKey (GDK_DISPLAY (), AnyKey, AnyModifier, (GDK_WINDOW_XID (root) ? GDK_WINDOW_XID (root) : DefaultRootWindow (GDK_DISPLAY()))); gdk_flush (); if (gdk_error_trap_pop ()) { gchar *error; gchar *key; key=g_strdup_printf ("%s",(XKeysymToString (XKeycodeToKeysym (GDK_DISPLAY (), key_code, 0)) != NULL)? XKeysymToString (XKeycodeToKeysym (GDK_DISPLAY (),key_code, 0)): g_strdup_printf ("%d",key_code)); error = g_strdup_printf (_("It seems that another application already has" " access to the multimedia keys.\n" "Key %s couldn't be bound.\n" "Is another daemon already running ?\n"), key); show_error(error); printf("[Sven][ERROR]:%s",error); g_free (key); g_free (error); } }
static GdkPixbuf* accessx_status_applet_get_glyph_pixbuf(AccessxStatusApplet* sapplet, GtkWidget* widget, GdkPixbuf* base, GdkColor* fg, GdkColor* bg, gchar* glyphstring) { GdkPixbuf* glyph_pixbuf; cairo_surface_t *surface; PangoLayout* layout; PangoRectangle ink, logic; PangoContext* pango_context; gint w = gdk_pixbuf_get_width(base); gint h = gdk_pixbuf_get_height(base); cairo_t *cr; surface = gdk_window_create_similar_surface (gdk_get_default_root_window (), CAIRO_CONTENT_COLOR_ALPHA, w, h); pango_context = gtk_widget_get_pango_context(widget); layout = pango_layout_new(pango_context); pango_layout_set_alignment(layout, PANGO_ALIGN_CENTER); pango_layout_set_text(layout, glyphstring, -1); cr = cairo_create (surface); gdk_cairo_set_source_color (cr, bg); cairo_paint (cr); gdk_cairo_set_source_color (cr, fg); pango_layout_get_pixel_extents(layout, &ink, &logic); cairo_move_to (cr, (w - ink.x - ink.width)/2, (h - ink.y - ink.height)/2); pango_cairo_show_layout (cr, layout); cairo_destroy (cr); g_object_unref(layout); glyph_pixbuf = gdk_pixbuf_get_from_surface (surface, 0, 0, w, h); cairo_surface_destroy (surface); return glyph_pixbuf; }
void xfce_randr_reload (XfceRandr *randr) { Display *xdisplay; GdkWindow *root_window; xfce_randr_cleanup (randr); /* get the x display */ xdisplay = gdk_x11_display_get_xdisplay (randr->priv->display); /* get the root window */ root_window = gdk_get_default_root_window (); /* get the screen resource */ #ifdef HAS_RANDR_ONE_POINT_THREE /* xfce_randr_reload() is only called after a xrandr notification, which means that X is aware of the new hardware already. So, if possible, do not reprobe the hardware again. */ if (randr->priv->has_1_3) randr->priv->resources = XRRGetScreenResourcesCurrent (xdisplay, GDK_WINDOW_XID (root_window)); else #endif randr->priv->resources = XRRGetScreenResources (xdisplay, GDK_WINDOW_XID (root_window)); /* repopulate */ xfce_randr_populate (randr, xdisplay, root_window); }
// this function will make sure that everything has been initialized. nsresult nsScreenManagerGtk :: EnsureInit() { if (mCachedScreenArray.Count() > 0) return NS_OK; #if GTK_CHECK_VERSION(2,2,0) mRootWindow = gdk_get_default_root_window(); #else mRootWindow = GDK_ROOT_PARENT(); #endif // GTK_CHECK_VERSION(2,2,0) g_object_ref(mRootWindow); // GDK_STRUCTURE_MASK ==> StructureNotifyMask, for ConfigureNotify // GDK_PROPERTY_CHANGE_MASK ==> PropertyChangeMask, for PropertyNotify gdk_window_set_events(mRootWindow, GdkEventMask(gdk_window_get_events(mRootWindow) | GDK_STRUCTURE_MASK | GDK_PROPERTY_CHANGE_MASK)); gdk_window_add_filter(mRootWindow, root_window_event_filter, this); #ifdef MOZ_X11 mNetWorkareaAtom = XInternAtom(GDK_WINDOW_XDISPLAY(mRootWindow), "_NET_WORKAREA", False); #endif return Init(); }
static void fix_without_wm(GtkWidget* child) { GdkDisplay* default_display; GdkScreen* default_screen; gint primary_monitor; GdkRectangle dest; default_display = gdk_display_get_default(); default_screen = gdk_display_get_default_screen(default_display); GdkCursor* cursor = gdk_cursor_new_for_display (default_display, GDK_LEFT_PTR); gdk_window_set_cursor (gdk_get_default_root_window (), cursor); g_object_unref(cursor); // NOTE: width/height is total width/height of multiple-screens. // So, in this way, web-container window is forced to position in center // of all screens. //INSTALLER_WIN_WIDTH = gdk_screen_width(); //INSTALLER_WIN_HEIGHT = gdk_screen_height(); gtk_window_move(GTK_WINDOW(installer_container), 0, 0); gtk_window_fullscreen(GTK_WINDOW(installer_container)); primary_monitor = gdk_screen_get_primary_monitor(default_screen); gdk_screen_get_monitor_geometry(default_screen, primary_monitor, &dest); INSTALLER_WIN_WIDTH = dest.width; INSTALLER_WIN_HEIGHT = dest.height; g_message("[%s] installer container, width: %d, height: %d\n", __func__, INSTALLER_WIN_WIDTH, INSTALLER_WIN_HEIGHT); BackgroundInfo* bg_info = create_background_info(installer_container, child); background_info_set_background_by_file(bg_info, BACKGROUND); setup_monitor_background(); }
void setup_background(GtkWidget* container, GtkWidget* webview, const char* xatom_name) { _BG_ATOM = gdk_x11_get_xatom_by_name(xatom_name); BackgroundInfo* info = create_background_info(container, webview); background_info_set_background_by_drawable(info, get_blurred_background()); //TODO: //we shoul use xatom_name window to set events instead of root window //because the monitors changed signal will came before root window rect changed //so the Xroot window rect maybe keep old rect in update_bg function gdk_window_set_events(gdk_get_default_root_window(), GDK_PROPERTY_CHANGE_MASK); gdk_window_add_filter(gdk_get_default_root_window(), (GdkFilterFunc)update_bg, info); }
gboolean uninit_composite (void) { XCompositeUnredirectSubwindows (gdk_x11_get_default_xdisplay (), GDK_WINDOW_XWINDOW (gdk_get_default_root_window ()), CompositeRedirectAutomatic); return TRUE; }
/* Get the background pixbuf. */ static GdkPixbuf * get_background_pixbuf(void) { /* Get the root window pixmap. */ GdkScreen * screen = gdk_screen_get_default(); #ifdef ENABLE_GTK3 GdkPixbuf * pixbuf = gdk_pixbuf_get_from_window( gdk_get_default_root_window(), 0, 0, gdk_screen_get_width(screen), /* Width */ gdk_screen_get_height(screen)); /* Height */ #else GdkPixbuf * pixbuf = gdk_pixbuf_get_from_drawable( NULL, /* Allocate a new pixbuf */ gdk_get_default_root_window(), /* The drawable */ NULL, /* Its colormap */ 0, 0, 0, 0, /* Coordinates */ gdk_screen_get_width(screen), /* Width */ gdk_screen_get_height(screen)); /* Height */ #endif /* Make the background darker. */ if (pixbuf != NULL) { unsigned char * pixels = gdk_pixbuf_get_pixels(pixbuf); int width = gdk_pixbuf_get_width(pixbuf); int height = gdk_pixbuf_get_height(pixbuf); int pixel_stride = ((gdk_pixbuf_get_has_alpha(pixbuf)) ? 4 : 3); int row_stride = gdk_pixbuf_get_rowstride(pixbuf); int y; for (y = 0; y < height; y += 1) { unsigned char * p = pixels; int x; for (x = 0; x < width; x += 1) { p[0] = p[0] / 2; p[1] = p[1] / 2; p[2] = p[2] / 2; p += pixel_stride; } pixels += row_stride; } } return pixbuf; }
/* * Called when the root window pixmap actor is destroyed. */ static void root_pixmap_destroy (GObject *sender, gpointer data) { ShellGlobal *global = SHELL_GLOBAL (data); gdk_window_remove_filter (gdk_get_default_root_window (), root_window_filter, global); global->root_pixmap = NULL; }
int main (int argc, char **argv) { GdkWindow *root; GdkPixbuf *pixbuf; gboolean ret; gint retval = 1; GError *error = NULL; gtk_init (&argc, &argv); root = gdk_get_default_root_window (); pixbuf = gdk_pixbuf_get_from_window (root, 0, 0, 150, 160); /* PASS */ g_debug ("try to save PNG with a profile"); ret = save_image_png ("icc-profile.png", pixbuf, &error); if (!ret) { g_warning ("FAILED: did not save image: %s", error->message); g_error_free (error); goto out; } /* PASS */ g_debug ("try to save TIFF with a profile"); ret = save_image_tiff ("icc-profile.tiff", pixbuf, &error); if (!ret) { g_warning ("FAILED: did not save image: %s", error->message); g_error_free (error); goto out; } /* PASS */ g_debug ("try to load PNG and get color attributes"); ret = save_image_verify ("icc-profile.png", &error); if (!ret) { g_warning ("FAILED: did not load image: %s", error->message); g_error_free (error); goto out; } /* PASS */ g_debug ("try to load TIFF and get color attributes"); ret = save_image_verify ("icc-profile.tiff", &error); if (!ret) { g_warning ("FAILED: did not load image: %s", error->message); g_error_free (error); goto out; } /* success */ retval = 0; g_debug ("ALL OKAY!"); out: return retval; }
wxScreenDCImpl::wxScreenDCImpl(wxScreenDC* owner) : base_type(owner) { GdkWindow* window = gdk_get_default_root_window(); m_width = gdk_window_get_width(window); m_height = gdk_window_get_height(window); cairo_t* cr = gdk_cairo_create(window); SetGraphicsContext(wxGraphicsContext::CreateFromNative(cr)); }
void panel_stop(panel *p) { ENTER; tray_destructor(p); XSelectInput (gdk_helper_display(), GDK_ROOT_WINDOW(), NoEventMask); gdk_window_remove_filter(gdk_get_default_root_window (), (GdkFilterFunc)panel_wm_events, p); gtk_widget_destroy(p->topgwin); RET(); }
int init_grabber(void) { set_numlockmask(); GdkWindow *gdk_root = gdk_get_default_root_window(); Window x_root = DefaultRootWindow(main_dpy); int i; int error; gdk_window_add_filter(gdk_root, keyevent_filter, NULL); for (i = 0 ; keybinds[i].handler != NULL ; i++) { if (0 != keybinds[i].keycode) { /* now that we have a display, replace KeySym by KeyCode in conf struct */ keybinds[i].keycode = XKeysymToKeycode(main_dpy, keybinds[i].keycode); gdk_error_trap_push(); XGrabKey(main_dpy, keybinds[i].keycode, keybinds[i].mask, x_root, TRUE, GrabModeAsync, GrabModeAsync); if (0 != numlockmask) { XGrabKey(main_dpy, keybinds[i].keycode, numlockmask | keybinds[i].mask, x_root, TRUE, GrabModeAsync, GrabModeAsync); } gdk_flush (); if ((error = gdk_error_trap_pop()) != 0) { if (BadAccess == error) { fprintf(stderr, "[bonnye] Command %s : shortcut already grabbed\n", keybinds[i].name); } else { fprintf(stderr, "[bonnye] Command %s : unknown error %d\n", keybinds[i].name, error); } /* } else { */ /* printf("[bonnye] Grabbing (%d, 0x%x) for %s\n", */ /* keybinds[i].keycode, */ /* keybinds[i].mask, */ /* keybinds[i].name); */ } } } return 0; }
static cairo_surface_t * tile_surface (cairo_surface_t *surface, int width, int height) { cairo_surface_t *copy; cairo_t *cr; if (surface == NULL) { copy = gdk_window_create_similar_surface (gdk_get_default_root_window (), CAIRO_CONTENT_COLOR, width, height); } else { copy = cairo_surface_create_similar (surface, cairo_surface_get_content (surface), width, height); } cr = cairo_create (copy); if (surface != NULL) { cairo_pattern_t *pattern; cairo_set_source_surface (cr, surface, 0.0, 0.0); pattern = cairo_get_source (cr); cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT); } else { GtkStyleContext *context; GdkRGBA bg; context = gtk_style_context_new (); gtk_style_context_add_provider (context, GTK_STYLE_PROVIDER (gtk_css_provider_get_default ()), GTK_STYLE_PROVIDER_PRIORITY_THEME); gtk_style_context_get_background_color (context, GTK_STATE_FLAG_NORMAL, &bg); gdk_cairo_set_source_rgba(cr, &bg); g_object_unref (G_OBJECT (context)); } cairo_paint (cr); if (cairo_status (cr) != CAIRO_STATUS_SUCCESS) { cairo_surface_destroy (copy); copy = NULL; } cairo_destroy(cr); return copy; }
static MT_PIXMAP *_mt_pixmap_new_from_image(MT_IMAGE *img) { GdkPixmap *pixmap; int width, height; width = gdk_pixbuf_get_width((GdkPixbuf *)img); height = gdk_pixbuf_get_height((GdkPixbuf *)img); pixmap = gdk_pixmap_new(gdk_get_default_root_window(), width, height, GTK_STYLE(mt_style)->depth); gdk_pixbuf_render_to_drawable((GdkPixbuf *)img, pixmap, NULL, 0, 0, 0, 0, width, height, GDK_RGB_DITHER_NONE, 0, 0); return (MT_PIXMAP *)pixmap; }
wxScreenDCImpl::wxScreenDCImpl(wxScreenDC* owner) : base_type(owner, 0) { GdkWindow* window = gdk_get_default_root_window(); m_width = gdk_window_get_width(window); m_height = gdk_window_get_height(window); cairo_t* cr = gdk_cairo_create(window); wxGraphicsContext* gc = wxGraphicsContext::CreateFromNative(cr); gc->EnableOffset(true); SetGraphicsContext(gc); }
void fix_without_wm(GtkWidget* child) { GdkCursor* cursor = gdk_cursor_new (GDK_LEFT_PTR); gdk_window_set_cursor (gdk_get_default_root_window (), cursor); g_object_unref(cursor); INSTALLER_WIN_WIDTH = gdk_screen_width(); INSTALLER_WIN_HEIGHT = gdk_screen_height(); gtk_window_move(GTK_WINDOW(installer_container), 0, 0); BackgroundInfo* bg_info = create_background_info(installer_container, child); background_info_set_background_by_file(bg_info, "/usr/share/backgrounds/default_background.jpg"); }
static cairo_surface_t * tile_surface (cairo_surface_t *surface, int width, int height) { cairo_surface_t *copy; cairo_t *cr; #if GTK_CHECK_VERSION (3, 0, 0) if (surface == NULL) { copy = gdk_window_create_similar_surface (gdk_get_default_root_window (), CAIRO_CONTENT_COLOR, width, height); } else { copy = cairo_surface_create_similar (surface, cairo_surface_get_content (surface), width, height); } #else copy = gdk_pixmap_new(surface, width, height, surface == NULL? 24 : -1); #endif cr = cairo_create (copy); if (surface != NULL) { cairo_pattern_t *pattern; cairo_set_source_surface (cr, surface, 0.0, 0.0); pattern = cairo_get_source (cr); cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT); } else { GtkStyle *style; style = gtk_widget_get_default_style (); gdk_cairo_set_source_color(cr, &style->bg[GTK_STATE_NORMAL]); } cairo_paint (cr); if (cairo_status (cr) != CAIRO_STATUS_SUCCESS) { cairo_surface_destroy (copy); copy = NULL; } cairo_destroy(cr); return copy; }