本文整理汇总了C++中GDK_DISPLAY_XDISPLAY函数的典型用法代码示例。如果您正苦于以下问题:C++ GDK_DISPLAY_XDISPLAY函数的具体用法?C++ GDK_DISPLAY_XDISPLAY怎么用?C++ GDK_DISPLAY_XDISPLAY使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GDK_DISPLAY_XDISPLAY函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: gdk_event_source_translate_event
static GdkEvent *
gdk_event_source_translate_event (GdkEventSource *event_source,
XEvent *xevent)
{
GdkEvent *event = gdk_event_new (GDK_NOTHING);
GdkFilterReturn result = GDK_FILTER_CONTINUE;
GdkEventTranslator *event_translator;
GdkWindow *filter_window;
Display *dpy;
dpy = GDK_DISPLAY_XDISPLAY (event_source->display);
#ifdef HAVE_XGENERICEVENTS
/* Get cookie data here so it's available
* to every event translator and event filter.
*/
if (xevent->type == GenericEvent)
XGetEventData (dpy, &xevent->xcookie);
#endif
filter_window = gdk_event_source_get_filter_window (event_source, xevent,
&event_translator);
if (filter_window)
event->any.window = g_object_ref (filter_window);
/* Run default filters */
if (_gdk_default_filters)
{
/* Apply global filters */
result = gdk_event_apply_filters (xevent, event, NULL);
}
if (result == GDK_FILTER_CONTINUE &&
filter_window && filter_window->filters)
{
/* Apply per-window filters */
result = gdk_event_apply_filters (xevent, event, filter_window);
}
if (result != GDK_FILTER_CONTINUE)
{
#ifdef HAVE_XGENERICEVENTS
if (xevent->type == GenericEvent)
XFreeEventData (dpy, &xevent->xcookie);
#endif
if (result == GDK_FILTER_REMOVE)
{
gdk_event_free (event);
return NULL;
}
else /* GDK_FILTER_TRANSLATE */
return event;
}
gdk_event_free (event);
event = NULL;
if (event_translator)
{
/* Event translator was gotten before in get_filter_window() */
event = _gdk_x11_event_translator_translate (event_translator,
event_source->display,
xevent);
}
else
{
GList *list = event_source->translators;
while (list && !event)
{
GdkEventTranslator *translator = list->data;
list = list->next;
event = _gdk_x11_event_translator_translate (translator,
event_source->display,
xevent);
}
}
if (event &&
(event->type == GDK_ENTER_NOTIFY ||
event->type == GDK_LEAVE_NOTIFY) &&
event->crossing.window != NULL)
{
/* Handle focusing (in the case where no window manager is running */
handle_focus_change (&event->crossing);
}
#ifdef HAVE_XGENERICEVENTS
if (xevent->type == GenericEvent)
XFreeEventData (dpy, &xevent->xcookie);
#endif
return event;
}
示例2: update_window_decoration_size
gboolean
update_window_decoration_size (WnckWindow *win)
{
decor_t *d;
cairo_surface_t *surface, *buffer_surface = NULL;
Picture picture;
Display *xdisplay;
XRenderPictFormat *format;
if (win == NULL)
return FALSE;
d = g_object_get_data (G_OBJECT (win), "decor");
if (!d->decorated)
return FALSE;
xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
gdk_error_trap_push ();
/* Get the correct depth for the frame window in reparenting mode, otherwise
* enforce 32 */
if (d->frame_window)
surface = create_native_surface_and_wrap (d->width, d->height, d->frame->style_window_rgb);
else
surface = create_native_surface_and_wrap (d->width, d->height, d->frame->style_window_rgba);
gdk_flush ();
/* Handle failure */
if (!surface || gdk_error_trap_pop ())
{
if (surface)
cairo_surface_destroy (surface);
return FALSE;
}
gdk_error_trap_push ();
if (d->frame_window)
buffer_surface = create_surface (d->width, d->height, d->frame->style_window_rgb);
else
buffer_surface = create_surface (d->width, d->height, d->frame->style_window_rgba);
gdk_flush ();
/* Handle failure */
if (!buffer_surface || gdk_error_trap_pop ())
{
if (buffer_surface)
cairo_surface_destroy (buffer_surface);
cairo_surface_destroy (surface);
return FALSE;
}
/* Create XRender context */
format = get_format_for_surface (d, buffer_surface);
picture = XRenderCreatePicture (xdisplay, cairo_xlib_surface_get_drawable (buffer_surface),
format, 0, NULL);
/* Destroy the old pixmaps and pictures */
if (d->surface)
cairo_surface_destroy (d->surface);
if (d->x11Pixmap)
decor_post_delete_pixmap (xdisplay,
wnck_window_get_xid (d->win),
d->x11Pixmap);
if (d->buffer_surface)
cairo_surface_destroy (d->buffer_surface);
if (d->picture)
XRenderFreePicture (xdisplay, d->picture);
if (d->cr)
cairo_destroy (d->cr);
/* Assign new pixmaps and pictures */
d->surface = surface;
d->x11Pixmap = cairo_xlib_surface_get_drawable (d->surface);
d->buffer_surface = buffer_surface;
d->cr = cairo_create (surface);
d->picture = picture;
d->prop_xid = wnck_window_get_xid (win);
update_window_decoration_name (win);
/* Redraw decoration on idle */
queue_decor_draw (d);
return TRUE;
}
示例3: main
int
main (int argc, char **argv)
{
int i;
char **argv_copy;
int argc_copy;
const char *startup_id, *display_name, *home_dir;
GdkDisplay *display;
TerminalOptions *options;
GError *error = NULL;
char *working_directory;
int ret = EXIT_SUCCESS;
setlocale (LC_ALL, "");
bindtextdomain (GETTEXT_PACKAGE, TERM_LOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain (GETTEXT_PACKAGE);
_terminal_debug_init ();
/* Make a NULL-terminated copy since we may need it later */
argv_copy = g_new (char *, argc + 1);
for (i = 0; i < argc; ++i)
argv_copy [i] = argv [i];
argv_copy [i] = NULL;
argc_copy = argc;
startup_id = g_getenv ("DESKTOP_STARTUP_ID");
working_directory = g_get_current_dir ();
/* Now change directory to $HOME so we don't prevent unmounting, e.g. if the
* factory is started by caja-open-terminal. See bug #565328.
* On failure back to /.
*/
home_dir = g_get_home_dir ();
if (home_dir == NULL || chdir (home_dir) < 0)
(void) chdir ("/");
options = terminal_options_parse (working_directory,
NULL,
startup_id,
NULL,
FALSE,
FALSE,
&argc, &argv,
&error,
gtk_get_option_group (TRUE),
egg_sm_client_get_option_group (),
NULL);
g_free (working_directory);
if (options == NULL)
{
g_printerr (_("Failed to parse arguments: %s\n"), error->message);
g_error_free (error);
exit (EXIT_FAILURE);
}
g_set_application_name (_("Terminal"));
/* Unset the these env variables, so they doesn't end up
* in the factory's env and thus in the terminals' envs.
*/
g_unsetenv ("DESKTOP_STARTUP_ID");
g_unsetenv ("GIO_LAUNCHED_DESKTOP_FILE_PID");
g_unsetenv ("GIO_LAUNCHED_DESKTOP_FILE");
display = gdk_display_get_default ();
display_name = gdk_display_get_name (display);
options->display_name = g_strdup (display_name);
if (options->startup_id == NULL)
{
/* Create a fake one containing a timestamp that we can use */
Time timestamp;
timestamp = slowly_and_stupidly_obtain_timestamp (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()));
options->startup_id = g_strdup_printf ("_TIME%lu", timestamp);
}
if (options->use_factory)
{
OwnData *data;
guint owner_id;
data = g_new (OwnData, 1);
data->factory_name = get_factory_name_for_display (display_name);
data->options = options;
data->exit_code = -1;
data->argv = argv_copy;
data->argc = argc_copy;
gtk_init(&argc, &argv);
options->initial_workspace = get_initial_workspace ();
owner_id = g_bus_own_name (G_BUS_TYPE_SESSION,
//.........这里部分代码省略.........
示例4: _xim_init_IMdkit
static void
_xim_init_IMdkit ()
{
#if 0
XIMStyle ims_styles_overspot [] = {
XIMPreeditPosition | XIMStatusNothing,
XIMPreeditNothing | XIMStatusNothing,
XIMPreeditPosition | XIMStatusCallbacks,
XIMPreeditNothing | XIMStatusCallbacks,
0
};
#endif
XIMStyle ims_styles_onspot [] = {
XIMPreeditPosition | XIMStatusNothing,
XIMPreeditCallbacks | XIMStatusNothing,
XIMPreeditNothing | XIMStatusNothing,
XIMPreeditPosition | XIMStatusCallbacks,
XIMPreeditCallbacks | XIMStatusCallbacks,
XIMPreeditNothing | XIMStatusCallbacks,
0
};
XIMEncoding ims_encodings[] = {
"COMPOUND_TEXT",
0
};
GdkWindowAttr window_attr = {
.title = "ibus-xim",
.event_mask = GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK,
.wclass = GDK_INPUT_OUTPUT,
.window_type = GDK_WINDOW_TOPLEVEL,
.override_redirect = 1,
};
XIMStyles styles;
XIMEncodings encodings;
GdkWindow *win;
win = gdk_window_new (NULL, &window_attr, GDK_WA_TITLE);
styles.count_styles =
sizeof (ims_styles_onspot)/sizeof (XIMStyle) - 1;
styles.supported_styles = ims_styles_onspot;
encodings.count_encodings =
sizeof (ims_encodings)/sizeof (XIMEncoding) - 1;
encodings.supported_encodings = ims_encodings;
_xims = IMOpenIM(GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
IMModifiers, "Xi18n",
IMServerWindow, GDK_WINDOW_XWINDOW(win),
IMServerName, _server_name != NULL ? _server_name : "ibus",
IMLocale, _locale != NULL ? _locale : LOCALES_STRING,
IMServerTransport, "X/",
IMInputStyles, &styles,
IMEncodingList, &encodings,
IMProtocolHandler, ims_protocol_handler,
IMFilterEventMask, KeyPressMask | KeyReleaseMask,
NULL);
_init_ibus ();
if (!ibus_bus_is_connected (_bus)) {
g_warning ("Can not connect to ibus daemon");
exit (EXIT_FAILURE);
}
}
static void
_atexit_cb ()
{
if (_bus && ibus_bus_is_connected (_bus)) {
ibus_bus_exit(_bus, False);
}
}
static void
_sighandler (int sig)
{
exit(EXIT_FAILURE);
}
示例5: remmina_rdp_event_on_key
static gboolean remmina_rdp_event_on_key(GtkWidget* widget, GdkEventKey* event, RemminaProtocolWidget* gp)
{
GdkDisplay* display;
guint16 cooked_keycode;
rfContext* rfi;
RemminaPluginRdpEvent rdp_event;
rfi = GET_DATA(gp);
rdp_event.type = REMMINA_RDP_EVENT_TYPE_SCANCODE;
rdp_event.key_event.up = (event->type == GDK_KEY_PRESS ? False : True);
rdp_event.key_event.extended = False;
switch (event->keyval)
{
case GDK_KEY_Pause:
rdp_event.key_event.key_code = 0x1D;
rdp_event.key_event.up = False;
remmina_rdp_event_event_push(gp, &rdp_event);
rdp_event.key_event.key_code = 0x45;
rdp_event.key_event.up = False;
remmina_rdp_event_event_push(gp, &rdp_event);
rdp_event.key_event.key_code = 0x1D;
rdp_event.key_event.up = True;
remmina_rdp_event_event_push(gp, &rdp_event);
rdp_event.key_event.key_code = 0x45;
rdp_event.key_event.up = True;
remmina_rdp_event_event_push(gp, &rdp_event);
break;
default:
if (!rfi->use_client_keymap)
{
rdp_event.key_event.key_code = freerdp_keyboard_get_rdp_scancode_from_x11_keycode(event->hardware_keycode);
remmina_plugin_service->log_printf("[RDP]keyval=%04X keycode=%i scancode=%i extended=%i\n",
event->keyval, event->hardware_keycode, rdp_event.key_event.key_code, &rdp_event.key_event.extended);
}
else
{
//TODO: Port to GDK functions
display = gdk_display_get_default();
cooked_keycode = XKeysymToKeycode(GDK_DISPLAY_XDISPLAY(display), XKeycodeToKeysym(GDK_DISPLAY_XDISPLAY(display), event->hardware_keycode, 0));
rdp_event.key_event.key_code = freerdp_keyboard_get_rdp_scancode_from_x11_keycode(cooked_keycode);
remmina_plugin_service->log_printf("[RDP]keyval=%04X raw_keycode=%i cooked_keycode=%i scancode=%i extended=%i\n",
event->keyval, event->hardware_keycode, cooked_keycode, rdp_event.key_event.key_code, &rdp_event.key_event.extended);
}
if (rdp_event.key_event.key_code)
remmina_rdp_event_event_push(gp, &rdp_event);
break;
}
/* Register/unregister the pressed key */
if (rdp_event.key_event.key_code)
{
if (event->type == GDK_KEY_PRESS)
g_array_append_val(rfi->pressed_keys, rdp_event.key_event.key_code);
else
remmina_rdp_event_release_key(gp, rdp_event.key_event.key_code);
}
return TRUE;
}
示例6: gdk_property_get
gboolean
gdk_property_get (GdkWindow *window,
GdkAtom property,
GdkAtom type,
gulong offset,
gulong length,
gint pdelete,
GdkAtom *actual_property_type,
gint *actual_format_type,
gint *actual_length,
guchar **data)
{
GdkDisplay *display;
Atom ret_prop_type;
gint ret_format;
gulong ret_nitems;
gulong ret_bytes_after;
gulong get_length;
gulong ret_length;
guchar *ret_data;
Atom xproperty;
Atom xtype;
int res;
g_return_val_if_fail (!window || GDK_WINDOW_IS_X11 (window), FALSE);
if (!window)
{
GdkScreen *screen = gdk_screen_get_default ();
window = gdk_screen_get_root_window (screen);
GDK_NOTE (MULTIHEAD, g_message ("gdk_property_get(): window is NULL\n"));
}
else if (!GDK_WINDOW_IS_X11 (window))
return FALSE;
if (GDK_WINDOW_DESTROYED (window))
return FALSE;
display = gdk_drawable_get_display (window);
xproperty = gdk_x11_atom_to_xatom_for_display (display, property);
if (type == GDK_NONE)
xtype = AnyPropertyType;
else
xtype = gdk_x11_atom_to_xatom_for_display (display, type);
ret_data = NULL;
/*
* Round up length to next 4 byte value. Some code is in the (bad?)
* habit of passing G_MAXLONG as the length argument, causing an
* overflow to negative on the add. In this case, we clamp the
* value to G_MAXLONG.
*/
get_length = length + 3;
if (get_length > G_MAXLONG)
get_length = G_MAXLONG;
/* To fail, either the user passed 0 or G_MAXULONG */
get_length = get_length / 4;
if (get_length == 0)
{
g_warning ("gdk_propery-get(): invalid length 0");
return FALSE;
}
res = XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display),
GDK_WINDOW_XWINDOW (window), xproperty,
offset, get_length, pdelete,
xtype, &ret_prop_type, &ret_format,
&ret_nitems, &ret_bytes_after,
&ret_data);
if (res != Success || (ret_prop_type == None && ret_format == 0))
{
return FALSE;
}
if (actual_property_type)
*actual_property_type = gdk_x11_xatom_to_atom_for_display (display, ret_prop_type);
if (actual_format_type)
*actual_format_type = ret_format;
if ((xtype != AnyPropertyType) && (ret_prop_type != xtype))
{
XFree (ret_data);
g_warning ("Couldn't match property type %s to %s\n",
gdk_x11_get_xatom_name_for_display (display, ret_prop_type),
gdk_x11_get_xatom_name_for_display (display, xtype));
return FALSE;
}
/* FIXME: ignoring bytes_after could have very bad effects */
if (data)
{
if (ret_prop_type == XA_ATOM ||
ret_prop_type == gdk_x11_get_xatom_by_name_for_display (display, "ATOM_PAIR"))
{
/*
//.........这里部分代码省略.........
示例7: GDK_DISPLAY_XDISPLAY
void *wxGetDisplay()
{
return GDK_DISPLAY_XDISPLAY(gdk_window_get_display(wxGetTopLevelGDK()));
}
示例8: main
int main (int argc, char **argv)
{
gboolean supports_xinput;
gboolean has_touchpad, has_touchscreen, has_trackball;
XDeviceInfo *device_info;
gint n_devices, opcode;
guint i;
gtk_init (&argc, &argv);
supports_xinput = supports_xinput_devices ();
if (supports_xinput) {
g_print ("Supports XInput:\t\t\tyes\n");
} else {
g_print ("Supports XInput:\t\t\tno\n");
return 0;
}
supports_xinput = supports_xinput2_devices (&opcode);
if (supports_xinput) {
g_print ("Supports XInput2:\t\t\tyes (opcode: %d)\n", opcode);
} else {
g_print ("Supports XInput2:\t\t\tno\n");
return 0;
}
has_touchpad = touchpad_is_present ();
g_print ("Has touchpad:\t\t\t\t%s\n", has_touchpad ? "yes" : "no");
has_touchscreen = touchscreen_is_present ();
g_print ("Has touchscreen:\t\t\t%s\n", has_touchscreen ? "yes" : "no");
has_trackball = trackball_is_present ();
g_print ("Has trackball:\t\t\t\t%s\n", has_trackball ? "yes" : "no");
device_info = XListInputDevices (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), &n_devices);
if (device_info == NULL) {
g_warning ("Has no input devices");
return 1;
}
print_disabled_devices ();
for (i = 0; i < n_devices; i++) {
XDevice *device;
if (device_info_is_touchscreen (&device_info[i])) {
g_print ("Device %d is touchscreen:\t\t%s\n", (int) device_info[i].id, "yes");
continue;
}
if (device_info_is_trackball (&device_info[i])) {
g_print ("Device %d is trackball:\t\t\t%s\n", (int) device_info[i].id, "yes");
continue;
}
if (device_info_is_tablet (&device_info[i])) {
g_print ("Device %d is tablet:\t\t\t%s\n", (int) device_info[i].id, "yes");
continue;
}
gdk_error_trap_push ();
device = XOpenDevice (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), device_info[i].id);
if (gdk_error_trap_pop () || (device == NULL))
continue;
if (device_is_touchpad (device))
g_print ("Device %d is touchpad:\t\t%s\n", (int) device_info[i].id, "yes");
else {
int tool_id;
tool_id = xdevice_get_last_tool_id (device_info[i].id);
if (tool_id >= 0x0)
g_print ("Device %d is touchpad/touchscreen:\t%s (tool ID: 0x%x)\n", (int) device_info[i].id, "no", tool_id);
else
g_print ("Device %d is touchpad/touchscreen:\t%s\n", (int) device_info[i].id, "no");
}
XCloseDevice (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), device);
}
XFreeDeviceList (device_info);
return 0;
}
示例9: egg_tray_icon_send_message
guint
egg_tray_icon_send_message (EggTrayIcon *icon,
gint timeout,
const gchar *message,
gint len)
{
guint stamp;
g_return_val_if_fail (EGG_IS_TRAY_ICON (icon), 0);
g_return_val_if_fail (timeout >= 0, 0);
g_return_val_if_fail (message != NULL, 0);
if (icon->manager_window == None)
return 0;
if (len < 0)
len = strlen (message);
stamp = icon->stamp++;
/* Get ready to send the message */
egg_tray_icon_send_manager_message (icon, SYSTEM_TRAY_BEGIN_MESSAGE,
(Window)gtk_plug_xembed_get_id (GTK_PLUG_XEMBED (icon)),
timeout, len, stamp);
/* Now to send the actual message */
gdk_error_trap_push ();
while (len > 0)
{
XClientMessageEvent ev;
Display *xdisplay;
#if HAVE_GTK_MULTIHEAD
xdisplay = GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (GTK_WIDGET (icon)));
#else
xdisplay = gdk_display;
#endif
ev.type = ClientMessage;
ev.window = (Window)gtk_plug_xembed_get_id (GTK_PLUG_XEMBED (icon));
ev.format = 8;
ev.message_type = XInternAtom (xdisplay,
"_NET_SYSTEM_TRAY_MESSAGE_DATA", False);
if (len > 20)
{
memcpy (&ev.data, message, 20);
len -= 20;
message += 20;
}
else
{
memcpy (&ev.data, message, len);
len = 0;
}
XSendEvent (xdisplay,
icon->manager_window, False, StructureNotifyMask, (XEvent *)&ev);
XSync (xdisplay, False);
}
gdk_error_trap_pop ();
return stamp;
}
示例10: Init
nsresult
nsScreenManagerGtk :: Init()
{
#ifdef MOZ_X11
XineramaScreenInfo *screenInfo = nullptr;
int numScreens;
bool useXinerama = GDK_IS_X11_DISPLAY(gdk_display_get_default());
if (useXinerama && !mXineramalib) {
mXineramalib = PR_LoadLibrary("libXinerama.so.1");
if (!mXineramalib) {
mXineramalib = SCREEN_MANAGER_LIBRARY_LOAD_FAILED;
}
}
if (mXineramalib && mXineramalib != SCREEN_MANAGER_LIBRARY_LOAD_FAILED) {
_XnrmIsActive_fn _XnrmIsActive = (_XnrmIsActive_fn)
PR_FindFunctionSymbol(mXineramalib, "XineramaIsActive");
_XnrmQueryScreens_fn _XnrmQueryScreens = (_XnrmQueryScreens_fn)
PR_FindFunctionSymbol(mXineramalib, "XineramaQueryScreens");
// get the number of screens via xinerama
Display *display = GDK_DISPLAY_XDISPLAY(gdk_display_get_default());
if (_XnrmIsActive && _XnrmQueryScreens && _XnrmIsActive(display)) {
screenInfo = _XnrmQueryScreens(display, &numScreens);
}
}
// screenInfo == nullptr if either Xinerama couldn't be loaded or
// isn't running on the current display
if (!screenInfo || numScreens == 1) {
numScreens = 1;
#endif
RefPtr<nsScreenGtk> screen;
if (mCachedScreenArray.Count() > 0) {
screen = static_cast<nsScreenGtk*>(mCachedScreenArray[0]);
} else {
screen = new nsScreenGtk();
if (!screen || !mCachedScreenArray.AppendObject(screen)) {
return NS_ERROR_OUT_OF_MEMORY;
}
}
screen->Init(mRootWindow);
#ifdef MOZ_X11
}
// If Xinerama is enabled and there's more than one screen, fill
// in the info for all of the screens. If that's not the case
// then nsScreenGTK() defaults to the screen width + height
else {
#ifdef DEBUG
printf("Xinerama superpowers activated for %d screens!\n", numScreens);
#endif
for (int i = 0; i < numScreens; ++i) {
RefPtr<nsScreenGtk> screen;
if (mCachedScreenArray.Count() > i) {
screen = static_cast<nsScreenGtk*>(mCachedScreenArray[i]);
} else {
screen = new nsScreenGtk();
if (!screen || !mCachedScreenArray.AppendObject(screen)) {
return NS_ERROR_OUT_OF_MEMORY;
}
}
// initialize this screen object
screen->Init(&screenInfo[i]);
}
}
// Remove any screens that are no longer present.
while (mCachedScreenArray.Count() > numScreens) {
mCachedScreenArray.RemoveObjectAt(mCachedScreenArray.Count() - 1);
}
if (screenInfo) {
XFree(screenInfo);
}
#endif
return NS_OK;
}
示例11: _wnck_error_trap_pop
int
_wnck_error_trap_pop (void)
{
XSync (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), False);
return gdk_error_trap_pop ();
}
示例12: get_active_application_properties
/* 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)
//.........这里部分代码省略.........
示例13: poll_for_idleness
static gboolean
poll_for_idleness (void *data)
{
HippoIdleMonitor *monitor = data;
int i;
int n_screens;
unsigned long idle_time;
gboolean was_idle;
idle_time = G_MAXINT;
n_screens = gdk_display_get_n_screens(monitor->display);
for (i = 0; i < n_screens; ++i) {
int result;
GdkScreen *screen;
screen = gdk_display_get_screen(monitor->display, i);
result = XScreenSaverQueryInfo(GDK_DISPLAY_XDISPLAY(monitor->display),
GDK_SCREEN_XSCREEN(screen)->root,
monitor->info);
if (result == 0) {
g_warning("Failed to get idle time from screensaver extension");
break;
}
/* monitor->info->idle is time in milliseconds since last user interaction event */
idle_time = MIN(monitor->info->idle, idle_time);
}
was_idle = monitor->currently_idle;
/* If the idle time has gone down, there must have been activity since we last checked */
if (idle_time < monitor->last_idle) {
monitor->activity_time = get_time();
monitor->currently_idle = FALSE;
} else {
/* If no activity, see how long ago it was and count ourselves idle
* if it's been a short while. We keep this idle really short, since it
* simply results in keeping bubbles up; we want to do this if people
* just look away for a minute, really. It can be "more aggressive"
* about idle detection than a screensaver would be.
*/
GTime now = get_time();
if (now < monitor->activity_time) {
/* clock went backward... just "catch up"
* then wait until the idle timeout expires again
*/
monitor->activity_time = now;
} else if ((now - monitor->activity_time) > 120) { /* 120 = 2 minutes */
monitor->currently_idle = TRUE;
}
}
monitor->last_idle = idle_time;
if (was_idle != monitor->currently_idle) {
(* monitor->func) (monitor->currently_idle, monitor->data);
}
if (hippo_data_cache_get_application_usage_enabled(monitor->cache) && !monitor->currently_idle) {
update_application_info(monitor);
}
return TRUE;
}
示例14: gdk_check_xpending
static gboolean
gdk_check_xpending (GdkDisplay *display)
{
return XPending (GDK_DISPLAY_XDISPLAY (display));
}
示例15: GDK_DISPLAY_XDISPLAY
bool wxTopLevelWindowGTK::ShowFullScreen(bool show, long)
{
if (show == m_fsIsShowing)
return false; // return what?
m_fsIsShowing = show;
#ifdef GDK_WINDOWING_X11
Display* xdpy = GDK_DISPLAY_XDISPLAY(gtk_widget_get_display(m_widget));
Window xroot = GDK_WINDOW_XID(gtk_widget_get_root_window(m_widget));
wxX11FullScreenMethod method = wxGetFullScreenMethodX11(xdpy, (WXWindow)xroot);
// NB: gtk_window_fullscreen() uses freedesktop.org's WMspec extensions
// to switch to fullscreen, which is not always available. We must
// check if WM supports the spec and use legacy methods if it
// doesn't.
if ( method == wxX11_FS_WMSPEC )
#endif // GDK_WINDOWING_X11
{
if (show)
gtk_window_fullscreen( GTK_WINDOW( m_widget ) );
else
gtk_window_unfullscreen( GTK_WINDOW( m_widget ) );
}
#ifdef GDK_WINDOWING_X11
else
{
GdkWindow* window = gtk_widget_get_window(m_widget);
Window xid = GDK_WINDOW_XID(window);
if (show)
{
GetPosition( &m_fsSaveFrame.x, &m_fsSaveFrame.y );
GetSize( &m_fsSaveFrame.width, &m_fsSaveFrame.height );
GdkScreen* screen = gtk_widget_get_screen(m_widget);
const int screen_width = gdk_screen_get_width(screen);
const int screen_height = gdk_screen_get_height(screen);
gint client_x, client_y, root_x, root_y;
gint width, height;
m_fsSaveGdkFunc = m_gdkFunc;
m_fsSaveGdkDecor = m_gdkDecor;
m_gdkFunc = m_gdkDecor = 0;
gdk_window_set_decorations(window, (GdkWMDecoration)0);
gdk_window_set_functions(window, (GdkWMFunction)0);
gdk_window_get_origin(window, &root_x, &root_y);
gdk_window_get_geometry(window, &client_x, &client_y, &width, &height);
gdk_window_move_resize(
window, -client_x, -client_y, screen_width + 1, screen_height + 1);
wxSetFullScreenStateX11(xdpy,
(WXWindow)xroot,
(WXWindow)xid,
show, &m_fsSaveFrame, method);
}
else // hide
{
m_gdkFunc = m_fsSaveGdkFunc;
m_gdkDecor = m_fsSaveGdkDecor;
gdk_window_set_decorations(window, (GdkWMDecoration)m_gdkDecor);
gdk_window_set_functions(window, (GdkWMFunction)m_gdkFunc);
wxSetFullScreenStateX11(xdpy,
(WXWindow)xroot,
(WXWindow)xid,
show, &m_fsSaveFrame, method);
SetSize(m_fsSaveFrame.x, m_fsSaveFrame.y,
m_fsSaveFrame.width, m_fsSaveFrame.height);
}
}
#endif // GDK_WINDOWING_X11
// documented behaviour is to show the window if it's still hidden when
// showing it full screen
if (show)
Show();
return true;
}