Ejemplo n.º 1
0
Archivo: nilwm.c Proyecto: nqv/nilwm
static
void cleanup() {
    if (nil_.key_syms) {
        xcb_key_symbols_free(nil_.key_syms);
    }
    if (nil_.font.id) {
        xcb_close_font(nil_.con, nil_.font.id);
    }
    if (nil_.cursor[CURSOR_NORMAL]) {
        xcb_free_cursor(nil_.con, nil_.cursor[CURSOR_NORMAL]);
    }
    if (nil_.cursor[CURSOR_MOVE]
        && (nil_.cursor[CURSOR_MOVE] != nil_.cursor[CURSOR_NORMAL])) {
        xcb_free_cursor(nil_.con, nil_.cursor[CURSOR_MOVE]);
    }
    if (nil_.cursor[CURSOR_RESIZE]
        && (nil_.cursor[CURSOR_RESIZE] != nil_.cursor[CURSOR_NORMAL])) {
        xcb_free_cursor(nil_.con, nil_.cursor[CURSOR_RESIZE]);
    }
    if (bar_.win) {
        xcb_destroy_window(nil_.con, bar_.win);
    }
    xcb_ungrab_keyboard(nil_.con, XCB_TIME_CURRENT_TIME);
    xcb_destroy_subwindows(nil_.con, nil_.scr->root);
    xcb_flush(nil_.con);
    xcb_disconnect(nil_.con);
    if (nil_.ws) {
        free(nil_.ws);
    }
}
Ejemplo n.º 2
0
static void
cursor_set (xcb_connection_t *c,
            xcb_screen_t     *screen,
            xcb_window_t      window,
            int               cursor_id)
{
  uint32_t             values_list[3];
  xcb_void_cookie_t    cookie_font;
  xcb_void_cookie_t    cookie_gc;
  xcb_generic_error_t *error;
  xcb_font_t           font;
  xcb_cursor_t         cursor;
  xcb_gcontext_t       gc;
  uint32_t             mask;
  uint32_t             value_list;

  font = xcb_generate_id (c);
  cookie_font = xcb_open_font_checked (c, font,
                                       strlen ("cursor"),
                                       "cursor");
  error = xcb_request_check (c, cookie_font);
  if (error) {
    fprintf (stderr, "ERROR: can't open font : %d\n", error->error_code);
    xcb_disconnect (c);
    exit (-1);
  }

  cursor = xcb_generate_id (c);
  xcb_create_glyph_cursor (c, cursor, font, font,
                           cursor_id, cursor_id + 1,
                           0, 0, 0,
                           0, 0, 0);

  gc = xcb_generate_id (c);
  mask = XCB_GC_FOREGROUND | XCB_GC_BACKGROUND | XCB_GC_FONT;
  values_list[0] = screen->black_pixel;
  values_list[1] = screen->white_pixel;
  values_list[2] = font;
  cookie_gc = xcb_create_gc_checked (c, gc, window, mask, values_list);
  error = xcb_request_check (c, cookie_gc);
  if (error) {
    fprintf (stderr, "ERROR: can't create gc : %d\n", error->error_code);
    xcb_disconnect (c);
    exit (-1);
  }

  mask = XCB_CW_CURSOR;
  value_list = cursor;
  xcb_change_window_attributes (c, window, mask, &value_list);

  xcb_free_cursor (c, cursor);

  cookie_font = xcb_close_font_checked (c, font);
  error = xcb_request_check (c, cookie_font);
  if (error) {
    fprintf (stderr, "ERROR: can't close font : %d\n", error->error_code);
    xcb_disconnect (c);
    exit (-1);
  }
}
Ejemplo n.º 3
0
void X11WindowedBackend::createCursor(const QImage &img, const QPoint &hotspot)
{
    const xcb_pixmap_t pix = xcb_generate_id(m_connection);
    const xcb_gcontext_t gc = xcb_generate_id(m_connection);
    const xcb_cursor_t cid = xcb_generate_id(m_connection);

    xcb_create_pixmap(m_connection, 32, pix, m_screen->root, img.width(), img.height());
    xcb_create_gc(m_connection, gc, pix, 0, nullptr);

    xcb_put_image(m_connection, XCB_IMAGE_FORMAT_Z_PIXMAP, pix, gc, img.width(), img.height(), 0, 0, 0, 32, img.byteCount(), img.constBits());

    XRenderPicture pic(pix, 32);
    xcb_render_create_cursor(m_connection, cid, pic, hotspot.x(), hotspot.y());
    for (auto it = m_windows.constBegin(); it != m_windows.constEnd(); ++it) {
        xcb_change_window_attributes(m_connection, (*it).window, XCB_CW_CURSOR, &cid);
    }

    xcb_free_pixmap(m_connection, pix);
    xcb_free_gc(m_connection, gc);
    if (m_cursor) {
        xcb_free_cursor(m_connection, m_cursor);
    }
    m_cursor = cid;
    xcb_flush(m_connection);
    markCursorAsRendered();
}
Ejemplo n.º 4
0
QXcbCursor::~QXcbCursor()
{
    xcb_connection_t *conn = xcb_connection();

    if (m_gtkCursorThemeInitialized) {
        m_screen->xSettings()->removeCallbackForHandle(this);
    }

    if (!--cursorCount)
        xcb_close_font(conn, cursorFont);

    foreach (xcb_cursor_t cursor, m_cursorHash)
        xcb_free_cursor(conn, cursor);
}
Ejemplo n.º 5
0
QXcbCursor::~QXcbCursor()
{
    xcb_connection_t *conn = xcb_connection();

    if (m_gtkCursorThemeInitialized) {
        m_screen->xSettings()->removeCallbackForHandle(this);
    }

    if (!--cursorCount)
        xcb_close_font(conn, cursorFont);

#ifndef QT_NO_CURSOR
    for (xcb_cursor_t cursor : qAsConst(m_cursorHash))
        xcb_free_cursor(conn, cursor);
#endif
}
Ejemplo n.º 6
0
X11WindowedBackend::~X11WindowedBackend()
{
    if (m_connection) {
        if (m_keySymbols) {
            xcb_key_symbols_free(m_keySymbols);
        }
        for (auto it = m_windows.begin(); it != m_windows.end(); ++it) {
            xcb_unmap_window(m_connection, (*it).window);
            xcb_destroy_window(m_connection, (*it).window);
            delete (*it).winInfo;
        }
        if (m_cursor) {
            xcb_free_cursor(m_connection, m_cursor);
        }
        xcb_disconnect(m_connection);
    }
}
static void setCursor(xcb_connection_t *connection,
                      xcb_screen_t *screen,
                      xcb_window_t window,
                      int cursorId) {

  xcb_font_t font = xcb_generate_id(connection);
  xcb_void_cookie_t fontCookie = xcb_open_font_checked(connection,
                                                       font,
                                                       strlen("cursor"),
                                                       "cursor");
  testCookie(fontCookie, connection, "can't open font");

  xcb_cursor_t cursor = xcb_generate_id(connection);
  xcb_create_glyph_cursor(connection,
                          cursor,
                          font,
                          font,
                          cursorId,
                          cursorId + 1,
                          0,0,0,0,0,0);

  xcb_gcontext_t gc = xcb_generate_id(connection);

  uint32_t mask = XCB_GC_FOREGROUND | XCB_GC_BACKGROUND | XCB_GC_FONT;
  uint32_t values_list[3];
  values_list[0] = screen->black_pixel;
  values_list[1] = screen->white_pixel;
  values_list[2] = font;

  xcb_void_cookie_t gcCookie = xcb_create_gc_checked(connection, gc, window, mask, values_list);
  testCookie(gcCookie, connection, "can't create gc");

  mask = XCB_CW_CURSOR;
  uint32_t value_list = cursor;
  xcb_change_window_attributes(connection, window, mask, &value_list);

  xcb_free_cursor(connection, cursor);

  fontCookie = xcb_close_font_checked(connection, font);
  testCookie(fontCookie, connection, "can't close font");
}