terminal: Use window_get_fullscreen() instead of tracking that state manually
This commit is contained in:
+9
-13
@@ -48,7 +48,7 @@ static char *option_shell;
|
|||||||
static struct wl_list terminal_list;
|
static struct wl_list terminal_list;
|
||||||
|
|
||||||
static struct terminal *
|
static struct terminal *
|
||||||
terminal_create(struct display *display, int fullscreen);
|
terminal_create(struct display *display);
|
||||||
static void
|
static void
|
||||||
terminal_destroy(struct terminal *terminal);
|
terminal_destroy(struct terminal *terminal);
|
||||||
static int
|
static int
|
||||||
@@ -404,7 +404,6 @@ struct terminal {
|
|||||||
int escape_flags;
|
int escape_flags;
|
||||||
struct utf8_state_machine state_machine;
|
struct utf8_state_machine state_machine;
|
||||||
int margin;
|
int margin;
|
||||||
int fullscreen;
|
|
||||||
struct color_scheme *color_scheme;
|
struct color_scheme *color_scheme;
|
||||||
struct terminal_color color_table[256];
|
struct terminal_color color_table[256];
|
||||||
cairo_font_extents_t extents;
|
cairo_font_extents_t extents;
|
||||||
@@ -764,7 +763,7 @@ resize_handler(struct widget *widget,
|
|||||||
columns = (width - m) / (int32_t) terminal->extents.max_x_advance;
|
columns = (width - m) / (int32_t) terminal->extents.max_x_advance;
|
||||||
rows = (height - m) / (int32_t) terminal->extents.height;
|
rows = (height - m) / (int32_t) terminal->extents.height;
|
||||||
|
|
||||||
if (!terminal->fullscreen) {
|
if (window_is_fullscreen(terminal->window)) {
|
||||||
width = columns * terminal->extents.max_x_advance + m;
|
width = columns * terminal->extents.max_x_advance + m;
|
||||||
height = rows * terminal->extents.height + m;
|
height = rows * terminal->extents.height + m;
|
||||||
widget_set_size(terminal->widget, width, height);
|
widget_set_size(terminal->widget, width, height);
|
||||||
@@ -778,7 +777,7 @@ terminal_resize(struct terminal *terminal, int columns, int rows)
|
|||||||
{
|
{
|
||||||
int32_t width, height, m;
|
int32_t width, height, m;
|
||||||
|
|
||||||
if (terminal->fullscreen)
|
if (window_is_fullscreen(terminal->window))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m = 2 * terminal->margin;
|
m = 2 * terminal->margin;
|
||||||
@@ -2065,8 +2064,7 @@ fullscreen_handler(struct window *window, void *data)
|
|||||||
{
|
{
|
||||||
struct terminal *terminal = data;
|
struct terminal *terminal = data;
|
||||||
|
|
||||||
terminal->fullscreen ^= 1;
|
window_set_fullscreen(window, !window_is_fullscreen(terminal->window));
|
||||||
window_set_fullscreen(window, terminal->fullscreen);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@@ -2097,8 +2095,7 @@ handle_bound_key(struct terminal *terminal,
|
|||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
case XKB_KEY_N:
|
case XKB_KEY_N:
|
||||||
new_terminal =
|
new_terminal = terminal_create(terminal->display);
|
||||||
terminal_create(terminal->display, option_fullscreen);
|
|
||||||
if (terminal_run(new_terminal, option_shell))
|
if (terminal_run(new_terminal, option_shell))
|
||||||
terminal_destroy(new_terminal);
|
terminal_destroy(new_terminal);
|
||||||
|
|
||||||
@@ -2448,7 +2445,7 @@ motion_handler(struct widget *widget,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static struct terminal *
|
static struct terminal *
|
||||||
terminal_create(struct display *display, int fullscreen)
|
terminal_create(struct display *display)
|
||||||
{
|
{
|
||||||
struct terminal *terminal;
|
struct terminal *terminal;
|
||||||
cairo_surface_t *surface;
|
cairo_surface_t *surface;
|
||||||
@@ -2459,7 +2456,6 @@ terminal_create(struct display *display, int fullscreen)
|
|||||||
return terminal;
|
return terminal;
|
||||||
|
|
||||||
memset(terminal, 0, sizeof *terminal);
|
memset(terminal, 0, sizeof *terminal);
|
||||||
terminal->fullscreen = fullscreen;
|
|
||||||
terminal->color_scheme = &DEFAULT_COLORS;
|
terminal->color_scheme = &DEFAULT_COLORS;
|
||||||
terminal_init(terminal);
|
terminal_init(terminal);
|
||||||
terminal->margin_top = 0;
|
terminal->margin_top = 0;
|
||||||
@@ -2571,8 +2567,8 @@ terminal_run(struct terminal *terminal, const char *path)
|
|||||||
display_watch_fd(terminal->display, terminal->master,
|
display_watch_fd(terminal->display, terminal->master,
|
||||||
EPOLLIN | EPOLLHUP, &terminal->io_task);
|
EPOLLIN | EPOLLHUP, &terminal->io_task);
|
||||||
|
|
||||||
window_set_fullscreen(terminal->window, terminal->fullscreen);
|
window_set_fullscreen(terminal->window, option_fullscreen);
|
||||||
if (!terminal->fullscreen)
|
if (!window_is_fullscreen(terminal->window))
|
||||||
terminal_resize(terminal, 80, 24);
|
terminal_resize(terminal, 80, 24);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -2621,7 +2617,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
wl_list_init(&terminal_list);
|
wl_list_init(&terminal_list);
|
||||||
terminal = terminal_create(d, option_fullscreen);
|
terminal = terminal_create(d);
|
||||||
if (terminal_run(terminal, option_shell))
|
if (terminal_run(terminal, option_shell))
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user