コード例 #1
0
void MenuEffectPrompt::create_objects()
{
	int x = 10, y = 10;
	BC_Title *title;
	add_subwindow(title = new BC_Title(x, y, PROMPT_TEXT));
	add_subwindow(new BC_OKButton(this));
	add_subwindow(new BC_CancelButton(this));
	show_window();
	raise_window();
}
コード例 #2
0
ファイル: lock.c プロジェクト: wenhann/chromiumos
Bool
unlock_p (saver_info *si)
{
  saver_preferences *p = &si->prefs;

  if (!si->unlock_cb)
    {
      fprintf(stderr, "%s: Error: no unlock function specified!\n", blurb());
      return False;
    }

  raise_window (si, True, True, True);

  xss_authenticate(si, p->verbose_p);

  return (si->unlock_state == ul_success);
}
コード例 #3
0
ファイル: window.c プロジェクト: kristiandelay/rutabaga
struct rtb_window *
window_impl_open(struct rutabaga *rtb,
                 int w, int h, const char *title, intptr_t parent)
{
    struct xcb_rutabaga *xrtb = (void *) rtb;
    struct xrtb_window *self;

    Display *dpy;
    xcb_connection_t *xcb_conn;

    int default_screen;

    GLXFBConfig *fb_configs, fb_config;
    XVisualInfo *visual;
    int nfb_configs;

    uint32_t event_mask =
        XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_EXPOSURE |
        XCB_EVENT_MASK_VISIBILITY_CHANGE | XCB_EVENT_MASK_BUTTON_PRESS |
        XCB_EVENT_MASK_BUTTON_RELEASE | XCB_EVENT_MASK_POINTER_MOTION |
        XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW |
        XCB_EVENT_MASK_KEY_PRESS | XCB_EVENT_MASK_KEY_RELEASE |
        XCB_EVENT_MASK_KEYMAP_STATE;
    uint32_t value_mask =
        XCB_CW_BORDER_PIXEL | XCB_CW_BACK_PIXMAP |
        XCB_CW_BIT_GRAVITY |
        XCB_CW_EVENT_MASK | XCB_CW_COLORMAP;
    uint32_t value_list[6];

    xcb_colormap_t colormap;
    xcb_void_cookie_t ck_window, ck_map;
    xcb_generic_error_t *err;

    assert(rtb);
    assert(h > 0);
    assert(w > 0);

    if (!(self = calloc(1, sizeof(*self))))
        goto err_malloc;

    self->xrtb = xrtb;

    dpy = xrtb->dpy;
    xcb_conn = xrtb->xcb_conn;

    default_screen = DefaultScreen(dpy);

    self->screen = find_xcb_screen(xcb_conn, default_screen);
    if (!self->screen) {
        ERR("couldn't find XCB screen\n");
        goto err_screen;
    }

    /**
     * gl configuration
     */

    fb_configs = glXGetFBConfigs(dpy, default_screen, &nfb_configs);
    if (!fb_configs || !nfb_configs) {
        ERR("no GL configurations, bailing out\n");
        goto err_gl_config;
    }

    fb_config = find_reasonable_fb_config(dpy, xcb_conn, fb_configs,
                                          nfb_configs, 0);

    if (!fb_config) {
        ERR("no reasonable GL configurations, bailing out\n");
        goto err_gl_config;
    }

    visual = glXGetVisualFromFBConfig(dpy, fb_config);

    self->gl_ctx = new_gl_context(dpy, fb_config);
    if (!self->gl_ctx) {
        ERR("couldn't create GLX context\n");
        goto err_gl_ctx;
    }

    /**
     * window setup
     */

    colormap = xcb_generate_id(xcb_conn);
    self->xcb_win = xcb_generate_id(xcb_conn);

    xcb_create_colormap(
        xcb_conn, XCB_COLORMAP_ALLOC_NONE, colormap,
        self->screen->root, visual->visualid);

    value_list[0] = 0;
    value_list[1] = 0;
    value_list[2] = XCB_GRAVITY_STATIC;
    value_list[3] = event_mask;
    value_list[4] = colormap;
    value_list[5] = 0;

    ck_window = xcb_create_window_checked(
                    xcb_conn, visual->depth, self->xcb_win,
                    parent ? (xcb_window_t) parent : self->screen->root,
                    0, 0,
                    w, h,
                    0,
                    XCB_WINDOW_CLASS_INPUT_OUTPUT,
                    visual->visualid, value_mask, value_list);

    free(visual);

    if ((err = xcb_request_check(xcb_conn, ck_window))) {
        ERR("can't create XCB window: %d\n", err->error_code);
        goto err_xcb_win;
    }

    get_dpi(dpy, default_screen, &self->dpi.x, &self->dpi.y);

    self->gl_win = glXCreateWindow(dpy, fb_config, self->xcb_win, 0);
    if (!self->gl_win) {
        ERR("couldn't create GL window\n");
        goto err_gl_win;
    }

    if (set_xprop(xcb_conn, self->xcb_win, XCB_ATOM_WM_NAME, title))
        set_xprop(xcb_conn, self->xcb_win, XCB_ATOM_WM_NAME, "oh no");

    self->gl_draw = self->gl_win;

    if (!glXMakeContextCurrent(
                dpy, self->gl_draw, self->gl_draw, self->gl_ctx)) {
        ERR("couldn't activate GLX context\n");
        goto err_gl_make_current;
    }

    ck_map = xcb_map_window_checked(xcb_conn, self->xcb_win);
    if ((err = xcb_request_check(xcb_conn, ck_map))) {
        ERR("can't map XCB window: %d\n", err->error_code);
        goto err_win_map;
    }

    if (parent)
        raise_window(xcb_conn, self->xcb_win);
    else
        xcb_icccm_set_wm_protocols(xcb_conn,
                                   self->xcb_win, xrtb->atoms.wm_protocols,
                                   1, &xrtb->atoms.wm_delete_window);

    free(fb_configs);

    uv_mutex_init(&self->lock);
    return RTB_WINDOW(self);

err_win_map:
err_gl_make_current:
err_gl_win:
    xcb_destroy_window(xcb_conn, self->xcb_win);

err_xcb_win:
    glXDestroyContext(dpy, self->gl_ctx);

err_gl_ctx:
err_gl_config:
    free(fb_configs);
err_screen:
    free(self);

err_malloc:
    return NULL;
}