gboolean meta_core_begin_grab_op (Display *xdisplay, Window frame_xwindow, MetaGrabOp op, gboolean pointer_already_grabbed, gboolean frame_action, int button, gulong modmask, guint32 timestamp, int root_x, int root_y) { MetaWindow *window = get_window (xdisplay, frame_xwindow); MetaDisplay *display; MetaScreen *screen; display = meta_display_for_x_display (xdisplay); screen = meta_display_screen_for_xwindow (display, frame_xwindow); g_assert (screen != NULL); return meta_display_begin_grab_op (display, screen, window, op, pointer_already_grabbed, frame_action, button, modmask, timestamp, root_x, root_y); }
void meta_core_lower_beneath_focus_window (Display *xdisplay, Window xwindow, guint32 timestamp) { XWindowChanges changes; MetaDisplay *display; MetaScreen *screen; MetaWindow *focus_window; display = meta_display_for_x_display (xdisplay); screen = meta_display_screen_for_xwindow (display, xwindow); focus_window = meta_stack_get_top (screen->stack); if (focus_window == NULL) return; changes.stack_mode = Below; changes.sibling = focus_window->frame ? focus_window->frame->xwindow : focus_window->xwindow; meta_error_trap_push (display); XConfigureWindow (xdisplay, xwindow, CWSibling | CWStackMode, &changes); meta_error_trap_pop (display, FALSE); }
void meta_core_lower_beneath_grab_window (Display *xdisplay, Window xwindow, guint32 timestamp) { XWindowChanges changes; MetaDisplay *display; MetaScreen *screen; MetaWindow *grab_window; display = meta_display_for_x_display (xdisplay); screen = meta_display_screen_for_xwindow (display, xwindow); grab_window = display->grab_window; if (grab_window == NULL) return; changes.stack_mode = Below; changes.sibling = grab_window->frame ? grab_window->frame->xwindow : grab_window->xwindow; meta_stack_tracker_record_lower_below (screen->stack_tracker, xwindow, changes.sibling, XNextRequest (screen->display->xdisplay)); meta_error_trap_push (display); XConfigureWindow (xdisplay, xwindow, CWSibling | CWStackMode, &changes); meta_error_trap_pop (display); }
static int x_io_error_handler (Display *xdisplay) { MetaDisplay *display; display = meta_display_for_x_display (xdisplay); if (display == NULL) meta_bug ("IO error received for unknown display?\n"); if (errno == EPIPE) { meta_warning (_("Lost connection to the display '%s';\n" "most likely the X server was shut down or you killed/destroyed\n" "the window manager.\n"), display->name); } else { meta_warning (_("Fatal IO error %d (%s) on display '%s'.\n"), errno, g_strerror (errno), display->name); } /* Xlib would force an exit anyhow */ exit (1); return 0; }
LOCAL_SYMBOL void meta_core_lower_beneath_sibling (Display *xdisplay, Window xwindow, Window grab_window, guint32 timestamp) { XWindowChanges changes; MetaDisplay *display; MetaScreen *screen; display = meta_display_for_x_display (xdisplay); screen = meta_display_screen_for_xwindow (display, xwindow); changes.stack_mode = Below; changes.sibling = grab_window; meta_stack_tracker_record_lower_below (screen->stack_tracker, xwindow, changes.sibling, XNextRequest (screen->display->xdisplay)); meta_error_trap_push (display); XConfigureWindow (xdisplay, xwindow, CWSibling | CWStackMode, &changes); meta_error_trap_pop (display); }
void meta_core_increment_event_serial (Display *xdisplay) { MetaDisplay *display; display = meta_display_for_x_display (xdisplay); meta_display_increment_event_serial (display); }
MetaGrabOp meta_core_get_grab_op (Display *xdisplay) { MetaDisplay *display; display = meta_display_for_x_display (xdisplay); return display->grab_op; }
static int x_error_handler (Display *xdisplay, XErrorEvent *error) { int retval; gchar buf[64]; MetaDisplay *display; ForeignDisplay *foreign; for (foreign = foreign_displays; foreign != NULL; foreign = foreign->next) { if (foreign->dpy == xdisplay) { foreign->handler (xdisplay, error, foreign->data); return 0; } } XGetErrorText (xdisplay, error->error_code, buf, 63); display = meta_display_for_x_display (xdisplay); /* Display can be NULL here because the compositing manager * has its own Display, but Xlib only has one global error handler */ if (display->error_traps > 0) { /* we're in an error trap, chain to the trap handler * saved from GDK */ meta_verbose ("X error: %s serial %ld error_code %d request_code %d minor_code %d)\n", buf, error->serial, error->error_code, error->request_code, error->minor_code); g_assert (display->error_trap_handler != NULL); g_assert (display->error_trap_handler != x_error_handler); retval = (* display->error_trap_handler) (xdisplay, error); } else { meta_bug ("Unexpected X error: %s serial %ld error_code %d request_code %d minor_code %d)\n", buf, error->serial, error->error_code, error->request_code, error->minor_code); retval = 1; /* compiler warning */ } return retval; }
void meta_core_end_grab_op (Display *xdisplay, guint32 timestamp) { MetaDisplay *display; display = meta_display_for_x_display (xdisplay); meta_display_end_grab_op (display, timestamp); }
void meta_core_grab_buttons (Display *xdisplay, Window frame_xwindow) { MetaDisplay *display; display = meta_display_for_x_display (xdisplay); meta_verbose ("Grabbing buttons on frame 0x%lx\n", frame_xwindow); meta_display_grab_window_buttons (display, frame_xwindow); }
int meta_core_get_grab_button (Display *xdisplay) { MetaDisplay *display; display = meta_display_for_x_display (xdisplay); if (display->grab_op == META_GRAB_OP_NONE) return -1; return display->grab_button; }
const char* meta_core_get_workspace_name_with_index (Display *xdisplay, Window xroot, int index) { MetaDisplay *display; MetaScreen *screen; MetaWorkspace *workspace; display = meta_display_for_x_display (xdisplay); screen = meta_display_screen_for_root (display, xroot); g_assert (screen != NULL); workspace = meta_screen_get_workspace_by_index (screen, index); return workspace ? meta_workspace_get_name (workspace) : NULL; }
/* Looks up the MetaWindow representing the frame of the given X window. * Used as a helper function by a bunch of the functions below. * * FIXME: The functions that use this function throw the result away * after use. Many of these functions tend to be called in small groups, * which results in get_window() getting called several times in succession * with the same parameters. We should profile to see whether this wastes * much time, and if it does we should look into a generalised * meta_core_get_window_info() which takes a bunch of pointers to variables * to put its results in, and only fills in the non-null ones. */ static MetaWindow * get_window (Display *xdisplay, Window frame_xwindow) { MetaDisplay *display; MetaWindow *window; display = meta_display_for_x_display (xdisplay); window = meta_display_lookup_x_window (display, frame_xwindow); if (window == NULL || window->frame == NULL) { meta_bug ("No such frame window 0x%lx!\n", frame_xwindow); return NULL; } return window; }
Window meta_core_get_grab_frame (Display *xdisplay) { MetaDisplay *display; display = meta_display_for_x_display (xdisplay); g_assert (display != NULL); g_assert (display->grab_op == META_GRAB_OP_NONE || display->grab_screen != NULL); g_assert (display->grab_op == META_GRAB_OP_NONE || display->grab_screen->display->xdisplay == xdisplay); if (display->grab_op != META_GRAB_OP_NONE && display->grab_window && display->grab_window->frame) return display->grab_window->frame->xwindow; else return None; }
void meta_core_get (Display *xdisplay, Window xwindow, ...) { va_list args; MetaCoreGetType request; MetaDisplay *display = meta_display_for_x_display (xdisplay); MetaWindow *window = meta_display_lookup_x_window (display, xwindow); va_start (args, xwindow); request = va_arg (args, MetaCoreGetType); /* Now, we special-case the first request slightly. Mostly, requests * for information on windows which have no frame are errors. * But sometimes we may want to know *whether* a window has a frame. * In this case, pass the key META_CORE_WINDOW_HAS_FRAME * as the *first* request, with a pointer to a boolean; if the window * has no frame, this will be set to False and meta_core_get will * exit immediately (so the values of any other requests will be * undefined). Otherwise it will be set to True and meta_core_get will * continue happily on its way. */ if (request != META_CORE_WINDOW_HAS_FRAME && (window == NULL || window->frame == NULL)) { meta_bug ("No such frame window 0x%lx!\n", xwindow); return; } while (request != META_CORE_GET_END) { gpointer answer = va_arg (args, gpointer); switch (request) { case META_CORE_WINDOW_HAS_FRAME: *((gboolean*)answer) = window != NULL && window->frame != NULL; if (!*((gboolean*)answer)) return; /* see above */ break; case META_CORE_GET_CLIENT_WIDTH: *((gint*)answer) = window->rect.width; break; case META_CORE_GET_CLIENT_HEIGHT: *((gint*)answer) = window->rect.height; break; case META_CORE_IS_TITLEBAR_ONSCREEN: *((gboolean*)answer) = meta_window_titlebar_is_onscreen (window); break; case META_CORE_GET_CLIENT_XWINDOW: *((Window*)answer) = window->xwindow; break; case META_CORE_GET_FRAME_FLAGS: *((MetaFrameFlags*)answer) = meta_frame_get_flags (window->frame); break; case META_CORE_GET_FRAME_TYPE: { MetaFrameType base_type = META_FRAME_TYPE_LAST; switch (window->type) { case META_WINDOW_NORMAL: base_type = META_FRAME_TYPE_NORMAL; break; case META_WINDOW_DIALOG: base_type = META_FRAME_TYPE_DIALOG; break; case META_WINDOW_MODAL_DIALOG: base_type = META_FRAME_TYPE_MODAL_DIALOG; break; case META_WINDOW_MENU: base_type = META_FRAME_TYPE_MENU; break; case META_WINDOW_UTILITY: base_type = META_FRAME_TYPE_UTILITY; break; case META_WINDOW_DESKTOP: case META_WINDOW_DOCK: case META_WINDOW_TOOLBAR: case META_WINDOW_SPLASHSCREEN: /* No frame */ base_type = META_FRAME_TYPE_LAST; break; } if (base_type == META_FRAME_TYPE_LAST) { /* can't add border if undecorated */ *((MetaFrameType*)answer) = META_FRAME_TYPE_LAST; } else if (window->border_only) { /* override base frame type */ *((MetaFrameType*)answer) = META_FRAME_TYPE_BORDER; } else { *((MetaFrameType*)answer) = base_type; } break; } case META_CORE_GET_MINI_ICON: *((GdkPixbuf**)answer) = window->mini_icon; break; case META_CORE_GET_ICON: *((GdkPixbuf**)answer) = window->icon; break; case META_CORE_GET_X: meta_window_get_position (window, (int*)answer, NULL); break; case META_CORE_GET_Y: meta_window_get_position (window, NULL, (int*)answer); break; case META_CORE_GET_FRAME_WORKSPACE: *((gint*)answer) = meta_window_get_net_wm_desktop (window); break; case META_CORE_GET_FRAME_X: *((gint*)answer) = window->frame->rect.x; break; case META_CORE_GET_FRAME_Y: *((gint*)answer) = window->frame->rect.y; break; case META_CORE_GET_FRAME_WIDTH: *((gint*)answer) = window->frame->rect.width; break; case META_CORE_GET_FRAME_HEIGHT: *((gint*)answer) = window->frame->rect.height; break; case META_CORE_GET_SCREEN_WIDTH: *((gint*)answer) = window->screen->rect.width; break; case META_CORE_GET_SCREEN_HEIGHT: *((gint*)answer) = window->screen->rect.height; break; default: meta_warning(_("Unknown window information request: %d"), request); } request = va_arg (args, MetaCoreGetType); } va_end (args); }
void meta_core_get (Display *xdisplay, Window xwindow, ...) { va_list args; MetaCoreGetType request; MetaDisplay *display = meta_display_for_x_display (xdisplay); MetaWindow *window = meta_display_lookup_x_window (display, xwindow); va_start (args, xwindow); request = va_arg (args, MetaCoreGetType); /* Now, we special-case the first request slightly. Mostly, requests * for information on windows which have no frame are errors. * But sometimes we may want to know *whether* a window has a frame. * In this case, pass the key META_CORE_WINDOW_HAS_FRAME * as the *first* request, with a pointer to a boolean; if the window * has no frame, this will be set to False and meta_core_get will * exit immediately (so the values of any other requests will be * undefined). Otherwise it will be set to True and meta_core_get will * continue happily on its way. */ if (request != META_CORE_WINDOW_HAS_FRAME && (window == NULL || window->frame == NULL)) { meta_bug ("No such frame window 0x%lx!\n", xwindow); return; } while (request != META_CORE_GET_END) { gpointer answer = va_arg (args, gpointer); switch (request) { case META_CORE_WINDOW_HAS_FRAME: *((gboolean*)answer) = window != NULL && window->frame != NULL; if (!*((gboolean*)answer)) return; /* see above */ break; case META_CORE_GET_CLIENT_WIDTH: *((gint*)answer) = window->rect.width; break; case META_CORE_GET_CLIENT_HEIGHT: *((gint*)answer) = window->rect.height; break; case META_CORE_GET_CLIENT_XWINDOW: *((Window*)answer) = window->xwindow; break; case META_CORE_GET_FRAME_FLAGS: *((MetaFrameFlags*)answer) = meta_frame_get_flags (window->frame); break; case META_CORE_GET_FRAME_TYPE: *((MetaFrameType*)answer) = meta_window_get_frame_type (window); break; case META_CORE_GET_MINI_ICON: *((GdkPixbuf**)answer) = window->mini_icon; break; case META_CORE_GET_ICON: *((GdkPixbuf**)answer) = window->icon; break; case META_CORE_GET_X: meta_window_get_position (window, (int*)answer, NULL); break; case META_CORE_GET_Y: meta_window_get_position (window, NULL, (int*)answer); break; case META_CORE_GET_FRAME_WORKSPACE: *((gint*)answer) = meta_window_get_net_wm_desktop (window); break; case META_CORE_GET_FRAME_X: *((gint*)answer) = window->frame->rect.x; break; case META_CORE_GET_FRAME_Y: *((gint*)answer) = window->frame->rect.y; break; case META_CORE_GET_FRAME_WIDTH: *((gint*)answer) = window->frame->rect.width; break; case META_CORE_GET_FRAME_HEIGHT: *((gint*)answer) = window->frame->rect.height; break; case META_CORE_GET_THEME_VARIANT: *((char**)answer) = window->gtk_theme_variant; break; case META_CORE_GET_SCREEN_WIDTH: *((gint*)answer) = window->screen->rect.width; break; case META_CORE_GET_SCREEN_HEIGHT: *((gint*)answer) = window->screen->rect.height; break; default: meta_warning(_("Unknown window information request: %d"), request); } request = va_arg (args, MetaCoreGetType); } va_end (args); }