Move to new uterm infrastructure
This fixes all compositor/output/context/etc. uses and replaces them by the new uterm API. Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
This commit is contained in:
parent
911d635e6e
commit
096f0cadc7
@ -38,15 +38,13 @@
|
||||
|
||||
#include "console.h"
|
||||
#include "font.h"
|
||||
#include "gl.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;
|
||||
struct kmscon_context *ctx;
|
||||
|
||||
/* font */
|
||||
unsigned int res_x;
|
||||
@ -81,7 +79,7 @@ static inline unsigned int to_abs_y(struct kmscon_console *con, unsigned int y)
|
||||
}
|
||||
|
||||
int kmscon_console_new(struct kmscon_console **out,
|
||||
struct kmscon_font_factory *ff, struct kmscon_compositor *comp)
|
||||
struct kmscon_font_factory *ff)
|
||||
{
|
||||
struct kmscon_console *con;
|
||||
int ret;
|
||||
@ -98,8 +96,6 @@ int kmscon_console_new(struct kmscon_console **out,
|
||||
con->ref = 1;
|
||||
con->auto_wrap = true;
|
||||
con->ff = ff;
|
||||
con->comp = comp;
|
||||
con->ctx = kmscon_compositor_get_context(comp);
|
||||
log_debug("console: new console\n");
|
||||
|
||||
ret = kmscon_buffer_new(&con->cells, 0, 0);
|
||||
@ -113,7 +109,6 @@ int kmscon_console_new(struct kmscon_console **out,
|
||||
con->margin_bottom = con->cells_y - 1 - num;
|
||||
|
||||
kmscon_font_factory_ref(con->ff);
|
||||
kmscon_compositor_ref(con->comp);
|
||||
*out = con;
|
||||
|
||||
return 0;
|
||||
@ -145,7 +140,6 @@ void kmscon_console_unref(struct kmscon_console *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");
|
||||
@ -246,12 +240,12 @@ int kmscon_console_resize(struct kmscon_console *con, unsigned int x,
|
||||
* You must have called kmscon_console_draw() before, otherwise this will map an
|
||||
* empty image onto the screen.
|
||||
*/
|
||||
void kmscon_console_map(struct kmscon_console *con)
|
||||
void kmscon_console_map(struct kmscon_console *con, struct gl_shader *shader)
|
||||
{
|
||||
if (!con)
|
||||
return;
|
||||
|
||||
kmscon_buffer_draw(con->cells, con->font);
|
||||
kmscon_buffer_draw(con->cells, con->font, shader);
|
||||
}
|
||||
|
||||
void kmscon_console_write(struct kmscon_console *con, kmscon_symbol_t ch)
|
||||
|
@ -41,7 +41,7 @@
|
||||
#include <inttypes.h>
|
||||
#include <stdlib.h>
|
||||
#include "font.h"
|
||||
#include "output.h"
|
||||
#include "gl.h"
|
||||
#include "unicode.h"
|
||||
|
||||
struct kmscon_buffer;
|
||||
@ -56,7 +56,8 @@ void kmscon_buffer_unref(struct kmscon_buffer *buf);
|
||||
|
||||
int kmscon_buffer_resize(struct kmscon_buffer *buf, unsigned int x,
|
||||
unsigned int y);
|
||||
void kmscon_buffer_draw(struct kmscon_buffer *buf, struct kmscon_font *font);
|
||||
void kmscon_buffer_draw(struct kmscon_buffer *buf, struct kmscon_font *font,
|
||||
struct gl_shader *shader);
|
||||
void kmscon_buffer_set_max_sb(struct kmscon_buffer *buf, unsigned int max);
|
||||
void kmscon_buffer_clear_sb(struct kmscon_buffer *buf);
|
||||
|
||||
@ -78,7 +79,7 @@ void kmscon_buffer_erase_region(struct kmscon_buffer *buf, unsigned int x_from,
|
||||
/* console objects */
|
||||
|
||||
int kmscon_console_new(struct kmscon_console **out,
|
||||
struct kmscon_font_factory *ff, struct kmscon_compositor *comp);
|
||||
struct kmscon_font_factory *ff);
|
||||
void kmscon_console_ref(struct kmscon_console *con);
|
||||
void kmscon_console_unref(struct kmscon_console *con);
|
||||
|
||||
@ -87,7 +88,8 @@ unsigned int kmscon_console_get_height(struct kmscon_console *con);
|
||||
int kmscon_console_resize(struct kmscon_console *con, unsigned int x,
|
||||
unsigned int y, unsigned int height);
|
||||
|
||||
void kmscon_console_map(struct kmscon_console *con);
|
||||
void kmscon_console_map(struct kmscon_console *con,
|
||||
struct gl_shader *shader);
|
||||
|
||||
void kmscon_console_write(struct kmscon_console *con, kmscon_symbol_t ch);
|
||||
void kmscon_console_newline(struct kmscon_console *con);
|
||||
|
@ -79,6 +79,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "console.h"
|
||||
#include "gl.h"
|
||||
#include "log.h"
|
||||
#include "unicode.h"
|
||||
|
||||
@ -119,7 +120,7 @@ struct kmscon_buffer {
|
||||
unsigned int mbottom_y;
|
||||
struct line **mbottom_buf;
|
||||
|
||||
struct kmscon_m4_stack *stack;
|
||||
struct gl_m4_stack *stack;
|
||||
};
|
||||
|
||||
static void destroy_cell(struct cell *cell)
|
||||
@ -242,7 +243,7 @@ int kmscon_buffer_new(struct kmscon_buffer **out, unsigned int x,
|
||||
|
||||
log_debug("console: new buffer object\n");
|
||||
|
||||
ret = kmscon_m4_stack_new(&buf->stack);
|
||||
ret = gl_m4_stack_new(&buf->stack);
|
||||
if (ret)
|
||||
goto err_free;
|
||||
|
||||
@ -254,7 +255,7 @@ int kmscon_buffer_new(struct kmscon_buffer **out, unsigned int x,
|
||||
return 0;
|
||||
|
||||
err_stack:
|
||||
kmscon_m4_stack_free(buf->stack);
|
||||
gl_m4_stack_free(buf->stack);
|
||||
err_free:
|
||||
free(buf);
|
||||
return ret;
|
||||
@ -290,7 +291,7 @@ void kmscon_buffer_unref(struct kmscon_buffer *buf)
|
||||
free(buf->scroll_buf);
|
||||
free(buf->mtop_buf);
|
||||
free(buf->mbottom_buf);
|
||||
kmscon_m4_stack_free(buf->stack);
|
||||
gl_m4_stack_free(buf->stack);
|
||||
free(buf);
|
||||
log_debug("console: destroying buffer object\n");
|
||||
}
|
||||
@ -679,7 +680,8 @@ unsigned int kmscon_buffer_get_mbottom(struct kmscon_buffer *buf)
|
||||
return buf->mbottom_y;
|
||||
}
|
||||
|
||||
void kmscon_buffer_draw(struct kmscon_buffer *buf, struct kmscon_font *font)
|
||||
void kmscon_buffer_draw(struct kmscon_buffer *buf, struct kmscon_font *font,
|
||||
struct gl_shader *shader)
|
||||
{
|
||||
float xs, ys;
|
||||
unsigned int i, j, k, num;
|
||||
@ -691,14 +693,14 @@ void kmscon_buffer_draw(struct kmscon_buffer *buf, struct kmscon_font *font)
|
||||
if (!buf || !font)
|
||||
return;
|
||||
|
||||
m = kmscon_m4_stack_tip(buf->stack);
|
||||
kmscon_m4_identity(m);
|
||||
m = gl_m4_stack_tip(buf->stack);
|
||||
gl_m4_identity(m);
|
||||
|
||||
xs = 1.0 / buf->size_x;
|
||||
ys = 1.0 / buf->size_y;
|
||||
kmscon_m4_scale(m, 2, 2, 1);
|
||||
kmscon_m4_trans(m, -0.5, -0.5, 0);
|
||||
kmscon_m4_scale(m, xs, ys, 1);
|
||||
gl_m4_scale(m, 2, 2, 1);
|
||||
gl_m4_translate(m, -0.5, -0.5, 0);
|
||||
gl_m4_scale(m, xs, ys, 1);
|
||||
|
||||
iter = buf->position;
|
||||
k = 0;
|
||||
@ -745,15 +747,15 @@ void kmscon_buffer_draw(struct kmscon_buffer *buf, struct kmscon_font *font)
|
||||
for (j = 0; j < num; ++j) {
|
||||
cell = &line->cells[j];
|
||||
|
||||
m = kmscon_m4_stack_push(buf->stack);
|
||||
m = gl_m4_stack_push(buf->stack);
|
||||
if (!m) {
|
||||
log_warn("console: cannot push matrix\n");
|
||||
break;
|
||||
}
|
||||
|
||||
kmscon_m4_trans(m, j, i, 0);
|
||||
kmscon_font_draw(font, cell->ch, m);
|
||||
m = kmscon_m4_stack_pop(buf->stack);
|
||||
gl_m4_translate(m, j, i, 0);
|
||||
kmscon_font_draw(font, cell->ch, m, shader);
|
||||
m = gl_m4_stack_pop(buf->stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -35,14 +35,14 @@
|
||||
#define KMSCON_FONT_H
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "output.h"
|
||||
#include "gl.h"
|
||||
#include "unicode.h"
|
||||
|
||||
struct kmscon_font_factory;
|
||||
struct kmscon_font;
|
||||
|
||||
int kmscon_font_factory_new(struct kmscon_font_factory **out,
|
||||
struct kmscon_symbol_table *st, struct kmscon_compositor *comp);
|
||||
struct kmscon_symbol_table *st);
|
||||
void kmscon_font_factory_ref(struct kmscon_font_factory *ff);
|
||||
void kmscon_font_factory_unref(struct kmscon_font_factory *ff);
|
||||
|
||||
@ -54,6 +54,7 @@ void kmscon_font_unref(struct kmscon_font *font);
|
||||
|
||||
unsigned int kmscon_font_get_height(struct kmscon_font *font);
|
||||
unsigned int kmscon_font_get_width(struct kmscon_font *font);
|
||||
int kmscon_font_draw(struct kmscon_font *font, kmscon_symbol_t ch, float *m);
|
||||
int kmscon_font_draw(struct kmscon_font *font, kmscon_symbol_t ch, float *m,
|
||||
struct gl_shader *shader);
|
||||
|
||||
#endif /* KMSCON_FONT_H */
|
||||
|
@ -38,8 +38,8 @@
|
||||
|
||||
#include <glib.h>
|
||||
#include "font.h"
|
||||
#include "gl.h"
|
||||
#include "log.h"
|
||||
#include "output.h"
|
||||
#include "unicode.h"
|
||||
|
||||
#include <ft2build.h>
|
||||
@ -49,8 +49,6 @@ struct kmscon_font_factory {
|
||||
unsigned long ref;
|
||||
struct kmscon_symbol_table *st;
|
||||
FT_Library lib;
|
||||
struct kmscon_compositor *comp;
|
||||
struct kmscon_context *ctx;
|
||||
};
|
||||
|
||||
struct kmscon_font {
|
||||
@ -64,7 +62,6 @@ struct kmscon_font {
|
||||
};
|
||||
|
||||
struct kmscon_glyph {
|
||||
struct kmscon_context *ctx;
|
||||
bool valid;
|
||||
unsigned int tex;
|
||||
unsigned int width;
|
||||
@ -95,7 +92,6 @@ static int kmscon_glyph_new(struct kmscon_glyph **out, kmscon_symbol_t key,
|
||||
return -ENOMEM;
|
||||
|
||||
memset(glyph, 0, sizeof(*glyph));
|
||||
glyph->ctx = font->ff->ctx;
|
||||
|
||||
val = kmscon_symbol_get(font->ff->st, &key, &len);
|
||||
|
||||
@ -120,7 +116,7 @@ static int kmscon_glyph_new(struct kmscon_glyph **out, kmscon_symbol_t key,
|
||||
if (!bmap->width || !bmap->rows)
|
||||
goto ready;
|
||||
|
||||
glyph->tex = kmscon_context_new_tex(glyph->ctx);
|
||||
glyph->tex = gl_tex_new();
|
||||
data = malloc(sizeof(unsigned char) * bmap->width * bmap->rows * 4);
|
||||
if (!data) {
|
||||
ret = -ENOMEM;
|
||||
@ -137,8 +133,7 @@ static int kmscon_glyph_new(struct kmscon_glyph **out, kmscon_symbol_t key,
|
||||
}
|
||||
}
|
||||
|
||||
kmscon_context_set_tex(glyph->ctx, glyph->tex, bmap->width,
|
||||
bmap->rows, data);
|
||||
gl_tex_load(glyph->tex, bmap->width, bmap->rows, data);
|
||||
free(data);
|
||||
|
||||
glyph->width = bmap->width;
|
||||
@ -153,7 +148,7 @@ ready:
|
||||
return 0;
|
||||
|
||||
err_tex:
|
||||
kmscon_context_free_tex(glyph->ctx, glyph->tex);
|
||||
gl_tex_free(glyph->tex);
|
||||
err_free:
|
||||
free(glyph);
|
||||
return ret;
|
||||
@ -165,18 +160,18 @@ static void kmscon_glyph_destroy(struct kmscon_glyph *glyph)
|
||||
return;
|
||||
|
||||
if (glyph->valid)
|
||||
kmscon_context_free_tex(glyph->ctx, glyph->tex);
|
||||
gl_tex_free(glyph->tex);
|
||||
free(glyph);
|
||||
}
|
||||
|
||||
int kmscon_font_factory_new(struct kmscon_font_factory **out,
|
||||
struct kmscon_symbol_table *st, struct kmscon_compositor *comp)
|
||||
struct kmscon_symbol_table *st)
|
||||
{
|
||||
struct kmscon_font_factory *ff;
|
||||
FT_Error err;
|
||||
int ret;
|
||||
|
||||
if (!out || !st || !comp)
|
||||
if (!out || !st)
|
||||
return -EINVAL;
|
||||
|
||||
log_debug("font: new font factory\n");
|
||||
@ -188,8 +183,6 @@ int kmscon_font_factory_new(struct kmscon_font_factory **out,
|
||||
memset(ff, 0, sizeof(*ff));
|
||||
ff->ref = 1;
|
||||
ff->st = st;
|
||||
ff->comp = comp;
|
||||
ff->ctx = kmscon_compositor_get_context(comp);
|
||||
|
||||
err = FT_Init_FreeType(&ff->lib);
|
||||
if (err) {
|
||||
@ -198,7 +191,6 @@ int kmscon_font_factory_new(struct kmscon_font_factory **out,
|
||||
goto err_free;
|
||||
}
|
||||
|
||||
kmscon_compositor_ref(ff->comp);
|
||||
kmscon_symbol_table_ref(ff->st);
|
||||
*out = ff;
|
||||
|
||||
@ -233,7 +225,6 @@ void kmscon_font_factory_unref(struct kmscon_font_factory *ff)
|
||||
if (err)
|
||||
log_warn("font: cannot deinitialize FreeType library\n");
|
||||
|
||||
kmscon_compositor_unref(ff->comp);
|
||||
kmscon_symbol_table_unref(ff->st);
|
||||
free(ff);
|
||||
}
|
||||
@ -370,7 +361,8 @@ static int kmscon_font_lookup(struct kmscon_font *font,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int kmscon_font_draw(struct kmscon_font *font, kmscon_symbol_t ch, float *m)
|
||||
int kmscon_font_draw(struct kmscon_font *font, kmscon_symbol_t ch, float *m,
|
||||
struct gl_shader *shader)
|
||||
{
|
||||
int ret;
|
||||
struct kmscon_glyph *glyph;
|
||||
@ -386,11 +378,11 @@ int kmscon_font_draw(struct kmscon_font *font, kmscon_symbol_t ch, float *m)
|
||||
if (!glyph->valid)
|
||||
return 0;
|
||||
|
||||
kmscon_m4_scale(m, 1.0 / glyph->advance, 1.0 / font->height, 1);
|
||||
kmscon_m4_trans(m, glyph->left, font->height - glyph->top, 0);
|
||||
kmscon_m4_scale(m, glyph->width, glyph->height, 1);
|
||||
gl_m4_scale(m, 1.0 / glyph->advance, 1.0 / font->height, 1);
|
||||
gl_m4_translate(m, glyph->left, font->height - glyph->top, 0);
|
||||
gl_m4_scale(m, glyph->width, glyph->height, 1);
|
||||
|
||||
kmscon_context_draw_tex(font->ff->ctx, val, val, 6, glyph->tex, m);
|
||||
gl_shader_draw_tex(shader, val, val, 6, glyph->tex, m);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -37,23 +37,25 @@
|
||||
#include "console.h"
|
||||
#include "eloop.h"
|
||||
#include "font.h"
|
||||
#include "gl.h"
|
||||
#include "input.h"
|
||||
#include "log.h"
|
||||
#include "output.h"
|
||||
#include "pty.h"
|
||||
#include "terminal.h"
|
||||
#include "unicode.h"
|
||||
#include "uterm.h"
|
||||
#include "vte.h"
|
||||
|
||||
struct term_out {
|
||||
struct term_out *next;
|
||||
struct kmscon_output *output;
|
||||
struct uterm_screen *screen;
|
||||
};
|
||||
|
||||
struct kmscon_terminal {
|
||||
unsigned long ref;
|
||||
struct ev_eloop *eloop;
|
||||
struct kmscon_compositor *comp;
|
||||
struct uterm_video *video;
|
||||
struct gl_shader *shader;
|
||||
|
||||
struct term_out *outputs;
|
||||
unsigned int max_height;
|
||||
@ -71,26 +73,22 @@ static void draw_all(struct ev_idle *idle, void *data)
|
||||
{
|
||||
struct kmscon_terminal *term = data;
|
||||
struct term_out *iter;
|
||||
struct kmscon_output *output;
|
||||
struct kmscon_context *ctx;
|
||||
struct uterm_screen *screen;
|
||||
int ret;
|
||||
|
||||
ctx = kmscon_compositor_get_context(term->comp);
|
||||
ev_eloop_rm_idle(idle);
|
||||
|
||||
iter = term->outputs;
|
||||
for (; iter; iter = iter->next) {
|
||||
output = iter->output;
|
||||
if (!kmscon_output_is_awake(output))
|
||||
continue;
|
||||
screen = iter->screen;
|
||||
|
||||
ret = kmscon_output_use(output);
|
||||
ret = uterm_screen_use(screen);
|
||||
if (ret)
|
||||
continue;
|
||||
|
||||
kmscon_context_clear(ctx);
|
||||
kmscon_console_map(term->console);
|
||||
kmscon_output_swap(output);
|
||||
gl_viewport(screen);
|
||||
kmscon_console_map(term->console, term->shader);
|
||||
uterm_screen_swap(screen);
|
||||
}
|
||||
}
|
||||
|
||||
@ -121,8 +119,10 @@ static void pty_input(struct kmscon_pty *pty, const char *u8, size_t len,
|
||||
}
|
||||
|
||||
int kmscon_terminal_new(struct kmscon_terminal **out,
|
||||
struct ev_eloop *loop, struct kmscon_font_factory *ff,
|
||||
struct kmscon_compositor *comp, struct kmscon_symbol_table *st)
|
||||
struct ev_eloop *loop,
|
||||
struct kmscon_font_factory *ff,
|
||||
struct uterm_video *video,
|
||||
struct kmscon_symbol_table *st)
|
||||
{
|
||||
struct kmscon_terminal *term;
|
||||
int ret;
|
||||
@ -139,13 +139,13 @@ int kmscon_terminal_new(struct kmscon_terminal **out,
|
||||
memset(term, 0, sizeof(*term));
|
||||
term->ref = 1;
|
||||
term->eloop = loop;
|
||||
term->comp = comp;
|
||||
term->video = video;
|
||||
|
||||
ret = ev_idle_new(&term->redraw);
|
||||
if (ret)
|
||||
goto err_free;
|
||||
|
||||
ret = kmscon_console_new(&term->console, ff, comp);
|
||||
ret = kmscon_console_new(&term->console, ff);
|
||||
if (ret)
|
||||
goto err_idle;
|
||||
|
||||
@ -158,12 +158,18 @@ int kmscon_terminal_new(struct kmscon_terminal **out,
|
||||
if (ret)
|
||||
goto err_vte;
|
||||
|
||||
ret = gl_shader_new(&term->shader);
|
||||
if (ret)
|
||||
goto err_pty;
|
||||
|
||||
ev_eloop_ref(term->eloop);
|
||||
kmscon_compositor_ref(term->comp);
|
||||
uterm_video_ref(term->video);
|
||||
*out = term;
|
||||
|
||||
return 0;
|
||||
|
||||
err_pty:
|
||||
kmscon_pty_unref(term->pty);
|
||||
err_vte:
|
||||
kmscon_vte_unref(term->vte);
|
||||
err_con:
|
||||
@ -193,11 +199,12 @@ void kmscon_terminal_unref(struct kmscon_terminal *term)
|
||||
|
||||
kmscon_terminal_close(term);
|
||||
kmscon_terminal_rm_all_outputs(term);
|
||||
gl_shader_unref(term->shader);
|
||||
kmscon_pty_unref(term->pty);
|
||||
kmscon_vte_unref(term->vte);
|
||||
kmscon_console_unref(term->console);
|
||||
ev_idle_unref(term->redraw);
|
||||
kmscon_compositor_unref(term->comp);
|
||||
uterm_video_unref(term->video);
|
||||
ev_eloop_unref(term->eloop);
|
||||
free(term);
|
||||
log_debug("terminal: destroying terminal object\n");
|
||||
@ -234,32 +241,30 @@ void kmscon_terminal_close(struct kmscon_terminal *term)
|
||||
}
|
||||
|
||||
int kmscon_terminal_add_output(struct kmscon_terminal *term,
|
||||
struct kmscon_output *output)
|
||||
struct uterm_display *disp)
|
||||
{
|
||||
struct term_out *out;
|
||||
unsigned int height;
|
||||
struct kmscon_mode *mode;
|
||||
int ret;
|
||||
|
||||
if (!term || !output)
|
||||
if (!term || !disp)
|
||||
return -EINVAL;
|
||||
|
||||
mode = kmscon_output_get_current(output);
|
||||
if (!mode) {
|
||||
log_warn("terminal: invalid output added to terminal\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
out = malloc(sizeof(*out));
|
||||
if (!out)
|
||||
return -ENOMEM;
|
||||
|
||||
memset(out, 0, sizeof(*out));
|
||||
kmscon_output_ref(output);
|
||||
out->output = output;
|
||||
ret = uterm_screen_new_single(&out->screen, disp);
|
||||
if (ret) {
|
||||
free(out);
|
||||
return ret;
|
||||
}
|
||||
|
||||
out->next = term->outputs;
|
||||
term->outputs = out;
|
||||
|
||||
height = kmscon_mode_get_height(mode);
|
||||
height = uterm_screen_height(out->screen);
|
||||
if (term->max_height < height) {
|
||||
term->max_height = height;
|
||||
kmscon_console_resize(term->console, 0, 0, term->max_height);
|
||||
@ -280,7 +285,7 @@ void kmscon_terminal_rm_all_outputs(struct kmscon_terminal *term)
|
||||
while (term->outputs) {
|
||||
tmp = term->outputs;
|
||||
term->outputs = tmp->next;
|
||||
kmscon_output_unref(tmp->output);
|
||||
uterm_screen_unref(tmp->screen);
|
||||
free(tmp);
|
||||
}
|
||||
}
|
||||
|
@ -37,8 +37,9 @@
|
||||
#include "console.h"
|
||||
#include "eloop.h"
|
||||
#include "font.h"
|
||||
#include "output.h"
|
||||
#include "gl.h"
|
||||
#include "unicode.h"
|
||||
#include "uterm.h"
|
||||
|
||||
struct kmscon_terminal;
|
||||
|
||||
@ -46,8 +47,10 @@ typedef void (*kmscon_terminal_closed_cb) (struct kmscon_terminal *term,
|
||||
void *data);
|
||||
|
||||
int kmscon_terminal_new(struct kmscon_terminal **out,
|
||||
struct ev_eloop *loop, struct kmscon_font_factory *ff,
|
||||
struct kmscon_compositor *comp, struct kmscon_symbol_table *st);
|
||||
struct ev_eloop *loop,
|
||||
struct kmscon_font_factory *ff,
|
||||
struct uterm_video *video,
|
||||
struct kmscon_symbol_table *st);
|
||||
void kmscon_terminal_ref(struct kmscon_terminal *term);
|
||||
void kmscon_terminal_unref(struct kmscon_terminal *term);
|
||||
|
||||
@ -56,7 +59,7 @@ int kmscon_terminal_open(struct kmscon_terminal *term,
|
||||
void kmscon_terminal_close(struct kmscon_terminal *term);
|
||||
|
||||
int kmscon_terminal_add_output(struct kmscon_terminal *term,
|
||||
struct kmscon_output *output);
|
||||
struct uterm_display *disp);
|
||||
void kmscon_terminal_rm_all_outputs(struct kmscon_terminal *term);
|
||||
|
||||
int kmscon_terminal_input(struct kmscon_terminal *term,
|
||||
|
@ -52,8 +52,8 @@
|
||||
#include "eloop.h"
|
||||
#include "font.h"
|
||||
#include "log.h"
|
||||
#include "output.h"
|
||||
#include "unicode.h"
|
||||
#include "uterm.h"
|
||||
#include "vt.h"
|
||||
|
||||
static volatile sig_atomic_t terminate;
|
||||
@ -65,7 +65,8 @@ struct console {
|
||||
struct ev_fd *stdin_fd;
|
||||
struct kmscon_symbol_table *st;
|
||||
struct kmscon_font_factory *ff;
|
||||
struct kmscon_compositor *comp;
|
||||
struct gl_shader *shader;
|
||||
struct uterm_video *video;
|
||||
struct kmscon_vt *vt;
|
||||
struct kmscon_console *con;
|
||||
struct ev_idle *idle;
|
||||
@ -110,29 +111,35 @@ static void stdin_cb(struct ev_fd *fd, int mask, void *data)
|
||||
static void map_outputs(struct console *con)
|
||||
{
|
||||
int ret;
|
||||
struct kmscon_output *iter;
|
||||
struct kmscon_context *ctx;
|
||||
struct uterm_display *iter;
|
||||
struct uterm_screen *screen;
|
||||
|
||||
if (kmscon_compositor_is_asleep(con->comp))
|
||||
if (!uterm_video_is_awake(con->video))
|
||||
return;
|
||||
|
||||
ctx = kmscon_compositor_get_context(con->comp);
|
||||
|
||||
iter = kmscon_compositor_get_outputs(con->comp);
|
||||
for ( ; iter; iter = kmscon_output_next(iter)) {
|
||||
if (!kmscon_output_is_active(iter))
|
||||
iter = uterm_video_get_displays(con->video);
|
||||
for ( ; iter; iter = uterm_display_next(iter)) {
|
||||
if (uterm_display_get_state(iter) != UTERM_DISPLAY_ACTIVE)
|
||||
continue;
|
||||
|
||||
ret = kmscon_output_use(iter);
|
||||
/* We create a screen on every draw here to avoid keeping a
|
||||
* global list of displays/screens. This is ugly but works.
|
||||
*/
|
||||
ret = uterm_screen_new_single(&screen, iter);
|
||||
if (ret)
|
||||
continue;
|
||||
|
||||
kmscon_context_clear(ctx);
|
||||
kmscon_console_map(con->con);
|
||||
|
||||
ret = kmscon_output_swap(iter);
|
||||
if (ret)
|
||||
ret = uterm_screen_use(screen);
|
||||
if (ret) {
|
||||
uterm_screen_unref(screen);
|
||||
continue;
|
||||
}
|
||||
|
||||
gl_viewport(screen);
|
||||
kmscon_console_map(con->con, con->shader);
|
||||
|
||||
uterm_screen_swap(screen);
|
||||
uterm_screen_unref(screen);
|
||||
}
|
||||
}
|
||||
|
||||
@ -155,23 +162,23 @@ static void schedule_draw(struct console *con)
|
||||
|
||||
static void activate_outputs(struct console *con)
|
||||
{
|
||||
struct kmscon_output *iter;
|
||||
struct kmscon_mode *mode;
|
||||
struct uterm_display *iter;
|
||||
struct uterm_mode *mode;
|
||||
int ret;
|
||||
uint32_t y;
|
||||
|
||||
con->max_y = 0;
|
||||
|
||||
iter = kmscon_compositor_get_outputs(con->comp);
|
||||
for ( ; iter; iter = kmscon_output_next(iter)) {
|
||||
if (!kmscon_output_is_active(iter)) {
|
||||
ret = kmscon_output_activate(iter, NULL);
|
||||
iter = uterm_video_get_displays(con->video);
|
||||
for ( ; iter; iter = uterm_display_next(iter)) {
|
||||
if (uterm_display_get_state(iter) == UTERM_DISPLAY_INACTIVE) {
|
||||
ret = uterm_display_activate(iter, NULL);
|
||||
if (ret)
|
||||
continue;
|
||||
}
|
||||
|
||||
mode = kmscon_output_get_current(iter);
|
||||
y = kmscon_mode_get_height(mode);
|
||||
mode = uterm_display_get_current(iter);
|
||||
y = uterm_mode_get_height(mode);
|
||||
if (y > con->max_y)
|
||||
con->max_y = y;
|
||||
}
|
||||
@ -191,14 +198,11 @@ static bool vt_switch(struct kmscon_vt *vt, int action, void *data)
|
||||
int ret;
|
||||
|
||||
if (action == KMSCON_VT_ENTER) {
|
||||
ret = kmscon_compositor_wake_up(con->comp);
|
||||
if (ret == 0) {
|
||||
log_info("No output found\n");
|
||||
} else if (ret > 0) {
|
||||
ret = uterm_video_wake_up(con->video);
|
||||
if (!ret)
|
||||
activate_outputs(con);
|
||||
}
|
||||
} else {
|
||||
kmscon_compositor_sleep(con->comp);
|
||||
uterm_video_sleep(con->video);
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -234,7 +238,8 @@ static void destroy_eloop(struct console *con)
|
||||
ev_eloop_rm_idle(con->idle);
|
||||
ev_idle_unref(con->idle);
|
||||
kmscon_console_unref(con->con);
|
||||
kmscon_compositor_unref(con->comp);
|
||||
gl_shader_unref(con->shader);
|
||||
uterm_video_unref(con->video);
|
||||
kmscon_vt_unref(con->vt);
|
||||
kmscon_font_factory_unref(con->ff);
|
||||
kmscon_symbol_table_unref(con->st);
|
||||
@ -271,15 +276,15 @@ static int setup_eloop(struct console *con)
|
||||
if (ret)
|
||||
goto err_loop;
|
||||
|
||||
ret = kmscon_compositor_new(&con->comp);
|
||||
ret = uterm_video_new(&con->video, UTERM_VIDEO_DRM, con->loop);
|
||||
if (ret)
|
||||
goto err_loop;
|
||||
|
||||
ret = kmscon_compositor_use(con->comp);
|
||||
ret = gl_shader_new(&con->shader);
|
||||
if (ret)
|
||||
goto err_loop;
|
||||
|
||||
ret = kmscon_font_factory_new(&con->ff, con->st, con->comp);
|
||||
ret = kmscon_font_factory_new(&con->ff, con->st);
|
||||
if (ret)
|
||||
goto err_loop;
|
||||
|
||||
@ -291,7 +296,7 @@ static int setup_eloop(struct console *con)
|
||||
if (ret)
|
||||
goto err_loop;
|
||||
|
||||
ret = kmscon_console_new(&con->con, con->ff, con->comp);
|
||||
ret = kmscon_console_new(&con->con, con->ff);
|
||||
if (ret)
|
||||
goto err_loop;
|
||||
|
||||
|
@ -37,12 +37,11 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
#include "eloop.h"
|
||||
#include "input.h"
|
||||
#include "log.h"
|
||||
#include "output.h"
|
||||
#include "terminal.h"
|
||||
#include "uterm.h"
|
||||
#include "vt.h"
|
||||
|
||||
struct app {
|
||||
@ -52,7 +51,7 @@ struct app {
|
||||
struct ev_signal *sig_chld;
|
||||
struct kmscon_symbol_table *st;
|
||||
struct kmscon_font_factory *ff;
|
||||
struct kmscon_compositor *comp;
|
||||
struct uterm_video *video;
|
||||
struct kmscon_input *input;
|
||||
struct kmscon_vt *vt;
|
||||
struct kmscon_terminal *term;
|
||||
@ -117,14 +116,14 @@ static void read_input(struct kmscon_input *input,
|
||||
|
||||
static void activate_outputs(struct app *app)
|
||||
{
|
||||
struct kmscon_output *iter;
|
||||
struct uterm_display *iter;
|
||||
int ret;
|
||||
|
||||
iter = kmscon_compositor_get_outputs(app->comp);
|
||||
iter = uterm_video_get_displays(app->video);
|
||||
|
||||
for ( ; iter; iter = kmscon_output_next(iter)) {
|
||||
if (!kmscon_output_is_active(iter)) {
|
||||
ret = kmscon_output_activate(iter, NULL);
|
||||
for ( ; iter; iter = uterm_display_next(iter)) {
|
||||
if (uterm_display_get_state(iter) == UTERM_DISPLAY_INACTIVE) {
|
||||
ret = uterm_display_activate(iter, NULL);
|
||||
if (ret) {
|
||||
log_err("test: cannot activate output: %d\n",
|
||||
ret);
|
||||
@ -146,17 +145,15 @@ static bool vt_switch(struct kmscon_vt *vt, int action, void *data)
|
||||
int ret;
|
||||
|
||||
if (action == KMSCON_VT_ENTER) {
|
||||
ret = kmscon_compositor_wake_up(app->comp);
|
||||
if (ret == 0)
|
||||
log_info("test: running without active outputs\n");
|
||||
else if (ret > 0)
|
||||
ret = uterm_video_wake_up(app->video);
|
||||
if (!ret)
|
||||
activate_outputs(app);
|
||||
|
||||
kmscon_input_wake_up(app->input);
|
||||
} else if (action == KMSCON_VT_LEAVE) {
|
||||
kmscon_input_sleep(app->input);
|
||||
kmscon_terminal_rm_all_outputs(app->term);
|
||||
kmscon_compositor_sleep(app->comp);
|
||||
uterm_video_sleep(app->video);
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -167,7 +164,7 @@ static void destroy_app(struct app *app)
|
||||
kmscon_terminal_unref(app->term);
|
||||
kmscon_vt_unref(app->vt);
|
||||
kmscon_input_unref(app->input);
|
||||
kmscon_compositor_unref(app->comp);
|
||||
uterm_video_unref(app->video);
|
||||
kmscon_font_factory_unref(app->ff);
|
||||
kmscon_symbol_table_unref(app->st);
|
||||
ev_eloop_rm_signal(app->sig_chld);
|
||||
@ -203,15 +200,11 @@ static int setup_app(struct app *app)
|
||||
if (ret)
|
||||
goto err_loop;
|
||||
|
||||
ret = kmscon_compositor_new(&app->comp);
|
||||
ret = uterm_video_new(&app->video, UTERM_VIDEO_DRM, app->eloop);
|
||||
if (ret)
|
||||
goto err_loop;
|
||||
|
||||
ret = kmscon_compositor_use(app->comp);
|
||||
if (ret)
|
||||
goto err_loop;
|
||||
|
||||
ret = kmscon_font_factory_new(&app->ff, app->st, app->comp);
|
||||
ret = kmscon_font_factory_new(&app->ff, app->st);
|
||||
if (ret)
|
||||
goto err_loop;
|
||||
|
||||
@ -227,8 +220,8 @@ static int setup_app(struct app *app)
|
||||
if (ret)
|
||||
goto err_loop;
|
||||
|
||||
ret = kmscon_terminal_new(&app->term, app->eloop, app->ff,
|
||||
app->comp, app->st);
|
||||
ret = kmscon_terminal_new(&app->term, app->eloop,
|
||||
app->ff, app->video, app->st);
|
||||
if (ret)
|
||||
goto err_loop;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user