コード例 #1
0
ファイル: i3ipc-con.c プロジェクト: bobbymcshane/i3ipc-glib
static void i3ipc_con_dispose(GObject *gobject) {
  i3ipcCon *self = I3IPC_CON(gobject);

  self->priv->parent = NULL;

  self->priv->rect = (i3ipc_rect_free(self->priv->rect), NULL);
  self->priv->deco_rect = (i3ipc_rect_free(self->priv->deco_rect), NULL);

  G_OBJECT_CLASS(i3ipc_con_parent_class)->dispose(gobject);
}
コード例 #2
0
ファイル: ipc.c プロジェクト: cornerman/i3-easyfocus
static Window *con_to_window(i3ipcCon *con)
{
    unsigned long id;
    g_object_get(con, "id", &id, NULL);

    uint32_t win_id;
    g_object_get(con, "window", &win_id, NULL);

    i3ipcRect *deco_rect = NULL;
    g_object_get(con, "deco_rect", &deco_rect, NULL);

    gboolean fullscreen;
    g_object_get(con, "fullscreen-mode", &fullscreen, NULL);

    gboolean urgent;
    g_object_get(con, "urgent", &urgent, NULL);

    gboolean focused;
    g_object_get(con, "focused", &focused, NULL);

    int x, y;
    if (fullscreen || (deco_rect->height == 0))
    {
        i3ipcRect *rect = NULL;
        g_object_get(con, "rect", &rect, NULL);

        x = rect->x;
        y = rect->y;

        i3ipc_rect_free(rect);
    }
    else
    {
        i3ipcCon *parent = NULL;
        g_object_get(con, "parent", &parent, NULL);

        i3ipcRect *parent_rect = NULL;
        g_object_get(parent, "rect", &parent_rect, NULL);

        x = parent_rect->x + deco_rect->x;
        y = parent_rect->y + deco_rect->y;

        i3ipc_rect_free(parent_rect);
        g_object_unref(parent);
    }

    i3ipc_rect_free(deco_rect);

    LOG("found window (id: %lu, window: %u, x: %i, y: %i)\n", id, win_id, x, y);
    Window *window = malloc(sizeof(Window));
    window->id = id;
    window->win_id = win_id;
    window->position.x = x;
    window->position.y = y;
    window->next = NULL;
    if (urgent) {
        window->type = URGENT_WINDOW;
    } else if (focused) {
        window->type = FOCUSED_WINDOW;
    } else {
        window->type = UNFOCUSED_WINDOW;
    }

    return window;
}