console: take reference of compositor
To switch to the new drawing subsystem we need a reference to a valid compositor object so we can retrieve the GL context. This also applies to the terminal object. Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
This commit is contained in:
parent
cabde245df
commit
05a1747f00
@ -49,11 +49,13 @@
|
||||
#include "console.h"
|
||||
#include "font.h"
|
||||
#include "log.h"
|
||||
#include "output.h"
|
||||
#include "unicode.h"
|
||||
|
||||
struct kmscon_console {
|
||||
size_t ref;
|
||||
struct kmscon_font_factory *ff;
|
||||
struct kmscon_compositor *comp;
|
||||
|
||||
/* GL texture and font */
|
||||
GLuint tex;
|
||||
@ -150,7 +152,7 @@ err_free:
|
||||
}
|
||||
|
||||
int kmscon_console_new(struct kmscon_console **out,
|
||||
struct kmscon_font_factory *ff)
|
||||
struct kmscon_font_factory *ff, struct kmscon_compositor *comp)
|
||||
{
|
||||
struct kmscon_console *con;
|
||||
int ret;
|
||||
@ -165,6 +167,7 @@ int kmscon_console_new(struct kmscon_console **out,
|
||||
memset(con, 0, sizeof(*con));
|
||||
con->ref = 1;
|
||||
con->ff = ff;
|
||||
con->comp = comp;
|
||||
log_debug("console: new console\n");
|
||||
|
||||
ret = kmscon_buffer_new(&con->cells, 0, 0);
|
||||
@ -175,6 +178,7 @@ int kmscon_console_new(struct kmscon_console **out,
|
||||
con->cells_y = kmscon_buffer_get_height(con->cells);
|
||||
|
||||
kmscon_font_factory_ref(con->ff);
|
||||
kmscon_compositor_ref(con->comp);
|
||||
*out = con;
|
||||
|
||||
return 0;
|
||||
@ -207,6 +211,7 @@ void kmscon_console_unref(struct kmscon_console *con)
|
||||
kmscon_console_free_res(con);
|
||||
kmscon_font_unref(con->font);
|
||||
kmscon_buffer_unref(con->cells);
|
||||
kmscon_compositor_unref(con->comp);
|
||||
kmscon_font_factory_unref(con->ff);
|
||||
free(con);
|
||||
log_debug("console: destroying console\n");
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include <inttypes.h>
|
||||
#include <stdlib.h>
|
||||
#include "font.h"
|
||||
#include "output.h"
|
||||
#include "unicode.h"
|
||||
|
||||
struct kmscon_buffer;
|
||||
@ -66,7 +67,7 @@ void kmscon_buffer_rotate(struct kmscon_buffer *buf);
|
||||
/* console objects */
|
||||
|
||||
int kmscon_console_new(struct kmscon_console **out,
|
||||
struct kmscon_font_factory *ff);
|
||||
struct kmscon_font_factory *ff, struct kmscon_compositor *comp);
|
||||
void kmscon_console_ref(struct kmscon_console *con);
|
||||
void kmscon_console_unref(struct kmscon_console *con);
|
||||
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include "eloop.h"
|
||||
#include "font.h"
|
||||
#include "log.h"
|
||||
#include "output.h"
|
||||
#include "terminal.h"
|
||||
#include "unicode.h"
|
||||
#include "vte.h"
|
||||
@ -52,6 +53,7 @@ struct term_out {
|
||||
struct kmscon_terminal {
|
||||
unsigned long ref;
|
||||
struct kmscon_eloop *eloop;
|
||||
struct kmscon_compositor *comp;
|
||||
|
||||
struct term_out *outputs;
|
||||
unsigned int max_height;
|
||||
@ -118,7 +120,7 @@ static void print_help(struct kmscon_terminal *term)
|
||||
}
|
||||
|
||||
int kmscon_terminal_new(struct kmscon_terminal **out,
|
||||
struct kmscon_font_factory *ff)
|
||||
struct kmscon_font_factory *ff, struct kmscon_compositor *comp)
|
||||
{
|
||||
struct kmscon_terminal *term;
|
||||
int ret;
|
||||
@ -134,12 +136,13 @@ int kmscon_terminal_new(struct kmscon_terminal **out,
|
||||
|
||||
memset(term, 0, sizeof(*term));
|
||||
term->ref = 1;
|
||||
term->comp = comp;
|
||||
|
||||
ret = kmscon_idle_new(&term->redraw);
|
||||
if (ret)
|
||||
goto err_free;
|
||||
|
||||
ret = kmscon_console_new(&term->console, ff);
|
||||
ret = kmscon_console_new(&term->console, ff, comp);
|
||||
if (ret)
|
||||
goto err_idle;
|
||||
|
||||
@ -149,7 +152,9 @@ int kmscon_terminal_new(struct kmscon_terminal **out,
|
||||
kmscon_vte_bind(term->vte, term->console);
|
||||
print_help(term);
|
||||
|
||||
kmscon_compositor_ref(term->comp);
|
||||
*out = term;
|
||||
|
||||
return 0;
|
||||
|
||||
err_con:
|
||||
@ -181,6 +186,7 @@ void kmscon_terminal_unref(struct kmscon_terminal *term)
|
||||
kmscon_vte_unref(term->vte);
|
||||
kmscon_console_unref(term->console);
|
||||
kmscon_terminal_disconnect_eloop(term);
|
||||
kmscon_compositor_unref(term->comp);
|
||||
free(term);
|
||||
log_debug("terminal: destroying terminal object\n");
|
||||
}
|
||||
|
@ -42,7 +42,7 @@
|
||||
struct kmscon_terminal;
|
||||
|
||||
int kmscon_terminal_new(struct kmscon_terminal **out,
|
||||
struct kmscon_font_factory *ff);
|
||||
struct kmscon_font_factory *ff, struct kmscon_compositor *comp);
|
||||
void kmscon_terminal_ref(struct kmscon_terminal *term);
|
||||
void kmscon_terminal_unref(struct kmscon_terminal *term);
|
||||
|
||||
|
@ -297,7 +297,7 @@ static int setup_eloop(struct console *con)
|
||||
if (ret)
|
||||
goto err_loop;
|
||||
|
||||
ret = kmscon_console_new(&con->con, con->ff);
|
||||
ret = kmscon_console_new(&con->con, con->ff, con->comp);
|
||||
if (ret)
|
||||
goto err_loop;
|
||||
|
||||
|
@ -182,7 +182,7 @@ static int setup_app(struct app *app)
|
||||
if (ret)
|
||||
goto err_loop;
|
||||
|
||||
ret = kmscon_terminal_new(&app->term, app->ff);
|
||||
ret = kmscon_terminal_new(&app->term, app->ff, app->comp);
|
||||
if (ret)
|
||||
goto err_loop;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user