struct window *window;
struct display *display;
uint32_t key;
-
- gboolean redraw_scheduled;
-
gchar *filename;
};
cairo_t *cr;
cairo_surface_t *wsurface, *surface;
- image->redraw_scheduled = 0;
-
window_draw(image->window);
window_get_child_rectangle(image->window, &rectangle);
cairo_surface_destroy(surface);
}
-static gboolean
-image_idle_redraw(void *data)
-{
- struct image *image = data;
-
- image_draw(image);
-
- return FALSE;
-}
-
-static void
-image_schedule_redraw(struct image *image)
-{
- if (!image->redraw_scheduled) {
- image->redraw_scheduled = 1;
- g_idle_add(image_idle_redraw, image);
- }
-}
-
static void
-resize_handler(struct window *window, void *data)
+redraw_handler(struct window *window, void *data)
{
struct image *image = data;
- image_schedule_redraw(image);
+ image_draw(image);
}
static void
{
struct image *image = data;
- image_schedule_redraw(image);
+ window_schedule_redraw(image->window);
}
static struct image *
* allocation scheme here. Or maybe just a real toolkit. */
image->key = key + 100;
- window_set_resize_handler(image->window, resize_handler, image);
+ window_set_redraw_handler(image->window, redraw_handler, image);
window_set_keyboard_focus_handler(image->window, keyboard_focus_handler, image);
image_draw(image);
struct terminal {
struct window *window;
struct display *display;
- int redraw_scheduled;
char *data;
int width, height, start, row, column;
int fd, master;
window_commit(terminal->window, 0);
}
-static gboolean
-idle_redraw(void *data)
+static void
+redraw_handler(struct window *window, void *data)
{
struct terminal *terminal = data;
terminal_draw(terminal);
- terminal->redraw_scheduled = 0;
-
- return FALSE;
}
#define STATE_NORMAL 0
terminal_data(struct terminal *terminal, const char *data, size_t length);
static void
-terminal_schedule_redraw(struct terminal *terminal)
-{
- if (!terminal->redraw_scheduled) {
- g_idle_add(idle_redraw, terminal);
- terminal->redraw_scheduled = 1;
- }
-}
-
-static void
handle_escape(struct terminal *terminal)
{
char *row, *p;
}
}
- terminal_schedule_redraw(terminal);
-}
-
-static void
-resize_handler(struct window *window, void *data)
-{
- struct terminal *terminal = data;
-
- terminal_schedule_redraw(terminal);
+ window_schedule_redraw(terminal->window);
}
static void
break;
terminal->fullscreen ^= 1;
window_set_fullscreen(window, terminal->fullscreen);
- terminal_schedule_redraw(terminal);
+ window_schedule_redraw(terminal->window);
break;
default:
if (state && unicode)
struct terminal *terminal = data;
terminal->focused = (device != NULL);
- terminal_schedule_redraw(terminal);
+ window_schedule_redraw(terminal->window);
}
static struct terminal *
terminal->margin = 5;
window_set_fullscreen(terminal->window, terminal->fullscreen);
- window_set_resize_handler(terminal->window, resize_handler, terminal);
+ window_set_redraw_handler(terminal->window,
+ redraw_handler, terminal);
window_set_key_handler(terminal->window, key_handler, terminal);
window_set_keyboard_focus_handler(terminal->window,
cairo_destroy(cr);
cairo_surface_destroy(surface);
-
terminal_draw(terminal);
return terminal;
struct display *display;
uint32_t key;
- gboolean redraw_scheduled;
-
gchar *filename;
PopplerDocument *document;
int page;
PopplerPage *page;
double width, height, doc_aspect, window_aspect, scale;
- view->redraw_scheduled = 0;
-
window_draw(view->window);
window_get_child_rectangle(view->window, &rectangle);
window_commit(view->window, 0);
}
-static gboolean
-view_idle_redraw(void *data)
+static void
+redraw_handler(struct window *window, void *data)
{
struct view *view = data;
view_draw(view);
-
- return FALSE;
-}
-
-static void
-view_schedule_redraw(struct view *view)
-{
- if (!view->redraw_scheduled) {
- view->redraw_scheduled = 1;
- g_idle_add(view_idle_redraw, view);
- }
}
static void
break;
view->fullscreen ^= 1;
window_set_fullscreen(window, view->fullscreen);
- view_schedule_redraw(view);
+ window_schedule_redraw(view->window);
break;
case KEY_SPACE:
case KEY_PAGEDOWN:
if (!state)
break;
view->page++;
- view_schedule_redraw(view);
+ window_schedule_redraw(view->window);
break;
case KEY_BACKSPACE:
case KEY_PAGEUP:
if (!state)
break;
view->page--;
- view_schedule_redraw(view);
+ window_schedule_redraw(view->window);
break;
default:
break;
}
static void
-resize_handler(struct window *window, void *data)
-{
- struct view *view = data;
-
- view_schedule_redraw(view);
-}
-
-static void
keyboard_focus_handler(struct window *window,
struct wl_input_device *device, void *data)
{
struct view *view = data;
view->focused = (device != NULL);
- view_schedule_redraw(view);
+ window_schedule_redraw(view->window);
}
static struct view *
/* FIXME: Window uses key 1 for moves, need some kind of
* allocation scheme here. Or maybe just a real toolkit. */
view->key = key + 100;
- view->redraw_scheduled = 1;
- window_set_resize_handler(view->window, resize_handler, view);
+ window_set_redraw_handler(view->window, redraw_handler, view);
window_set_key_handler(view->window, key_handler, view);
window_set_keyboard_focus_handler(view->window,
keyboard_focus_handler, view);
struct wl_surface *surface;
const char *title;
struct rectangle allocation, saved_allocation, surface_allocation;
+ int redraw_scheduled;
int minimum_width, minimum_height;
int margin;
int drag_x, drag_y;
cairo_surface_t *cairo_surface, *pending_surface;
window_resize_handler_t resize_handler;
+ window_redraw_handler_t redraw_handler;
window_key_handler_t key_handler;
window_keyboard_focus_handler_t keyboard_focus_handler;
window_acknowledge_handler_t acknowledge_handler;
if (window->resize_handler)
(*window->resize_handler)(window,
window->user_data);
-
+ else if (window->redraw_handler)
+ window_schedule_redraw(window);
break;
}
}
cairo_destroy (cr);
}
+static gboolean
+idle_redraw(void *data)
+{
+ struct window *window = data;
+
+ window->redraw_handler(window, window->user_data);
+ window->redraw_scheduled = 0;
+
+ return FALSE;
+}
+
+void
+window_schedule_redraw(struct window *window)
+{
+ if (!window->redraw_scheduled) {
+ g_idle_add(idle_redraw, window);
+ window->redraw_scheduled = 1;
+ }
+}
+
void
window_set_fullscreen(struct window *window, int fullscreen)
{
}
void
+window_set_redraw_handler(struct window *window,
+ window_redraw_handler_t handler, void *data)
+{
+ window->redraw_handler = handler;
+ window->user_data = data;
+}
+
+void
window_set_key_handler(struct window *window,
window_key_handler_t handler, void *data)
{
{
struct display *d = data;
struct window *window;
- cairo_surface_t *pending;
/* The acknowledge event means that the server processed our
* last commit request and we can now safely free the old
};
typedef void (*window_resize_handler_t)(struct window *window, void *data);
+typedef void (*window_redraw_handler_t)(struct window *window, void *data);
typedef void (*window_frame_handler_t)(struct window *window, uint32_t frame, uint32_t timestamp, void *data);
typedef void (*window_acknowledge_handler_t)(struct window *window, uint32_t key, uint32_t frame, void *data);
typedef void (*window_key_handler_t)(struct window *window, uint32_t key, uint32_t unicode,
window_copy_image(struct window *window,
struct rectangle *rectangle,
void *image);
+void
+window_schedule_redraw(struct window *window);
void
window_move(struct window *window, int32_t x, int32_t y);
window_set_fullscreen(struct window *window, int fullscreen);
void
+window_set_redraw_handler(struct window *window,
+ window_redraw_handler_t handler, void *data);
+
+void
window_set_decoration(struct window *window, int decoration);
void