Merge remote branch 'callum/master'

Conflicts:
	clients/window.h
dev
Kristian Høgsberg 14 years ago
commit 6ec41abf72
  1. 70
      clients/terminal.c
  2. 19
      clients/window.c
  3. 14
      clients/window.h

@ -54,8 +54,8 @@ static int option_fullscreen;
#define ATTRMASK_CONCEALED 0x10 #define ATTRMASK_CONCEALED 0x10
/* Buffer sizes */ /* Buffer sizes */
#define MAX_RESPONSE 11 #define MAX_RESPONSE 256
#define MAX_ESCAPE 64 #define MAX_ESCAPE 255
/* Terminal modes */ /* Terminal modes */
#define MODE_SHOW_CURSOR 0x00000001 #define MODE_SHOW_CURSOR 0x00000001
@ -377,7 +377,7 @@ struct terminal {
int fd, master; int fd, master;
GIOChannel *channel; GIOChannel *channel;
uint32_t modifiers; uint32_t modifiers;
char escape[MAX_ESCAPE]; char escape[MAX_ESCAPE+1];
int escape_length; int escape_length;
enum escape_state state; enum escape_state state;
enum escape_state outer_state; enum escape_state outer_state;
@ -1141,6 +1141,24 @@ handle_dcs(struct terminal *terminal)
static void static void
handle_osc(struct terminal *terminal) 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 static void
@ -1152,6 +1170,7 @@ handle_escape(struct terminal *terminal)
int i, count, x, y, top, bottom; int i, count, x, y, top, bottom;
int args[10], set[10] = { 0, }; int args[10], set[10] = { 0, };
char response[MAX_RESPONSE] = {0, }; char response[MAX_RESPONSE] = {0, };
struct rectangle allocation;
terminal->escape[terminal->escape_length++] = '\0'; terminal->escape[terminal->escape_length++] = '\0';
i = 0; i = 0;
@ -1474,6 +1493,51 @@ handle_escape(struct terminal *terminal)
terminal->saved_row = terminal->row; terminal->saved_row = terminal->row;
terminal->saved_column = terminal->column; terminal->saved_column = terminal->column;
break; 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': case 'u':
terminal->row = terminal->saved_row; terminal->row = terminal->saved_row;
terminal->column = terminal->saved_column; terminal->column = terminal->saved_column;

@ -1233,6 +1233,19 @@ window_set_keyboard_focus_handler(struct window *window,
window->keyboard_focus_handler = handler; window->keyboard_focus_handler = handler;
} }
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 void
window_damage(struct window *window, int32_t x, int32_t y, window_damage(struct window *window, int32_t x, int32_t y,
int32_t width, int32_t height) int32_t width, int32_t height)
@ -1273,12 +1286,6 @@ window_create_internal(struct display *display, struct window *parent,
return window; return window;
} }
void
window_set_title(struct window *window, const char *title)
{
window->title = strdup(title);
}
struct window * struct window *
window_create(struct display *display, int32_t width, int32_t height) window_create(struct display *display, int32_t width, int32_t height)
{ {

@ -136,9 +136,6 @@ window_create_transient(struct display *display, struct window *parent,
void void
window_destroy(struct window *window); window_destroy(struct window *window);
void
window_set_title(struct window *window, const char *title);
void void
window_move(struct window *window, struct input *input, uint32_t time); window_move(struct window *window, struct input *input, uint32_t time);
@ -147,6 +144,7 @@ window_draw(struct window *window);
void void
window_get_child_allocation(struct window *window, window_get_child_allocation(struct window *window,
struct rectangle *allocation); struct rectangle *allocation);
void void
window_set_child_size(struct window *window, int32_t width, int32_t height); window_set_child_size(struct window *window, int32_t width, int32_t height);
void void
@ -212,6 +210,16 @@ void
window_set_keyboard_focus_handler(struct window *window, window_set_keyboard_focus_handler(struct window *window,
window_keyboard_focus_handler_t handler); 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 void
display_set_global_handler(struct display *display, display_set_global_handler(struct display *display,
display_global_handler_t handler); display_global_handler_t handler);

Loading…
Cancel
Save