cmsHPROFILE * f_screen_get_profile (GdkScreen *screen) { Display *dpy; Atom icc_atom, type; int format; gulong nitems; gulong bytes_after; guchar *str; int result; cmsHPROFILE *profile; dpy = GDK_DISPLAY_XDISPLAY (gdk_screen_get_display (screen)); icc_atom = gdk_x11_get_xatom_by_name_for_display (gdk_screen_get_display (screen), "_ICC_PROFILE"); result = XGetWindowProperty (dpy, GDK_WINDOW_XID (gdk_screen_get_root_window (screen)), icc_atom, 0, G_MAXLONG, False, XA_CARDINAL, &type, &format, &nitems, &bytes_after, (guchar **)&str); /* TODO: handle bytes_after != 0 */ if (nitems) { profile = cmsOpenProfileFromMem(str, nitems); XFree (str); return profile; } else return NULL; }
static gboolean is_in_viewport (GtkWindow *window, GdkScreen *screen, gint workspace, gint viewport_x, gint viewport_y) { GdkScreen *s; GdkDisplay *display; GdkWindow *gdkwindow; const gchar *cur_name; const gchar *name; gint cur_n; gint n; gint ws; gint sc_width, sc_height; gint x, y, width, height; gint vp_x, vp_y; /* Check for screen and display match */ display = gdk_screen_get_display (screen); cur_name = gdk_display_get_name (display); cur_n = gdk_screen_get_number (screen); s = gtk_window_get_screen (window); display = gdk_screen_get_display (s); name = gdk_display_get_name (display); n = gdk_screen_get_number (s); if (strcmp (cur_name, name) != 0 || cur_n != n) { return FALSE; } /* Check for workspace match */ ws = gedit_utils_get_window_workspace (window); if (ws != workspace && ws != GEDIT_ALL_WORKSPACES) { return FALSE; } /* Check for viewport match */ gdkwindow = gtk_widget_get_window (GTK_WIDGET (window)); gdk_window_get_position (gdkwindow, &x, &y); width = gdk_window_get_width (gdkwindow); height = gdk_window_get_height (gdkwindow); gedit_utils_get_current_viewport (screen, &vp_x, &vp_y); x += vp_x; y += vp_y; sc_width = gdk_screen_get_width (screen); sc_height = gdk_screen_get_height (screen); return x + width * .25 >= viewport_x && x + width * .75 <= viewport_x + sc_width && y >= viewport_y && y + height <= viewport_y + sc_height; }
/* Asks the user to click on a window, then waits for them click * the mouse. When the mouse is released, returns the toplevel * window under the pointer, or NULL, if there is none. */ static GtkWidget * query_for_toplevel (GdkScreen *screen, const char *prompt) { GdkDisplay *display = gdk_screen_get_display (screen); GtkWidget *popup, *label, *frame; GdkCursor *cursor; GtkWidget *toplevel = NULL; popup = gtk_window_new (GTK_WINDOW_POPUP); gtk_window_set_screen (GTK_WINDOW (popup), screen); gtk_window_set_modal (GTK_WINDOW (popup), TRUE); gtk_window_set_position (GTK_WINDOW (popup), GTK_WIN_POS_CENTER); frame = gtk_frame_new (NULL); gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT); gtk_container_add (GTK_CONTAINER (popup), frame); label = gtk_label_new (prompt); g_object_set (label, "margin", 10, NULL); gtk_container_add (GTK_CONTAINER (frame), label); gtk_widget_show_all (popup); cursor = gdk_cursor_new_from_name (display, "crosshair"); if (gdk_device_grab (gtk_get_current_event_device (), gtk_widget_get_window (popup), GDK_OWNERSHIP_NONE, FALSE, GDK_BUTTON_RELEASE_MASK, cursor, GDK_CURRENT_TIME) == GDK_GRAB_SUCCESS) { gboolean clicked = FALSE; g_signal_connect (popup, "button-release-event", G_CALLBACK (button_release_event_cb), &clicked); /* Process events until clicked is set by button_release_event_cb. * We pass in may_block=TRUE since we want to wait if there * are no events currently. */ while (!clicked) g_main_context_iteration (NULL, TRUE); toplevel = find_toplevel_at_pointer (gdk_screen_get_display (screen)); if (toplevel == popup) toplevel = NULL; } g_object_unref (cursor); gtk_widget_destroy (popup); gdk_flush (); /* Really release the grab */ return toplevel; }
/************************************************************************** Set the "hand" cursor when moving over a link. **************************************************************************/ static void set_cursor_if_appropriate(GtkTextView *text_view, gint x, gint y) { static gboolean hovering_over_link = FALSE; static GdkCursor *hand_cursor = NULL; static GdkCursor *regular_cursor = NULL; GSList *tags, *tagp; GtkTextIter iter; gboolean hovering = FALSE; /* Initialize the cursors. */ if (!hand_cursor) { hand_cursor = gdk_cursor_new_for_display( gdk_screen_get_display(gdk_screen_get_default()), GDK_HAND2); } if (!regular_cursor) { regular_cursor = gdk_cursor_new_for_display( gdk_screen_get_display(gdk_screen_get_default()), GDK_XTERM); } gtk_text_view_get_iter_at_location(text_view, &iter, x, y); tags = gtk_text_iter_get_tags(&iter); for (tagp = tags; tagp; tagp = tagp->next) { enum text_link_type type = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(tagp->data), "type")); if (type != 0) { hovering = TRUE; break; } } if (hovering != hovering_over_link) { hovering_over_link = hovering; if (hovering_over_link) { gdk_window_set_cursor(gtk_text_view_get_window(text_view, GTK_TEXT_WINDOW_TEXT), hand_cursor); } else { gdk_window_set_cursor(gtk_text_view_get_window(text_view, GTK_TEXT_WINDOW_TEXT), regular_cursor); } } if (tags) { g_slist_free(tags); } }
static void get_im (GtkIMContextGCIN *context_xim) { GdkWindow *client_window = context_xim->client_window; GdkScreen *screen = gdk_window_get_screen (client_window); GdkDisplay *display = gdk_screen_get_display (screen); if (!context_xim->gcin_ch) { if (!(context_xim->gcin_ch = gcin_im_client_open(GDK_DISPLAY_XDISPLAY(gdk_display_get_default())))) perror("cannot open gcin_ch"); #if 1 context_xim->timeout_handle = 0; context_xim->pe_attN = 0; context_xim->pe_att = NULL; context_xim->pe_str = NULL; context_xim->pe_cursor = 0; #endif #if 0 // coredump g_signal_connect (display, "closed", G_CALLBACK (gcin_display_closed), context_xim); #endif if (context_xim->is_mozilla) { int rflag; gcin_im_client_set_flags(context_xim->gcin_ch, FLAG_GCIN_client_handle_raise_window, &rflag); context_xim->dirty_fix_off = (rflag & FLAG_GCIN_srv_ret_status_use_pop_up) > 0; } } }
static void gdk_wmspec_change_state (gboolean add, GdkWindow *window, GdkAtom state1, GdkAtom state2) { GdkDisplay *display = gdk_screen_get_display (gdk_drawable_get_screen (GDK_DRAWABLE (window))); XEvent xev; #define _NET_WM_STATE_REMOVE 0 /* remove/unset property */ #define _NET_WM_STATE_ADD 1 /* add/set property */ #define _NET_WM_STATE_TOGGLE 2 /* toggle property */ xev.xclient.type = ClientMessage; xev.xclient.serial = 0; xev.xclient.send_event = True; xev.xclient.window = GDK_WINDOW_XID (window); xev.xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_STATE"); xev.xclient.format = 32; xev.xclient.data.l[0] = add ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE; xev.xclient.data.l[1] = gdk_x11_atom_to_xatom_for_display (display, state1); xev.xclient.data.l[2] = gdk_x11_atom_to_xatom_for_display (display, state2); XSendEvent (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XWINDOW (gdk_screen_get_root_window (gdk_drawable_get_screen (GDK_DRAWABLE (window)))), False, SubstructureRedirectMask | SubstructureNotifyMask, &xev); }
static gboolean osk_audio_init_canberra(OskAudio* audio) { GdkScreen* screen; ca_proplist* props; const char* name; int nr; if (ca_context_create(&audio->ca) != CA_SUCCESS) return FALSE; screen = gdk_screen_get_default(); nr = gdk_screen_get_number(screen); name = gdk_display_get_name(gdk_screen_get_display(screen)); /* Set default application properties */ ca_proplist_create(&props); ca_proplist_sets(props, CA_PROP_APPLICATION_NAME, "Onboard"); ca_proplist_sets(props, CA_PROP_APPLICATION_ID, "org.onboard.Onboard"); ca_proplist_sets(props, CA_PROP_APPLICATION_ICON_NAME, "onboard"); ca_proplist_sets(props, CA_PROP_WINDOW_X11_DISPLAY, name); ca_proplist_setf(props, CA_PROP_WINDOW_X11_SCREEN, "%i", nr); ca_context_change_props_full(audio->ca, props); ca_proplist_destroy(props); return TRUE; }
char * na_tray_manager_get_child_title (NaTrayManager *manager, NaTrayManagerChild *child) { char *retval = NULL; #ifdef GDK_WINDOWING_X11 GdkDisplay *display; Window *child_window; Atom utf8_string, atom, type; int result; int format; gulong nitems; gulong bytes_after; gchar *val; g_return_val_if_fail (NA_IS_TRAY_MANAGER (manager), NULL); g_return_val_if_fail (GTK_IS_SOCKET (child), NULL); display = gdk_screen_get_display (manager->screen); child_window = g_object_get_data (G_OBJECT (child), "na-tray-child-window"); utf8_string = gdk_x11_get_xatom_by_name_for_display (display, "UTF8_STRING"); atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_NAME"); gdk_error_trap_push (); result = XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), *child_window, atom, 0, G_MAXLONG, False, utf8_string, &type, &format, &nitems, &bytes_after, (guchar **)&val); if (gdk_error_trap_pop () || result != Success) return NULL; if (type != utf8_string || format != 8 || nitems == 0) { if (val) XFree (val); return NULL; } if (!g_utf8_validate (val, nitems, NULL)) { XFree (val); return NULL; } retval = g_strndup (val, nitems); XFree (val); #endif return retval; }
/* on_screen_changed */ static void _on_screen_changed(GtkWidget * widget, GdkScreen * previous, gpointer data) { Close * close = data; GdkWindow * window; GdkEventMask events; #ifdef DEBUG fprintf(stderr, "DEBUG: %s()\n", __func__); #endif close->screen = gtk_widget_get_screen(widget); close->display = gdk_screen_get_display(close->screen); close->root = gdk_screen_get_root_window(close->screen); close->panel = ((window = gtk_widget_get_parent_window(widget)) != NULL) ? GDK_WINDOW_XID(window) : None; events = gdk_window_get_events(close->root); gdk_window_set_events(close->root, events | GDK_PROPERTY_CHANGE_MASK); gdk_window_add_filter(close->root, _on_filter, close); close->atom_active = gdk_x11_get_xatom_by_name_for_display( close->display, "_NET_ACTIVE_WINDOW"); close->atom_close = gdk_x11_get_xatom_by_name_for_display( close->display, "_NET_CLOSE_WINDOW"); _close_do(close); }
/* initialize info->im */ static void xim_info_try_im (GtkOXIMInfo *info) { GdkScreen *screen = info->screen; GdkDisplay *display = gdk_screen_get_display (screen); g_assert (info->im == NULL); if (info->reconnecting) return; if (XSupportsLocale ()) { if (!XSetLocaleModifiers ("@im=oxim")) g_warning ("Unable to set locale modifiers with XSetLocaleModifiers()"); info->im = XOpenIM (GDK_DISPLAY_XDISPLAY (display), NULL, NULL, NULL); if (!info->im) { XRegisterIMInstantiateCallback (GDK_DISPLAY_XDISPLAY(display), NULL, NULL, NULL, xim_instantiate_callback, (XPointer)info); info->reconnecting = TRUE; return; } setup_im (info); } }
static void panel_menu_item_activate_switch_user (GtkWidget *menuitem, gpointer user_data) { GdkScreen *screen; GAppInfo *app_info; if (panel_lockdown_get_disable_switch_user_s ()) return; screen = gtk_widget_get_screen (GTK_WIDGET (menuitem)); app_info = g_app_info_create_from_commandline (GDM_FLEXISERVER_COMMAND " " GDM_FLEXISERVER_ARGS, GDM_FLEXISERVER_COMMAND, G_APP_INFO_CREATE_NONE, NULL); if (app_info) { GdkAppLaunchContext *launch_context; GdkDisplay *display; display = gdk_screen_get_display (screen); launch_context = gdk_display_get_app_launch_context (display); gdk_app_launch_context_set_screen (launch_context, screen); g_app_info_launch (app_info, NULL, G_APP_LAUNCH_CONTEXT (launch_context), NULL); g_object_unref (launch_context); g_object_unref (app_info); } }
void eel_gnome_open_terminal_on_screen (const char *command, GdkScreen *screen) { GAppInfo *app; GdkAppLaunchContext *ctx; GError *error = NULL; GdkDisplay *display; app = g_app_info_create_from_commandline (command, NULL, G_APP_INFO_CREATE_NEEDS_TERMINAL, &error); if (app != NULL && screen != NULL) { display = gdk_screen_get_display (screen); ctx = gdk_display_get_app_launch_context (display); gdk_app_launch_context_set_screen (ctx, screen); g_app_info_launch (app, NULL, G_APP_LAUNCH_CONTEXT (ctx), &error); g_object_unref (app); g_object_unref (ctx); } if (error != NULL) { g_message ("Could not start application on terminal: %s", error->message); g_error_free (error); } }
static gboolean panel_app_info_launch_uris (GAppInfo *appinfo, GList *uris, GdkScreen *screen, guint32 timestamp, GError **error) { GdkAppLaunchContext *context; GError *local_error; GdkDisplay *display; g_return_val_if_fail (G_IS_APP_INFO (appinfo), FALSE); g_return_val_if_fail (GDK_IS_SCREEN (screen), FALSE); g_return_val_if_fail (error == NULL || *error == NULL, FALSE); display = gdk_screen_get_display (screen); context = gdk_display_get_app_launch_context (display); gdk_app_launch_context_set_screen (context, screen); gdk_app_launch_context_set_timestamp (context, timestamp); local_error = NULL; g_app_info_launch_uris (appinfo, uris, (GAppLaunchContext *) context, &local_error); g_object_unref (context); return _panel_launch_handle_error (g_app_info_get_name (appinfo), screen, local_error, error); }
gboolean panel_app_info_launch_uris (GAppInfo *appinfo, GList *uris, GdkScreen *screen, guint32 timestamp, GError **error) { GdkAppLaunchContext *context; GError *local_error; GdkDisplay *display; g_return_val_if_fail (G_IS_DESKTOP_APP_INFO (appinfo), FALSE); g_return_val_if_fail (GDK_IS_SCREEN (screen), FALSE); g_return_val_if_fail (error == NULL || *error == NULL, FALSE); display = gdk_screen_get_display (screen); context = gdk_display_get_app_launch_context (display); gdk_app_launch_context_set_screen (context, screen); gdk_app_launch_context_set_timestamp (context, timestamp); local_error = NULL; g_desktop_app_info_launch_uris_as_manager ((GDesktopAppInfo*)appinfo, uris, (GAppLaunchContext *) context, G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD, NULL, NULL, gather_pid_callback, appinfo, &local_error); g_object_unref (context); return _panel_launch_handle_error (g_app_info_get_name ((GAppInfo*) appinfo), screen, local_error, error); }
static void add_startup_timeout (GdkScreen *screen, const char *startup_id) { StartupTimeoutData *data; StartupNotificationData *sn_data; data = g_object_get_data (G_OBJECT (screen), "appinfo-startup-data"); if (data == NULL) { data = g_new (StartupTimeoutData, 1); data->contexts = NULL; data->timeout_id = 0; g_object_set_data_full (G_OBJECT (screen), "appinfo-startup-data", data, free_startup_timeout); } sn_data = g_new (StartupNotificationData, 1); sn_data->display = g_object_ref (gdk_screen_get_display (screen)); sn_data->startup_id = g_strdup (startup_id); g_get_current_time (&sn_data->time); data->contexts = g_slist_prepend (data->contexts, sn_data); if (data->timeout_id == 0) data->timeout_id = g_timeout_add_seconds (STARTUP_TIMEOUT_LENGTH_SECONDS, startup_timeout, data); }
gboolean hippo_ui_get_pointer_position (HippoUI *ui, int *x_p, int *y_p) { GdkScreen *screen; GdkScreen *pointer_screen; int x, y; gtk_status_icon_get_geometry(GTK_STATUS_ICON(ui->icon), &screen, NULL, NULL); gdk_display_get_pointer(gdk_screen_get_display(screen), &pointer_screen, &x, &y, NULL); if (pointer_screen != screen) { x = 0; y = 0; } if (x_p) *x_p = x; if (y_p) *y_p = y; return pointer_screen == screen; }
static void launch_application_from_command_internal (const gchar *full_command, GdkScreen *screen, gboolean use_terminal) { GAppInfo *app; GdkAppLaunchContext *ctx; GdkDisplay *display; if (use_terminal) { eel_gnome_open_terminal_on_screen (full_command, screen); } else { app = g_app_info_create_from_commandline (full_command, NULL, 0, NULL); if (app != NULL) { display = gdk_screen_get_display (screen); ctx = gdk_display_get_app_launch_context (display); gdk_app_launch_context_set_screen (ctx, screen); g_app_info_launch (app, NULL, G_APP_LAUNCH_CONTEXT (ctx), NULL); g_object_unref (app); g_object_unref (ctx); } } }
//______________________________________________ void ShadowHelper::reset( void ) { #if OXYGEN_DEBUG std::cerr << "Oxygen::ShadowHelper::reset" << std::endl; #endif #ifdef GDK_WINDOWING_X11 GdkScreen* screen = gdk_screen_get_default(); if( !screen ) return; Display* display( GDK_DISPLAY_XDISPLAY( gdk_screen_get_display( screen ) ) ); // round pixmaps for( PixmapList::const_iterator iter = _roundPixmaps.begin(); iter != _roundPixmaps.end(); ++iter ) { XFreePixmap(display, *iter); } // square pixmaps for( PixmapList::const_iterator iter = _squarePixmaps.begin(); iter != _squarePixmaps.end(); ++iter ) { XFreePixmap(display, *iter); } #endif // clear arrays _roundPixmaps.clear(); _squarePixmaps.clear(); // reset size _size = 0; }
/* title_on_screen_changed */ static void _title_on_screen_changed(GtkWidget * widget, GdkScreen * previous, gpointer data) { Title * title = data; GdkEventMask events; #ifdef DEBUG fprintf(stderr, "DEBUG: %s()\n", __func__); #endif if(title->root != NULL) gdk_window_remove_filter(title->root, _title_on_filter, title); title->screen = gtk_widget_get_screen(widget); title->display = gdk_screen_get_display(title->screen); title->root = gdk_screen_get_root_window(title->screen); events = gdk_window_get_events(title->root); gdk_window_set_events(title->root, events | GDK_PROPERTY_CHANGE_MASK); gdk_window_add_filter(title->root, _title_on_filter, title); title->atom_active = gdk_x11_get_xatom_by_name_for_display( title->display, "_NET_ACTIVE_WINDOW"); title->atom_name = gdk_x11_get_xatom_by_name_for_display( title->display, "_NET_WM_NAME"); title->atom_utf8_string = gdk_x11_get_xatom_by_name_for_display( title->display, "UTF8_STRING"); title->atom_visible_name = gdk_x11_get_xatom_by_name_for_display( title->display, "_NET_WM_VISIBLE_NAME"); _title_do(title); }
void start_recording(GtkWidget *widget, gpointer data) { GdkNativeWindow native; GdkDisplay *display; GdkRectangle rect; if(is_recording) return; screen = gtk_widget_get_screen(widget); if (screen == NULL) { screen = gdk_screen_get_default (); } native = select_window(screen); display = gdk_screen_get_display (screen); window = gdk_window_foreign_new_for_display (display, native); gdk_drawable_get_size (GDK_DRAWABLE (window), &rect.width, &rect.height); /* creating flv und screenVideo instances */ flv = newFLVStream(FLVVERSION_1, FLVFLAG_VIDEO); video = newScreenVideo(rect.width, rect.height, 64); printf("video width: %i, height: %i\n", rect.width, rect.height); /* capture timer */ g_timeout_add ( 1000 / FRAMERATE, next_capture, NULL); is_recording = 1; }
static int get_current_desktop (GdkScreen *screen) { Display *display; Window win; Atom current_desktop, type; int format; unsigned long n_items, bytes_after; unsigned char *data_return = NULL; int workspace = 0; display = GDK_DISPLAY_XDISPLAY (gdk_screen_get_display (screen)); win = XRootWindow (display, GDK_SCREEN_XNUMBER (screen)); current_desktop = XInternAtom (display, "_NET_CURRENT_DESKTOP", True); XGetWindowProperty (display, win, current_desktop, 0, G_MAXLONG, False, XA_CARDINAL, &type, &format, &n_items, &bytes_after, &data_return); if (type == XA_CARDINAL && format == 32 && n_items > 0) workspace = (int) data_return[0]; if (data_return) XFree (data_return); return workspace; }
static Bool gdk_xsettings_watch_cb (Window window, Bool is_start, long mask, void *cb_data) { GdkWindow *gdkwin; GdkScreen *screen = cb_data; gdkwin = gdk_x11_window_lookup_for_display (gdk_screen_get_display (screen), window); if (is_start) { if (gdkwin) g_object_ref (gdkwin); else { gdkwin = gdk_x11_window_foreign_new_for_display (gdk_screen_get_display (screen), window); /* gdk_window_foreign_new_for_display() can fail and return NULL if the * window has already been destroyed. */ if (!gdkwin) return False; } gdk_window_add_filter (gdkwin, gdk_xsettings_client_event_filter, screen); } else { if (!gdkwin) { /* gdkwin should not be NULL here, since if starting the watch succeeded * we have a reference on the window. It might mean that the caller didn't * remove the watch when it got a DestroyNotify event. Or maybe the * caller ignored the return value when starting the watch failed. */ g_warning ("gdk_xsettings_watch_cb(): Couldn't find window to unwatch"); return False; } gdk_window_remove_filter (gdkwin, gdk_xsettings_client_event_filter, screen); g_object_unref (gdkwin); } return True; }
/** * mate_rr_screen_refresh * @screen: a #MateRRScreen * @error: location to store error, or %NULL * * Refreshes the screen configuration, and calls the screen's callback if it * exists and if the screen's configuration changed. * * Return value: TRUE if the screen's configuration changed; otherwise, the * function returns FALSE and a NULL error if the configuration didn't change, * or FALSE and a non-NULL error if there was an error while refreshing the * configuration. */ gboolean mate_rr_screen_refresh (MateRRScreen *screen, GError **error) { gboolean refreshed; g_return_val_if_fail (error == NULL || *error == NULL, FALSE); gdk_x11_display_grab (gdk_screen_get_display (screen->gdk_screen)); refreshed = screen_update (screen, FALSE, TRUE, error); force_timestamp_update (screen); /* this is to keep other clients from thinking that the X server re-detected things by itself - bgo#621046 */ gdk_x11_display_ungrab (gdk_screen_get_display (screen->gdk_screen)); return refreshed; }
static GdkMonitor * get_monitor (GdkScreen *screen, gint n) { GdkDisplay *display; display = gdk_screen_get_display (screen); return gdk_display_get_monitor (display, n); }
static guint32 get_keyboard_lock_modifiers(void) { guint32 modifiers = 0; #if GTK_CHECK_VERSION(3,18,0) GdkKeymap *keyboard = gdk_keymap_get_default(); if (gdk_keymap_get_caps_lock_state(keyboard)) { modifiers |= SPICE_INPUTS_CAPS_LOCK; } if (gdk_keymap_get_num_lock_state(keyboard)) { modifiers |= SPICE_INPUTS_NUM_LOCK; } if (gdk_keymap_get_scroll_lock_state(keyboard)) { modifiers |= SPICE_INPUTS_SCROLL_LOCK; } #else #if HAVE_X11_XKBLIB_H Display *x_display = NULL; XKeyboardState keyboard_state; GdkScreen *screen = gdk_screen_get_default(); if (!GDK_IS_X11_DISPLAY(gdk_screen_get_display(screen))) { SPICE_DEBUG("FIXME: gtk backend is not X11"); return 0; } x_display = GDK_SCREEN_XDISPLAY(screen); XGetKeyboardControl(x_display, &keyboard_state); if (keyboard_state.led_mask & 0x01) { modifiers |= SPICE_INPUTS_CAPS_LOCK; } if (keyboard_state.led_mask & 0x02) { modifiers |= SPICE_INPUTS_NUM_LOCK; } if (keyboard_state.led_mask & 0x04) { modifiers |= SPICE_INPUTS_SCROLL_LOCK; } #elif defined(G_OS_WIN32) if (GetKeyState(VK_CAPITAL) & 1) { modifiers |= SPICE_INPUTS_CAPS_LOCK; } if (GetKeyState(VK_NUMLOCK) & 1) { modifiers |= SPICE_INPUTS_NUM_LOCK; } if (GetKeyState(VK_SCROLL) & 1) { modifiers |= SPICE_INPUTS_SCROLL_LOCK; } #else g_warning("get_keyboard_lock_modifiers not implemented"); #endif // HAVE_X11_XKBLIB_H #endif // GTK_CHECK_VERSION(3,18,0) return modifiers; }
static gchar * gdk_x11_screen_make_display_name (GdkScreen *screen) { const gchar *old_display; old_display = gdk_display_get_name (gdk_screen_get_display (screen)); return substitute_screen_number (old_display, gdk_screen_get_number (screen)); }
/** * gdk_screen_get_n_monitors: * @screen: a #GdkScreen * * Returns the number of monitors which @screen consists of. * * Returns: number of monitors which @screen consists of * * Since: 2.2 */ gint gdk_screen_get_n_monitors (GdkScreen *screen) { GdkDisplay *display; g_return_val_if_fail (GDK_IS_SCREEN (screen), 0); display = gdk_screen_get_display (screen); return gdk_display_get_n_monitors (display); }
/** * caja_launch_application_from_command: * * Fork off a process to launch an application with a given uri as * a parameter. * * @command_string: The application to be launched, with any desired * command-line options. * @...: Passed as parameters to the application after quoting each of them. */ void caja_launch_application_from_command (GdkScreen *screen, const char *name, const char *command_string, gboolean use_terminal, ...) { char *full_command, *tmp; char *quoted_parameter; char *parameter; va_list ap; full_command = g_strdup (command_string); va_start (ap, use_terminal); while ((parameter = va_arg (ap, char *)) != NULL) { quoted_parameter = g_shell_quote (parameter); tmp = g_strconcat (full_command, " ", quoted_parameter, NULL); g_free (quoted_parameter); g_free (full_command); full_command = tmp; } va_end (ap); if (use_terminal) { eel_mate_open_terminal_on_screen (full_command, screen); } else { GdkAppLaunchContext *launch_context; GdkDisplay *display; GAppInfo *app_info = NULL; app_info = g_app_info_create_from_commandline (full_command, NULL, G_APP_INFO_CREATE_NONE, NULL); if (app_info != NULL) { display = gdk_screen_get_display (screen); launch_context = gdk_display_get_app_launch_context (display); gdk_app_launch_context_set_screen (launch_context, screen); g_app_info_launch (app_info, NULL, G_APP_LAUNCH_CONTEXT (launch_context), NULL); g_object_unref (launch_context); g_object_unref (app_info); } } g_free (full_command); }
/** * cinnamon_app_launch: * @timestamp: Event timestamp, or 0 for current event timestamp * @uris: (element-type utf8): List of uris to pass to application * @workspace: Start on this workspace, or -1 for default * @startup_id: (out): Returned startup notification ID, or %NULL if none * @error: A #GError */ gboolean cinnamon_app_launch (CinnamonApp *app, guint timestamp, GList *uris, int workspace, char **startup_id, GError **error) { GDesktopAppInfo *gapp; GdkAppLaunchContext *context; gboolean ret; CinnamonGlobal *global; MetaScreen *screen; GdkDisplay *gdisplay; if (startup_id) *startup_id = NULL; if (app->entry == NULL) { MetaWindow *window = window_backed_app_get_window (app); /* We can't pass URIs into a window; shouldn't hit this * code path. If we do, fix the caller to disallow it. */ g_return_val_if_fail (uris == NULL, TRUE); meta_window_activate (window, timestamp); return TRUE; } global = cinnamon_global_get (); screen = cinnamon_global_get_screen (global); gdisplay = gdk_screen_get_display (cinnamon_global_get_gdk_screen (global)); if (timestamp == 0) timestamp = cinnamon_global_get_current_time (global); if (workspace < 0) workspace = meta_screen_get_active_workspace_index (screen); context = gdk_display_get_app_launch_context (gdisplay); gdk_app_launch_context_set_timestamp (context, timestamp); gdk_app_launch_context_set_desktop (context, workspace); gapp = gmenu_tree_entry_get_app_info (app->entry); ret = g_desktop_app_info_launch_uris_as_manager (gapp, uris, G_APP_LAUNCH_CONTEXT (context), G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL, NULL, NULL, _gather_pid_callback, app, error); g_object_unref (context); return ret; }
EggTrayIcon * egg_tray_icon_new_for_xscreen (Screen *xscreen, const char *name) { EggTrayIcon *icon; char buffer[256]; GdkWindow *root_window; g_return_val_if_fail (xscreen != NULL, NULL); icon = g_object_new (EGG_TYPE_TRAY_ICON, NULL); gtk_window_set_title (GTK_WINDOW (icon), name); #if HAVE_GTK_MULTIHEAD /* FIXME: this code does not compile, screen is undefined. Now try * getting the GdkScreen from xscreen (:. Dunno how to solve this * (there is prolly some easy way I cant think of right now) */ gtk_plug_construct_for_display (GTK_PLUG (icon), gdk_screen_get_display (screen), 0); #else gtk_plug_construct (GTK_PLUG (icon), 0); #endif gtk_widget_realize (GTK_WIDGET (icon)); /* Now see if there's a manager window around */ g_snprintf (buffer, sizeof (buffer), "_NET_SYSTEM_TRAY_S%d", XScreenNumberOfScreen (xscreen)); icon->selection_atom = XInternAtom (DisplayOfScreen (xscreen), buffer, False); icon->manager_atom = XInternAtom (DisplayOfScreen (xscreen), "MANAGER", False); icon->system_tray_opcode_atom = XInternAtom (DisplayOfScreen (xscreen), "_NET_SYSTEM_TRAY_OPCODE", False); egg_tray_icon_update_manager_window (icon); #if HAVE_GTK_MULTIHEAD root_window = gdk_screen_get_root_window (gtk_widget_get_screen (screen)); #else root_window = gdk_window_lookup (gdk_x11_get_default_root_xwindow ()); #endif /* Add a root window filter so that we get changes on MANAGER */ gdk_window_add_filter (root_window, egg_tray_icon_manager_filter, icon); return icon; }