diff options
author | Kristian Høgsberg <krh@bitplanet.net> | 2011-01-25 10:40:01 -0500 |
---|---|---|
committer | Kristian Høgsberg <krh@bitplanet.net> | 2011-01-25 10:40:01 -0500 |
commit | 6ec41abf72ab04f562cb91d7c44b734c2f184b65 (patch) | |
tree | 4434466bf105b958e00188ea5b1a0c619f803d7f /clients | |
parent | 4d6ff297c809be5330f693810cf8e5bac61b238d (diff) | |
parent | 6eeeb30021a9f72636887a529bb5772930cd190e (diff) |
Merge remote branch 'callum/master'
Conflicts:
clients/window.h
Diffstat (limited to 'clients')
-rw-r--r-- | clients/terminal.c | 70 | ||||
-rw-r--r-- | clients/window.c | 19 | ||||
-rw-r--r-- | clients/window.h | 14 |
3 files changed, 91 insertions, 12 deletions
diff --git a/clients/terminal.c b/clients/terminal.c index 78f575f..cb4d861 100644 --- a/clients/terminal.c +++ b/clients/terminal.c @@ -54,8 +54,8 @@ static int option_fullscreen; #define ATTRMASK_CONCEALED 0x10 /* Buffer sizes */ -#define MAX_RESPONSE 11 -#define MAX_ESCAPE 64 +#define MAX_RESPONSE 256 +#define MAX_ESCAPE 255 /* Terminal modes */ #define MODE_SHOW_CURSOR 0x00000001 @@ -377,7 +377,7 @@ struct terminal { int fd, master; GIOChannel *channel; uint32_t modifiers; - char escape[MAX_ESCAPE]; + char escape[MAX_ESCAPE+1]; int escape_length; enum escape_state state; enum escape_state outer_state; @@ -1141,6 +1141,24 @@ handle_dcs(struct terminal *terminal) static void handle_osc(struct terminal *terminal) { + char *p; + int code; + + terminal->escape[terminal->escape_length++] = '\0'; + p = &terminal->escape[2]; + code = strtol(p, &p, 10); + if (*p == ';') p++; + + switch (code) { + case 0: /* Icon name and window title */ + case 1: /* Icon label */ + case 2: /* Window title*/ + window_set_title(terminal->window, p); + break; + default: + fprintf(stderr, "Unknown OSC escape code %d\n", code); + break; + } } static void @@ -1152,6 +1170,7 @@ handle_escape(struct terminal *terminal) int i, count, x, y, top, bottom; int args[10], set[10] = { 0, }; char response[MAX_RESPONSE] = {0, }; + struct rectangle allocation; terminal->escape[terminal->escape_length++] = '\0'; i = 0; @@ -1474,6 +1493,51 @@ handle_escape(struct terminal *terminal) terminal->saved_row = terminal->row; terminal->saved_column = terminal->column; break; + case 't': /* windowOps */ + if (!set[0]) break; + switch (args[0]) { + case 4: /* resize px */ + if (set[1] && set[2]) { + window_set_child_size(terminal->window, + args[2], args[1]); + resize_handler(terminal->window, + args[2], args[1], terminal); + } + break; + case 8: /* resize ch */ + if (set[1] && set[2]) { + terminal_resize(terminal, args[2], args[1]); + } + break; + case 13: /* report position */ + window_get_child_allocation(terminal->window, &allocation); + snprintf(response, MAX_RESPONSE, "\e[3;%d;%dt", + allocation.x, allocation.y); + write(terminal->master, response, strlen(response)); + break; + case 14: /* report px */ + window_get_child_allocation(terminal->window, &allocation); + snprintf(response, MAX_RESPONSE, "\e[4;%d;%dt", + allocation.height, allocation.width); + write(terminal->master, response, strlen(response)); + break; + case 18: /* report ch */ + snprintf(response, MAX_RESPONSE, "\e[9;%d;%dt", + terminal->height, terminal->width); + write(terminal->master, response, strlen(response)); + break; + case 21: /* report title */ + snprintf(response, MAX_RESPONSE, "\e]l%s\e\\", + window_get_title(terminal->window)); + write(terminal->master, response, strlen(response)); + break; + default: + if (args[0] >= 24) + terminal_resize(terminal, terminal->width, args[0]); + else + fprintf(stderr, "Unimplemented windowOp %d\n", args[0]); + break; + } case 'u': terminal->row = terminal->saved_row; terminal->column = terminal->saved_column; diff --git a/clients/window.c b/clients/window.c index 59ea975..cad8040 100644 --- a/clients/window.c +++ b/clients/window.c @@ -1234,6 +1234,19 @@ window_set_keyboard_focus_handler(struct window *window, } void +window_set_title(struct window *window, const char *title) +{ + free((void*) window->title); + window->title = strdup(title); +} + +const char * +window_get_title(struct window *window) +{ + return window->title; +} + +void window_damage(struct window *window, int32_t x, int32_t y, int32_t width, int32_t height) { @@ -1273,12 +1286,6 @@ window_create_internal(struct display *display, struct window *parent, return window; } -void -window_set_title(struct window *window, const char *title) -{ - window->title = strdup(title); -} - struct window * window_create(struct display *display, int32_t width, int32_t height) { diff --git a/clients/window.h b/clients/window.h index 8ef8edd..0473b81 100644 --- a/clients/window.h +++ b/clients/window.h @@ -137,9 +137,6 @@ void window_destroy(struct window *window); void -window_set_title(struct window *window, const char *title); - -void window_move(struct window *window, struct input *input, uint32_t time); void @@ -147,6 +144,7 @@ window_draw(struct window *window); void window_get_child_allocation(struct window *window, struct rectangle *allocation); + void window_set_child_size(struct window *window, int32_t width, int32_t height); void @@ -213,6 +211,16 @@ window_set_keyboard_focus_handler(struct window *window, window_keyboard_focus_handler_t handler); void +window_set_frame_handler(struct window *window, + window_frame_handler_t handler); + +void +window_set_title(struct window *window, const char *title); + +const char * +window_get_title(struct window *window); + +void display_set_global_handler(struct display *display, display_global_handler_t handler); |