Compare commits
2 commits
793918f86f
...
9aac4865dc
Author | SHA1 | Date | |
---|---|---|---|
|
9aac4865dc | ||
|
68211499e8 |
2 changed files with 28 additions and 10 deletions
|
@ -30,14 +30,17 @@ int text_node_handle(UINode *node, enum UIEvent ev, size_t d, void *p)
|
|||
|
||||
if (n->pending_text) {
|
||||
if (n->layout) {
|
||||
g_object_unref(n->layout);
|
||||
pango_layout_set_text(n->layout, n->pending_text, -1);
|
||||
pango_cairo_update_layout(node->drw, n->layout);
|
||||
n->pending_text = NULL;
|
||||
} else {
|
||||
PangoLayout *layout = pango_cairo_create_layout(n->node.drw);
|
||||
pango_layout_set_font_description(layout, n->desc);
|
||||
pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_END);
|
||||
pango_layout_set_text(layout, n->pending_text, -1);
|
||||
n->layout = layout;
|
||||
n->pending_text = NULL;
|
||||
}
|
||||
PangoLayout *layout = pango_cairo_create_layout(n->node.drw);
|
||||
pango_layout_set_font_description(layout, n->desc);
|
||||
pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_END);
|
||||
pango_layout_set_text(layout, n->pending_text, -1);
|
||||
n->layout = layout;
|
||||
n->pending_text = NULL;
|
||||
}
|
||||
|
||||
switch (ev) {
|
||||
|
|
21
src/window.c
21
src/window.c
|
@ -1,8 +1,9 @@
|
|||
#include "cairo.h"
|
||||
#include "rect.h"
|
||||
#include "timeutil.h"
|
||||
#include "window.h"
|
||||
#include "node.h"
|
||||
//#define PROF
|
||||
#define PROF
|
||||
#include "prof.c"
|
||||
#include "time.h"
|
||||
#include <stdint.h>
|
||||
|
@ -10,6 +11,7 @@
|
|||
#include <sys/poll.h>
|
||||
#include <time.h>
|
||||
#include <xcb/xcb.h>
|
||||
#include <xcb/xproto.h>
|
||||
|
||||
void _window_process_xcb_event(UIWindow *window, xcb_generic_event_t *event);
|
||||
|
||||
|
@ -168,11 +170,17 @@ void _window_process_xcb_event(UIWindow *window, xcb_generic_event_t *event)
|
|||
uint8_t event_type = event->response_type & ~0x80;
|
||||
switch (event_type) {
|
||||
case XCB_EXPOSE: {
|
||||
begin_clock("XCB_EXPOSE");
|
||||
xcb_expose_event_t *ev = (xcb_expose_event_t*)event;
|
||||
UIRect region = { ev->x, ev->y, ev->width, ev->height };
|
||||
window->invalid_region = ui_rect_united(&window->invalid_region, ®ion);
|
||||
window_invalidate_node(window, window->root);
|
||||
end_clock();
|
||||
break;
|
||||
}
|
||||
|
||||
case XCB_CONFIGURE_NOTIFY: {
|
||||
begin_clock("XCB_CONFIGURE_NOTIFY");
|
||||
xcb_configure_notify_event_t *ev = (xcb_configure_notify_event_t*)event;
|
||||
UIRect new_rect = { 0, 0, ev->width, ev->height };
|
||||
if (!ui_rect_equals(&window->root->rect, &new_rect)) {
|
||||
|
@ -182,13 +190,14 @@ void _window_process_xcb_event(UIWindow *window, xcb_generic_event_t *event)
|
|||
window->root->rect.w = ev->width;
|
||||
window->root->rect.h = ev->height;
|
||||
node_dispatch(window->root, UI_EVENT_RELAYOUT, 0, NULL);
|
||||
window_invalidate_node(window, window->root);
|
||||
node_dump(window->root, 0);
|
||||
}
|
||||
end_clock();
|
||||
break;
|
||||
}
|
||||
|
||||
case XCB_MOTION_NOTIFY: {
|
||||
begin_clock("XCB_MOTION_NOTIFY");
|
||||
xcb_motion_notify_event_t *ev = (xcb_motion_notify_event_t*)event;
|
||||
UINode *node = node_by_point(window->root, ev->event_x, ev->event_y);
|
||||
if (node && node != window->hovered) {
|
||||
|
@ -199,11 +208,13 @@ void _window_process_xcb_event(UIWindow *window, xcb_generic_event_t *event)
|
|||
}
|
||||
node_dispatch(node, UI_EVENT_HOVERED, 0, NULL);
|
||||
}
|
||||
end_clock();
|
||||
break;
|
||||
}
|
||||
|
||||
case XCB_BUTTON_RELEASE: /* through */
|
||||
case XCB_BUTTON_PRESS: {
|
||||
begin_clock("XCB_BUTTON_PRESS");
|
||||
xcb_button_press_event_t *ev = (xcb_button_press_event_t*)event;
|
||||
UINode *node = node_by_point(window->root, ev->event_x, ev->event_y);
|
||||
if (node) {
|
||||
|
@ -254,6 +265,7 @@ void _window_process_xcb_event(UIWindow *window, xcb_generic_event_t *event)
|
|||
}
|
||||
}
|
||||
}
|
||||
end_clock();
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -325,6 +337,7 @@ int window_turn(UIWindow *window)
|
|||
|
||||
clear_summary();
|
||||
|
||||
begin_clock("Frame");
|
||||
int64_t frame_start_ms = time_current_ms();
|
||||
for (int i = 0; i < UI_WINDOW_MAX_POLL; i++) {
|
||||
if (fds[i].revents & POLLNVAL) {
|
||||
|
@ -389,7 +402,9 @@ int window_turn(UIWindow *window)
|
|||
printf("peak frametime: %ldms\n", frame_peak_ms);
|
||||
}
|
||||
|
||||
dump_summary();
|
||||
end_clock();
|
||||
|
||||
dump_summary(stdout);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue