libnsfb: branch vince/wayland updated. 504b977986d6fbeac321080d213b5a8cbc358a8d
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/libnsfb.git/shortlog/504b977986d6fbeac3210...
...commit http://git.netsurf-browser.org/libnsfb.git/commit/504b977986d6fbeac321080...
...tree http://git.netsurf-browser.org/libnsfb.git/tree/504b977986d6fbeac321080d2...
The branch, vince/wayland has been updated
via 504b977986d6fbeac321080d213b5a8cbc358a8d (commit)
via 3bddccd91760120f8222a4de0e0dccf2ec00b5d5 (commit)
from e9fb6419fee39416f16d09d4505bd6c8ebf05045 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/libnsfb.git/commit/?id=504b977986d6fbeac32...
commit 504b977986d6fbeac321080d213b5a8cbc358a8d
Author: Vincent Sanders <vincent.sanders(a)collabora.co.uk>
Commit: Vincent Sanders <vincent.sanders(a)collabora.co.uk>
start on pointer input
diff --git a/src/surface/wld.c b/src/surface/wld.c
index 087b990..3780431 100644
--- a/src/surface/wld.c
+++ b/src/surface/wld.c
@@ -56,14 +56,31 @@ struct wld_connection {
/** shared memory formats available */
uint32_t shm_formats;
+
+ /** list of input seats */
+ struct wl_list input_list;
};
-/* wayland window encompasing the display and shell surfaces */
+/** wayland input seat */
+struct wld_input {
+ struct wl_list link; /**< input list */
+
+ struct wld_connection* connection; /**< connection to wayland server */
+
+ struct wl_seat *seat; /**< The seat object */
+
+ struct wl_pointer *pointer;
+ struct wl_keyboard *keyboard;
+
+
+};
+
+/** wayland window encompasing the display and shell surfaces */
struct wld_window {
struct wld_connection* connection; /**< connection to wayland server */
- struct wl_surface *surface;
- struct wl_shell_surface *shell_surface;
+ struct wl_surface *surface; /**< drawing surface object */
+ struct wl_shell_surface *shell_surface; /**< shell surface object */
int width, height;
};
@@ -841,6 +858,210 @@ struct wl_shm_listener shm_listenter = {
shm_format
};
+static void
+pointer_handle_enter(void *data, struct wl_pointer *pointer,
+ uint32_t serial, struct wl_surface *surface,
+ wl_fixed_t sx_w, wl_fixed_t sy_w)
+{
+#if 0
+ struct input *input = data;
+ struct window *window;
+ struct widget *widget;
+ float sx = wl_fixed_to_double(sx_w);
+ float sy = wl_fixed_to_double(sy_w);
+
+ if (!surface) {
+ /* enter event for a window we've just destroyed */
+ return;
+ }
+
+ input->display->serial = serial;
+ input->pointer_enter_serial = serial;
+ input->pointer_focus = wl_surface_get_user_data(surface);
+ window = input->pointer_focus;
+
+ if (window->resizing) {
+ window->resizing = 0;
+ /* Schedule a redraw to free the pool */
+ window_schedule_redraw(window);
+ }
+
+ input->sx = sx;
+ input->sy = sy;
+
+ widget = window_find_widget(window, sx, sy);
+ input_set_focus_widget(input, widget, sx, sy);
+
+#endif
+}
+
+static void
+pointer_handle_leave(void *data, struct wl_pointer *pointer,
+ uint32_t serial, struct wl_surface *surface)
+{
+#if 0
+ struct input *input = data;
+
+ input->display->serial = serial;
+ input_remove_pointer_focus(input);
+#endif
+}
+
+static void
+pointer_handle_motion(void *data, struct wl_pointer *pointer,
+ uint32_t time, wl_fixed_t sx_w, wl_fixed_t sy_w)
+{
+#if 0
+ struct input *input = data;
+ struct window *window = input->pointer_focus;
+ struct widget *widget;
+ int cursor;
+ float sx = wl_fixed_to_double(sx_w);
+ float sy = wl_fixed_to_double(sy_w);
+
+ input->sx = sx;
+ input->sy = sy;
+
+ if (!window)
+ return;
+
+ if (!(input->grab && input->grab_button)) {
+ widget = window_find_widget(window, sx, sy);
+ input_set_focus_widget(input, widget, sx, sy);
+ }
+
+ if (input->grab)
+ widget = input->grab;
+ else
+ widget = input->focus_widget;
+ if (widget && widget->motion_handler)
+ cursor = widget->motion_handler(input->focus_widget,
+ input, time, sx, sy,
+ widget->user_data);
+ else
+ cursor = input->focus_widget->default_cursor;
+
+ input_set_pointer_image(input, cursor);
+#endif
+}
+
+static void
+pointer_handle_button(void *data, struct wl_pointer *pointer, uint32_t serial,
+ uint32_t time, uint32_t button, uint32_t state_w)
+{
+#if 0
+ struct input *input = data;
+ struct widget *widget;
+ enum wl_pointer_button_state state = state_w;
+
+ input->display->serial = serial;
+ if (input->focus_widget && input->grab == NULL &&
+ state == WL_POINTER_BUTTON_STATE_PRESSED)
+ input_grab(input, input->focus_widget, button);
+
+ widget = input->grab;
+ if (widget && widget->button_handler)
+ (*widget->button_handler)(widget,
+ input, time,
+ button, state,
+ input->grab->user_data);
+
+ if (input->grab && input->grab_button == button &&
+ state == WL_POINTER_BUTTON_STATE_RELEASED)
+ input_ungrab(input);
+#endif
+}
+
+static void
+pointer_handle_axis(void *data, struct wl_pointer *pointer,
+ uint32_t time, uint32_t axis, wl_fixed_t value)
+{
+#if 0
+ struct input *input = data;
+ struct widget *widget;
+
+ widget = input->focus_widget;
+ if (input->grab)
+ widget = input->grab;
+ if (widget && widget->axis_handler)
+ (*widget->axis_handler)(widget,
+ input, time,
+ axis, value,
+ widget->user_data);
+#endif
+}
+
+static const struct wl_pointer_listener pointer_listener = {
+ pointer_handle_enter,
+ pointer_handle_leave,
+ pointer_handle_motion,
+ pointer_handle_button,
+ pointer_handle_axis,
+};
+
+static void
+seat_handle_capabilities(void *data,
+ struct wl_seat *seat,
+ enum wl_seat_capability caps)
+{
+ struct wld_input *input = data;
+#if 0
+ if ((caps & WL_SEAT_CAPABILITY_POINTER) && !input->pointer) {
+ input->pointer = wl_seat_get_pointer(seat);
+
+ wl_pointer_add_listener(input->pointer, &pointer_listener, input);
+
+ } else if (!(caps & WL_SEAT_CAPABILITY_POINTER) && input->pointer) {
+
+ wl_pointer_destroy(input->pointer);
+ input->pointer = NULL;
+ }
+#endif
+#if 0
+ if ((caps & WL_SEAT_CAPABILITY_KEYBOARD) && !input->keyboard) {
+ input->keyboard = wl_seat_get_keyboard(seat);
+
+ wl_keyboard_add_listener(input->keyboard, &keyboard_listener, input);
+
+ } else if (!(caps & WL_SEAT_CAPABILITY_KEYBOARD) && input->keyboard) {
+
+ wl_keyboard_destroy(input->keyboard);
+ input->keyboard = NULL;
+ }
+#endif
+}
+
+static const struct wl_seat_listener seat_listener = {
+ seat_handle_capabilities,
+};
+
+/**
+ * new seat added
+ */
+static struct wld_input *
+new_input_seat(struct wld_connection *connection,
+ struct wl_registry *registry,
+ uint32_t id)
+{
+ struct wld_input *input;
+
+ input = calloc(1, sizeof(struct wld_input));
+ if (input == NULL) {
+ return NULL;
+ }
+
+ input->connection = connection;
+
+ input->seat = wl_registry_bind(registry, id, &wl_seat_interface, 1);
+ if (input->seat == NULL) {
+ free(input);
+ return NULL;
+ }
+
+ //wl_seat_add_listener(input->seat, &seat_listener, input);
+
+ return input;
+}
/** registry global addition callback
*
@@ -883,6 +1104,14 @@ registry_handle_global(void *ctx,
connection->shm_formats = 0;
wl_shm_add_listener(connection->shm, &shm_listenter, connection);
}
+
+ } else if (strcmp(interface, "wl_seat") == 0) {
+ struct wld_input *input;
+
+ input = new_input_seat(connection, registry, id);
+ if (input != NULL) {
+ wl_list_insert(connection->input_list.prev, &input->link);
+ }
}
}
@@ -939,6 +1168,9 @@ new_connection(void)
return NULL;
}
+ /* initialise lists */
+ wl_list_init(&connection->input_list);
+
/* make a connection to the wayland server */
connection->display = wl_display_connect(NULL);
if (connection->display == NULL) {
commitdiff http://git.netsurf-browser.org/libnsfb.git/commit/?id=3bddccd91760120f822...
commit 3bddccd91760120f8222a4de0e0dccf2ec00b5d5
Author: Vincent Sanders <vincent.sanders(a)collabora.co.uk>
Commit: Vincent Sanders <vincent.sanders(a)collabora.co.uk>
fix event dispatch to use timeouts
diff --git a/src/surface/wld.c b/src/surface/wld.c
index 76067e7..087b990 100644
--- a/src/surface/wld.c
+++ b/src/surface/wld.c
@@ -20,14 +20,6 @@
#include <fcntl.h>
#include <sys/mman.h>
-#if 0
-#include <xcb/xcb.h>
-#include <xcb/xcb_image.h>
-#include <xcb/xcb_atom.h>
-#include <xcb/xcb_icccm.h>
-#include <xcb/xcb_aux.h>
-#include <xcb/xcb_keysyms.h>
-#endif
#include <wayland-client.h>
#include "libnsfb.h"
@@ -85,25 +77,11 @@ struct wld_shm_buffer {
*/
};
+
typedef struct wldstate_s {
struct wld_connection* connection; /**< connection to wayland server */
struct wld_window *window;
struct wld_shm_buffer *shm_buffer;
-#if 0
- xcb_connection_t *connection; /* The x server connection */
- xcb_screen_t *screen; /* The screen to put the window on */
- xcb_key_symbols_t *keysymbols; /* keysym mappings */
-
- xcb_shm_segment_info_t shminfo;
-
- xcb_image_t *image; /* The X image buffer */
-
- xcb_window_t window; /* The handle to the window */
- xcb_pixmap_t pmap; /* The handle to the backing pixmap */
- xcb_gcontext_t gc; /* The handle to the pixmap plotting graphics context */
- xcb_shm_seg_t segment; /* The handle to the image shared memory */
-#endif
-
} wldstate_t;
@@ -839,7 +817,7 @@ create_blank_cursor(xcb_connection_t *conn, const xcb_screen_t *scr)
}
return cur;
}
-#endif
+#endif
/** shared memory interface format available callback
@@ -1015,14 +993,14 @@ new_connection(void)
static int
update_and_redraw(struct wldstate_s *wldstate,
- int x,
- int y,
- int width,
+ int x,
+ int y,
+ int width,
int height)
{
- wl_surface_attach(wldstate->window->surface,
- wldstate->shm_buffer->buffer,
- 0,
+ wl_surface_attach(wldstate->window->surface,
+ wldstate->shm_buffer->buffer,
+ 0,
0);
wl_surface_damage(wldstate->window->surface, x, y, width, height);
@@ -1030,7 +1008,7 @@ update_and_redraw(struct wldstate_s *wldstate,
wl_surface_commit(wldstate->window->surface);
wldstate->shm_buffer->inuse = true;
- /** @todo should this be here? */
+ /* force syncronisation to cause the update */
wl_display_roundtrip(wldstate->connection->display);
return 0;
@@ -1179,9 +1157,9 @@ static const struct wl_buffer_listener buffer_listener = {
};
static struct wld_shm_buffer *
-new_shm_buffer(struct wl_shm *shm,
- int width,
- int height,
+new_shm_buffer(struct wl_shm *shm,
+ int width,
+ int height,
uint32_t format)
{
struct wl_shm_pool *pool;
@@ -1203,11 +1181,11 @@ new_shm_buffer(struct wl_shm *shm,
return NULL;
}
- shmbuff->data = mmap(NULL,
- shmbuff->size,
- PROT_READ | PROT_WRITE,
- MAP_SHARED,
- fd,
+ shmbuff->data = mmap(NULL,
+ shmbuff->size,
+ PROT_READ | PROT_WRITE,
+ MAP_SHARED,
+ fd,
0);
if (shmbuff->data == MAP_FAILED) {
close(fd);
@@ -1281,9 +1259,9 @@ static int wld_initialise(nsfb_t *nsfb)
return -1; /* error */
}
- wldstate->shm_buffer = new_shm_buffer(wldstate->connection->shm,
- nsfb->width,
- nsfb->height,
+ wldstate->shm_buffer = new_shm_buffer(wldstate->connection->shm,
+ nsfb->width,
+ nsfb->height,
WL_SHM_FORMAT_XRGB8888);
if (wldstate->shm_buffer == NULL) {
fprintf(stderr, "Error creating wayland shared memory\n");
@@ -1453,20 +1431,49 @@ static int x_finalise(nsfb_t *nsfb)
return 0;
}
-#endif
+#endif
static bool wld_input(nsfb_t *nsfb, nsfb_event_t *event, int timeout)
{
wldstate_t *wldstate = nsfb->surface_priv;
- int ret = 0;
+ int ret = 0; /* number of events dispatched */
if (wldstate == NULL) {
return false;
}
- ret = wl_display_dispatch(wldstate->connection->display);
+ /* flush any pending outgoing messages to server */
+ wl_display_flush(wldstate->connection->display);
+
+ if (timeout < 0) {
+ /* caller wants to wait forever for an event */
+ ret = wl_display_dispatch(wldstate->connection->display);
+ } else {
+ int confd;
+ fd_set rfds;
+ struct timeval tv;
+ int retval;
+
+ confd = wl_display_get_fd(wldstate->connection->display);
+
+ FD_ZERO(&rfds);
+ FD_SET(confd, &rfds);
+
+ tv.tv_sec = timeout / 1000;
+ tv.tv_usec = timeout % 1000;
+
+ retval = select(confd + 1, &rfds, NULL, NULL, &tv);
+ if (retval == 0) {
+ /* timeout, nothing ready to read */
+ ret = wl_display_dispatch_pending(wldstate->connection->display);
+ } else {
+ ret = wl_display_dispatch(wldstate->connection->display);
+ }
+ }
+
+ /* check for connection error */
if (ret == -1) {
- /* error, time to quit */
+ /* exit on conenction error */
event->type = NSFB_EVENT_CONTROL;
event->value.controlcode = NSFB_CONTROL_QUIT;
return true;
@@ -1687,17 +1694,6 @@ x_cursor(nsfb_t *nsfb, struct nsfb_cursor_s *cursor)
static int wld_update(nsfb_t *nsfb, nsfb_bbox_t *box)
{
wldstate_t *wldstate = nsfb->surface_priv;
-
- if (wldstate != NULL) {
- update_and_redraw(wldstate, box->x0, box->y0, box->x1 - box->x0, box->y1 - box->y0);
- }
- return 0;
-}
-
-#if 0
-static int x_update(nsfb_t *nsfb, nsfb_bbox_t *box)
-{
- xstate_t *xstate = nsfb->surface_priv;
struct nsfb_cursor_s *cursor = nsfb->cursor;
if ((cursor != NULL) &&
@@ -1705,11 +1701,12 @@ static int x_update(nsfb_t *nsfb, nsfb_bbox_t *box)
nsfb_cursor_plot(nsfb, cursor);
}
- update_and_redraw_pixmap(xstate, box->x0, box->y0, box->x1 - box->x0, box->y1 - box->y0);
-
+ if (wldstate != NULL) {
+ update_and_redraw(wldstate, box->x0, box->y0, box->x1 - box->x0, box->y1 - box->y0);
+ }
return 0;
}
-#endif
+
const nsfb_surface_rtns_t wld_rtns = {
.initialise = wld_initialise,
-----------------------------------------------------------------------
Summary of changes:
src/surface/wld.c | 355 +++++++++++++++++++++++++++++++++++++++++++----------
1 files changed, 292 insertions(+), 63 deletions(-)
diff --git a/src/surface/wld.c b/src/surface/wld.c
index 76067e7..3780431 100644
--- a/src/surface/wld.c
+++ b/src/surface/wld.c
@@ -20,14 +20,6 @@
#include <fcntl.h>
#include <sys/mman.h>
-#if 0
-#include <xcb/xcb.h>
-#include <xcb/xcb_image.h>
-#include <xcb/xcb_atom.h>
-#include <xcb/xcb_icccm.h>
-#include <xcb/xcb_aux.h>
-#include <xcb/xcb_keysyms.h>
-#endif
#include <wayland-client.h>
#include "libnsfb.h"
@@ -64,14 +56,31 @@ struct wld_connection {
/** shared memory formats available */
uint32_t shm_formats;
+
+ /** list of input seats */
+ struct wl_list input_list;
+};
+
+/** wayland input seat */
+struct wld_input {
+ struct wl_list link; /**< input list */
+
+ struct wld_connection* connection; /**< connection to wayland server */
+
+ struct wl_seat *seat; /**< The seat object */
+
+ struct wl_pointer *pointer;
+ struct wl_keyboard *keyboard;
+
+
};
-/* wayland window encompasing the display and shell surfaces */
+/** wayland window encompasing the display and shell surfaces */
struct wld_window {
struct wld_connection* connection; /**< connection to wayland server */
- struct wl_surface *surface;
- struct wl_shell_surface *shell_surface;
+ struct wl_surface *surface; /**< drawing surface object */
+ struct wl_shell_surface *shell_surface; /**< shell surface object */
int width, height;
};
@@ -85,25 +94,11 @@ struct wld_shm_buffer {
*/
};
+
typedef struct wldstate_s {
struct wld_connection* connection; /**< connection to wayland server */
struct wld_window *window;
struct wld_shm_buffer *shm_buffer;
-#if 0
- xcb_connection_t *connection; /* The x server connection */
- xcb_screen_t *screen; /* The screen to put the window on */
- xcb_key_symbols_t *keysymbols; /* keysym mappings */
-
- xcb_shm_segment_info_t shminfo;
-
- xcb_image_t *image; /* The X image buffer */
-
- xcb_window_t window; /* The handle to the window */
- xcb_pixmap_t pmap; /* The handle to the backing pixmap */
- xcb_gcontext_t gc; /* The handle to the pixmap plotting graphics context */
- xcb_shm_seg_t segment; /* The handle to the image shared memory */
-#endif
-
} wldstate_t;
@@ -839,7 +834,7 @@ create_blank_cursor(xcb_connection_t *conn, const xcb_screen_t *scr)
}
return cur;
}
-#endif
+#endif
/** shared memory interface format available callback
@@ -863,6 +858,210 @@ struct wl_shm_listener shm_listenter = {
shm_format
};
+static void
+pointer_handle_enter(void *data, struct wl_pointer *pointer,
+ uint32_t serial, struct wl_surface *surface,
+ wl_fixed_t sx_w, wl_fixed_t sy_w)
+{
+#if 0
+ struct input *input = data;
+ struct window *window;
+ struct widget *widget;
+ float sx = wl_fixed_to_double(sx_w);
+ float sy = wl_fixed_to_double(sy_w);
+
+ if (!surface) {
+ /* enter event for a window we've just destroyed */
+ return;
+ }
+
+ input->display->serial = serial;
+ input->pointer_enter_serial = serial;
+ input->pointer_focus = wl_surface_get_user_data(surface);
+ window = input->pointer_focus;
+
+ if (window->resizing) {
+ window->resizing = 0;
+ /* Schedule a redraw to free the pool */
+ window_schedule_redraw(window);
+ }
+
+ input->sx = sx;
+ input->sy = sy;
+
+ widget = window_find_widget(window, sx, sy);
+ input_set_focus_widget(input, widget, sx, sy);
+
+#endif
+}
+
+static void
+pointer_handle_leave(void *data, struct wl_pointer *pointer,
+ uint32_t serial, struct wl_surface *surface)
+{
+#if 0
+ struct input *input = data;
+
+ input->display->serial = serial;
+ input_remove_pointer_focus(input);
+#endif
+}
+
+static void
+pointer_handle_motion(void *data, struct wl_pointer *pointer,
+ uint32_t time, wl_fixed_t sx_w, wl_fixed_t sy_w)
+{
+#if 0
+ struct input *input = data;
+ struct window *window = input->pointer_focus;
+ struct widget *widget;
+ int cursor;
+ float sx = wl_fixed_to_double(sx_w);
+ float sy = wl_fixed_to_double(sy_w);
+
+ input->sx = sx;
+ input->sy = sy;
+
+ if (!window)
+ return;
+
+ if (!(input->grab && input->grab_button)) {
+ widget = window_find_widget(window, sx, sy);
+ input_set_focus_widget(input, widget, sx, sy);
+ }
+
+ if (input->grab)
+ widget = input->grab;
+ else
+ widget = input->focus_widget;
+ if (widget && widget->motion_handler)
+ cursor = widget->motion_handler(input->focus_widget,
+ input, time, sx, sy,
+ widget->user_data);
+ else
+ cursor = input->focus_widget->default_cursor;
+
+ input_set_pointer_image(input, cursor);
+#endif
+}
+
+static void
+pointer_handle_button(void *data, struct wl_pointer *pointer, uint32_t serial,
+ uint32_t time, uint32_t button, uint32_t state_w)
+{
+#if 0
+ struct input *input = data;
+ struct widget *widget;
+ enum wl_pointer_button_state state = state_w;
+
+ input->display->serial = serial;
+ if (input->focus_widget && input->grab == NULL &&
+ state == WL_POINTER_BUTTON_STATE_PRESSED)
+ input_grab(input, input->focus_widget, button);
+
+ widget = input->grab;
+ if (widget && widget->button_handler)
+ (*widget->button_handler)(widget,
+ input, time,
+ button, state,
+ input->grab->user_data);
+
+ if (input->grab && input->grab_button == button &&
+ state == WL_POINTER_BUTTON_STATE_RELEASED)
+ input_ungrab(input);
+#endif
+}
+
+static void
+pointer_handle_axis(void *data, struct wl_pointer *pointer,
+ uint32_t time, uint32_t axis, wl_fixed_t value)
+{
+#if 0
+ struct input *input = data;
+ struct widget *widget;
+
+ widget = input->focus_widget;
+ if (input->grab)
+ widget = input->grab;
+ if (widget && widget->axis_handler)
+ (*widget->axis_handler)(widget,
+ input, time,
+ axis, value,
+ widget->user_data);
+#endif
+}
+
+static const struct wl_pointer_listener pointer_listener = {
+ pointer_handle_enter,
+ pointer_handle_leave,
+ pointer_handle_motion,
+ pointer_handle_button,
+ pointer_handle_axis,
+};
+
+static void
+seat_handle_capabilities(void *data,
+ struct wl_seat *seat,
+ enum wl_seat_capability caps)
+{
+ struct wld_input *input = data;
+#if 0
+ if ((caps & WL_SEAT_CAPABILITY_POINTER) && !input->pointer) {
+ input->pointer = wl_seat_get_pointer(seat);
+
+ wl_pointer_add_listener(input->pointer, &pointer_listener, input);
+
+ } else if (!(caps & WL_SEAT_CAPABILITY_POINTER) && input->pointer) {
+
+ wl_pointer_destroy(input->pointer);
+ input->pointer = NULL;
+ }
+#endif
+#if 0
+ if ((caps & WL_SEAT_CAPABILITY_KEYBOARD) && !input->keyboard) {
+ input->keyboard = wl_seat_get_keyboard(seat);
+
+ wl_keyboard_add_listener(input->keyboard, &keyboard_listener, input);
+
+ } else if (!(caps & WL_SEAT_CAPABILITY_KEYBOARD) && input->keyboard) {
+
+ wl_keyboard_destroy(input->keyboard);
+ input->keyboard = NULL;
+ }
+#endif
+}
+
+static const struct wl_seat_listener seat_listener = {
+ seat_handle_capabilities,
+};
+
+/**
+ * new seat added
+ */
+static struct wld_input *
+new_input_seat(struct wld_connection *connection,
+ struct wl_registry *registry,
+ uint32_t id)
+{
+ struct wld_input *input;
+
+ input = calloc(1, sizeof(struct wld_input));
+ if (input == NULL) {
+ return NULL;
+ }
+
+ input->connection = connection;
+
+ input->seat = wl_registry_bind(registry, id, &wl_seat_interface, 1);
+ if (input->seat == NULL) {
+ free(input);
+ return NULL;
+ }
+
+ //wl_seat_add_listener(input->seat, &seat_listener, input);
+
+ return input;
+}
/** registry global addition callback
*
@@ -905,6 +1104,14 @@ registry_handle_global(void *ctx,
connection->shm_formats = 0;
wl_shm_add_listener(connection->shm, &shm_listenter, connection);
}
+
+ } else if (strcmp(interface, "wl_seat") == 0) {
+ struct wld_input *input;
+
+ input = new_input_seat(connection, registry, id);
+ if (input != NULL) {
+ wl_list_insert(connection->input_list.prev, &input->link);
+ }
}
}
@@ -961,6 +1168,9 @@ new_connection(void)
return NULL;
}
+ /* initialise lists */
+ wl_list_init(&connection->input_list);
+
/* make a connection to the wayland server */
connection->display = wl_display_connect(NULL);
if (connection->display == NULL) {
@@ -1015,14 +1225,14 @@ new_connection(void)
static int
update_and_redraw(struct wldstate_s *wldstate,
- int x,
- int y,
- int width,
+ int x,
+ int y,
+ int width,
int height)
{
- wl_surface_attach(wldstate->window->surface,
- wldstate->shm_buffer->buffer,
- 0,
+ wl_surface_attach(wldstate->window->surface,
+ wldstate->shm_buffer->buffer,
+ 0,
0);
wl_surface_damage(wldstate->window->surface, x, y, width, height);
@@ -1030,7 +1240,7 @@ update_and_redraw(struct wldstate_s *wldstate,
wl_surface_commit(wldstate->window->surface);
wldstate->shm_buffer->inuse = true;
- /** @todo should this be here? */
+ /* force syncronisation to cause the update */
wl_display_roundtrip(wldstate->connection->display);
return 0;
@@ -1179,9 +1389,9 @@ static const struct wl_buffer_listener buffer_listener = {
};
static struct wld_shm_buffer *
-new_shm_buffer(struct wl_shm *shm,
- int width,
- int height,
+new_shm_buffer(struct wl_shm *shm,
+ int width,
+ int height,
uint32_t format)
{
struct wl_shm_pool *pool;
@@ -1203,11 +1413,11 @@ new_shm_buffer(struct wl_shm *shm,
return NULL;
}
- shmbuff->data = mmap(NULL,
- shmbuff->size,
- PROT_READ | PROT_WRITE,
- MAP_SHARED,
- fd,
+ shmbuff->data = mmap(NULL,
+ shmbuff->size,
+ PROT_READ | PROT_WRITE,
+ MAP_SHARED,
+ fd,
0);
if (shmbuff->data == MAP_FAILED) {
close(fd);
@@ -1281,9 +1491,9 @@ static int wld_initialise(nsfb_t *nsfb)
return -1; /* error */
}
- wldstate->shm_buffer = new_shm_buffer(wldstate->connection->shm,
- nsfb->width,
- nsfb->height,
+ wldstate->shm_buffer = new_shm_buffer(wldstate->connection->shm,
+ nsfb->width,
+ nsfb->height,
WL_SHM_FORMAT_XRGB8888);
if (wldstate->shm_buffer == NULL) {
fprintf(stderr, "Error creating wayland shared memory\n");
@@ -1453,20 +1663,49 @@ static int x_finalise(nsfb_t *nsfb)
return 0;
}
-#endif
+#endif
static bool wld_input(nsfb_t *nsfb, nsfb_event_t *event, int timeout)
{
wldstate_t *wldstate = nsfb->surface_priv;
- int ret = 0;
+ int ret = 0; /* number of events dispatched */
if (wldstate == NULL) {
return false;
}
- ret = wl_display_dispatch(wldstate->connection->display);
+ /* flush any pending outgoing messages to server */
+ wl_display_flush(wldstate->connection->display);
+
+ if (timeout < 0) {
+ /* caller wants to wait forever for an event */
+ ret = wl_display_dispatch(wldstate->connection->display);
+ } else {
+ int confd;
+ fd_set rfds;
+ struct timeval tv;
+ int retval;
+
+ confd = wl_display_get_fd(wldstate->connection->display);
+
+ FD_ZERO(&rfds);
+ FD_SET(confd, &rfds);
+
+ tv.tv_sec = timeout / 1000;
+ tv.tv_usec = timeout % 1000;
+
+ retval = select(confd + 1, &rfds, NULL, NULL, &tv);
+ if (retval == 0) {
+ /* timeout, nothing ready to read */
+ ret = wl_display_dispatch_pending(wldstate->connection->display);
+ } else {
+ ret = wl_display_dispatch(wldstate->connection->display);
+ }
+ }
+
+ /* check for connection error */
if (ret == -1) {
- /* error, time to quit */
+ /* exit on conenction error */
event->type = NSFB_EVENT_CONTROL;
event->value.controlcode = NSFB_CONTROL_QUIT;
return true;
@@ -1687,17 +1926,6 @@ x_cursor(nsfb_t *nsfb, struct nsfb_cursor_s *cursor)
static int wld_update(nsfb_t *nsfb, nsfb_bbox_t *box)
{
wldstate_t *wldstate = nsfb->surface_priv;
-
- if (wldstate != NULL) {
- update_and_redraw(wldstate, box->x0, box->y0, box->x1 - box->x0, box->y1 - box->y0);
- }
- return 0;
-}
-
-#if 0
-static int x_update(nsfb_t *nsfb, nsfb_bbox_t *box)
-{
- xstate_t *xstate = nsfb->surface_priv;
struct nsfb_cursor_s *cursor = nsfb->cursor;
if ((cursor != NULL) &&
@@ -1705,11 +1933,12 @@ static int x_update(nsfb_t *nsfb, nsfb_bbox_t *box)
nsfb_cursor_plot(nsfb, cursor);
}
- update_and_redraw_pixmap(xstate, box->x0, box->y0, box->x1 - box->x0, box->y1 - box->y0);
-
+ if (wldstate != NULL) {
+ update_and_redraw(wldstate, box->x0, box->y0, box->x1 - box->x0, box->y1 - box->y0);
+ }
return 0;
}
-#endif
+
const nsfb_surface_rtns_t wld_rtns = {
.initialise = wld_initialise,
--
NetSurf Framebuffer library
9 years, 10 months
netsurf: branch master updated. 53962009da5eb95a7c3146cdcce59c588d9bf3ce
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/53962009da5eb95a7c314...
...commit http://git.netsurf-browser.org/netsurf.git/commit/53962009da5eb95a7c3146c...
...tree http://git.netsurf-browser.org/netsurf.git/tree/53962009da5eb95a7c3146cdc...
The branch, master has been updated
via 53962009da5eb95a7c3146cdcce59c588d9bf3ce (commit)
via cc4411c0c7452968349725bf1edbcd1731422180 (commit)
from 7de97e8d6a2899a4811b494f74064989eeac1b00 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=53962009da5eb95a7c3...
commit 53962009da5eb95a7c3146cdcce59c588d9bf3ce
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Trivial redraw optimisation for multiline textareas. Only redraw the line that was changed and below.
diff --git a/desktop/textarea.c b/desktop/textarea.c
index 81af9f8..e614cc4 100644
--- a/desktop/textarea.c
+++ b/desktop/textarea.c
@@ -861,7 +861,8 @@ static bool textarea_reflow_singleline(struct textarea *ta, size_t b_off,
* \param b_start 0-based byte offset in ta->text to start of modification
* \return true on success false otherwise
*/
-static bool textarea_reflow_multiline(struct textarea *ta, size_t b_start)
+static bool textarea_reflow_multiline(struct textarea *ta, const size_t b_start,
+ struct rect *r)
{
char *text;
unsigned int len;
@@ -907,9 +908,9 @@ static bool textarea_reflow_multiline(struct textarea *ta, size_t b_start)
do {
/* Set line count to start point */
if (restart)
- line = 0;
- else
- line = start;
+ start = 0;
+
+ line = start;
/* Find available width */
avail_width = ta->vis_width - 2 * ta->border_width -
@@ -1098,6 +1099,14 @@ static bool textarea_reflow_multiline(struct textarea *ta, size_t b_start)
ta->v_extent = v_extent;
ta->line_count = line;
+ /* Don't need to redraw above changes, so update redraw request rect*/
+ if (ta->lines[start].b_start + ta->lines[start].b_length < b_start &&
+ restart == false)
+ /* Start line is unchanged */
+ start++;
+ r->y0 = max(r->y0, (signed)(ta->line_height * start +
+ ta->text_y_offset - ta->scroll_y));
+
return true;
}
@@ -1249,7 +1258,7 @@ static bool textarea_insert_text(struct textarea *ta, const char *text,
/* See to reflow */
if (ta->flags & TEXTAREA_MULTILINE) {
- if (!textarea_reflow_multiline(ta, show_b_off))
+ if (!textarea_reflow_multiline(ta, show_b_off, r))
return false;
} else {
if (!textarea_reflow_singleline(ta, show_b_off, r))
@@ -1401,7 +1410,7 @@ static bool textarea_replace_text(struct textarea *ta, size_t b_start,
/* See to reflow */
if (ta->flags & TEXTAREA_MULTILINE) {
- if (!textarea_reflow_multiline(ta, b_start))
+ if (!textarea_reflow_multiline(ta, b_start, r))
return false;
} else {
if (!textarea_reflow_singleline(ta, show_b_off, r))
@@ -1606,7 +1615,7 @@ struct textarea *textarea_create(const textarea_flags flags,
textarea_setup_text_offsets(ret);
if (flags & TEXTAREA_MULTILINE)
- textarea_reflow_multiline(ret, 0);
+ textarea_reflow_multiline(ret, 0, &r);
else
textarea_reflow_singleline(ret, 0, &r);
@@ -1654,7 +1663,7 @@ bool textarea_set_text(struct textarea *ta, const char *text)
textarea_normalise_text(ta, 0, len);
if (ta->flags & TEXTAREA_MULTILINE) {
- if (!textarea_reflow_multiline(ta, 0))
+ if (!textarea_reflow_multiline(ta, 0, &r))
return false;
} else {
if (!textarea_reflow_singleline(ta, 0, &r))
@@ -2810,7 +2819,7 @@ void textarea_set_dimensions(struct textarea *ta, int width, int height)
textarea_setup_text_offsets(ta);
if (ta->flags & TEXTAREA_MULTILINE) {
- textarea_reflow_multiline(ta, 0);
+ textarea_reflow_multiline(ta, 0, &r);
} else {
textarea_reflow_singleline(ta, 0, &r);
}
@@ -2833,7 +2842,7 @@ void textarea_set_layout(struct textarea *ta, int width, int height,
textarea_setup_text_offsets(ta);
if (ta->flags & TEXTAREA_MULTILINE) {
- textarea_reflow_multiline(ta, 0);
+ textarea_reflow_multiline(ta, 0, &r);
} else {
textarea_reflow_singleline(ta, 0, &r);
}
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=cc4411c0c7452968349...
commit cc4411c0c7452968349725bf1edbcd1731422180
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Remove some spaces.
diff --git a/desktop/textarea.c b/desktop/textarea.c
index 15d35e1..81af9f8 100644
--- a/desktop/textarea.c
+++ b/desktop/textarea.c
@@ -1249,11 +1249,11 @@ static bool textarea_insert_text(struct textarea *ta, const char *text,
/* See to reflow */
if (ta->flags & TEXTAREA_MULTILINE) {
- if (!textarea_reflow_multiline(ta, show_b_off))
- return false;
+ if (!textarea_reflow_multiline(ta, show_b_off))
+ return false;
} else {
- if (!textarea_reflow_singleline(ta, show_b_off, r))
- return false;
+ if (!textarea_reflow_singleline(ta, show_b_off, r))
+ return false;
}
return true;
@@ -1401,11 +1401,11 @@ static bool textarea_replace_text(struct textarea *ta, size_t b_start,
/* See to reflow */
if (ta->flags & TEXTAREA_MULTILINE) {
- if (!textarea_reflow_multiline(ta, b_start))
- return false;
+ if (!textarea_reflow_multiline(ta, b_start))
+ return false;
} else {
- if (!textarea_reflow_singleline(ta, show_b_off, r))
- return false;
+ if (!textarea_reflow_singleline(ta, show_b_off, r))
+ return false;
}
return true;
-----------------------------------------------------------------------
Summary of changes:
desktop/textarea.c | 41 +++++++++++++++++++++++++----------------
1 files changed, 25 insertions(+), 16 deletions(-)
diff --git a/desktop/textarea.c b/desktop/textarea.c
index 15d35e1..e614cc4 100644
--- a/desktop/textarea.c
+++ b/desktop/textarea.c
@@ -861,7 +861,8 @@ static bool textarea_reflow_singleline(struct textarea *ta, size_t b_off,
* \param b_start 0-based byte offset in ta->text to start of modification
* \return true on success false otherwise
*/
-static bool textarea_reflow_multiline(struct textarea *ta, size_t b_start)
+static bool textarea_reflow_multiline(struct textarea *ta, const size_t b_start,
+ struct rect *r)
{
char *text;
unsigned int len;
@@ -907,9 +908,9 @@ static bool textarea_reflow_multiline(struct textarea *ta, size_t b_start)
do {
/* Set line count to start point */
if (restart)
- line = 0;
- else
- line = start;
+ start = 0;
+
+ line = start;
/* Find available width */
avail_width = ta->vis_width - 2 * ta->border_width -
@@ -1098,6 +1099,14 @@ static bool textarea_reflow_multiline(struct textarea *ta, size_t b_start)
ta->v_extent = v_extent;
ta->line_count = line;
+ /* Don't need to redraw above changes, so update redraw request rect*/
+ if (ta->lines[start].b_start + ta->lines[start].b_length < b_start &&
+ restart == false)
+ /* Start line is unchanged */
+ start++;
+ r->y0 = max(r->y0, (signed)(ta->line_height * start +
+ ta->text_y_offset - ta->scroll_y));
+
return true;
}
@@ -1249,11 +1258,11 @@ static bool textarea_insert_text(struct textarea *ta, const char *text,
/* See to reflow */
if (ta->flags & TEXTAREA_MULTILINE) {
- if (!textarea_reflow_multiline(ta, show_b_off))
- return false;
+ if (!textarea_reflow_multiline(ta, show_b_off, r))
+ return false;
} else {
- if (!textarea_reflow_singleline(ta, show_b_off, r))
- return false;
+ if (!textarea_reflow_singleline(ta, show_b_off, r))
+ return false;
}
return true;
@@ -1401,11 +1410,11 @@ static bool textarea_replace_text(struct textarea *ta, size_t b_start,
/* See to reflow */
if (ta->flags & TEXTAREA_MULTILINE) {
- if (!textarea_reflow_multiline(ta, b_start))
- return false;
+ if (!textarea_reflow_multiline(ta, b_start, r))
+ return false;
} else {
- if (!textarea_reflow_singleline(ta, show_b_off, r))
- return false;
+ if (!textarea_reflow_singleline(ta, show_b_off, r))
+ return false;
}
return true;
@@ -1606,7 +1615,7 @@ struct textarea *textarea_create(const textarea_flags flags,
textarea_setup_text_offsets(ret);
if (flags & TEXTAREA_MULTILINE)
- textarea_reflow_multiline(ret, 0);
+ textarea_reflow_multiline(ret, 0, &r);
else
textarea_reflow_singleline(ret, 0, &r);
@@ -1654,7 +1663,7 @@ bool textarea_set_text(struct textarea *ta, const char *text)
textarea_normalise_text(ta, 0, len);
if (ta->flags & TEXTAREA_MULTILINE) {
- if (!textarea_reflow_multiline(ta, 0))
+ if (!textarea_reflow_multiline(ta, 0, &r))
return false;
} else {
if (!textarea_reflow_singleline(ta, 0, &r))
@@ -2810,7 +2819,7 @@ void textarea_set_dimensions(struct textarea *ta, int width, int height)
textarea_setup_text_offsets(ta);
if (ta->flags & TEXTAREA_MULTILINE) {
- textarea_reflow_multiline(ta, 0);
+ textarea_reflow_multiline(ta, 0, &r);
} else {
textarea_reflow_singleline(ta, 0, &r);
}
@@ -2833,7 +2842,7 @@ void textarea_set_layout(struct textarea *ta, int width, int height,
textarea_setup_text_offsets(ta);
if (ta->flags & TEXTAREA_MULTILINE) {
- textarea_reflow_multiline(ta, 0);
+ textarea_reflow_multiline(ta, 0, &r);
} else {
textarea_reflow_singleline(ta, 0, &r);
}
--
NetSurf Browser
9 years, 10 months
netsurf: branch master updated. 7de97e8d6a2899a4811b494f74064989eeac1b00
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/7de97e8d6a2899a4811b4...
...commit http://git.netsurf-browser.org/netsurf.git/commit/7de97e8d6a2899a4811b494...
...tree http://git.netsurf-browser.org/netsurf.git/tree/7de97e8d6a2899a4811b494f7...
The branch, master has been updated
via 7de97e8d6a2899a4811b494f74064989eeac1b00 (commit)
via f70e58b4a140600b7a375ecdd0991d8eee64e033 (commit)
via e678df267e0840aea58fed63cd3922a23a15915a (commit)
from 70fbca36060e2c358a6dc54da853ba6d5ec8724d (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=7de97e8d6a2899a4811...
commit 7de97e8d6a2899a4811b494f74064989eeac1b00
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
ensure the closest character is picked
diff --git a/amiga/font.c b/amiga/font.c
index ee5ab30..df0567f 100644
--- a/amiga/font.c
+++ b/amiga/font.c
@@ -216,7 +216,7 @@ bool nsfont_position_in_string(const plot_font_style_t *fstyle,
outf16 = utf16;
if(!(ofont = ami_open_outline_font(fstyle, 0))) return false;
- *char_offset = length;
+ *char_offset = 0;
*actual_x = 0;
while (utf8_pos < length) {
@@ -239,17 +239,20 @@ bool nsfont_position_in_string(const plot_font_style_t *fstyle,
}
tx += tempx;
+ utf16 += utf16charlen;
+ utf8_pos = utf8_next(string, length, utf8_pos);
if(tx < x) {
*actual_x = tx;
- } else {
*char_offset = utf8_pos;
+ } else {
+ if((x - *actual_x) > (tx - x)) {
+ *actual_x = tx;
+ *char_offset = utf8_pos;
+ }
free(outf16);
return true;
}
-
- utf16 += utf16charlen;
- utf8_pos = utf8_next(string, length, utf8_pos);
}
*actual_x = tx;
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=f70e58b4a140600b7a3...
commit f70e58b4a140600b7a375ecdd0991d8eee64e033
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
update posn_in_string loop to be similar to nsfont_split
diff --git a/amiga/font.c b/amiga/font.c
index bffce63..ee5ab30 100644
--- a/amiga/font.c
+++ b/amiga/font.c
@@ -206,76 +206,56 @@ bool nsfont_position_in_string(const plot_font_style_t *fstyle,
uint32 tx=0,i=0;
size_t len, utf8len = 0;
uint8 *utf8;
+ int utf8_pos = 0;
uint32 co = 0;
int utf16charlen;
ULONG emwidth = (ULONG)NSA_FONT_EMWIDTH(fstyle->size);
int32 tempx;
- len = utf8_bounded_length(string, length);
if(utf8_to_enc(string,"UTF-16",length,(char **)&utf16) != UTF8_CONVERT_OK) return false;
outf16 = utf16;
-
if(!(ofont = ami_open_outline_font(fstyle, 0))) return false;
*char_offset = length;
+ *actual_x = 0;
- for(i=0;i<len;i++)
- {
+ while (utf8_pos < length) {
if ((*utf16 < 0xD800) || (0xDFFF < *utf16))
utf16charlen = 1;
else
utf16charlen = 2;
- utf8len = utf8_char_byte_length(string);
-
utf16next = &utf16[utf16charlen];
tempx = ami_font_width_glyph(ofont, utf16, utf16next, emwidth);
- if(tempx == 0)
- {
- if(ufont == NULL)
- {
+ if (tempx == 0) {
+ if (ufont == NULL)
ufont = ami_open_outline_font(fstyle, *utf16);
- }
- if(ufont)
- {
- tempx = ami_font_width_glyph(ufont, utf16, utf16next, emwidth);
- }
-/*
- if(tempx == 0)
- {
- tempx = ami_font_width_glyph(ofont, NULL, 0xfffd, utf16next, emwidth);
- }
-*/
+ if (ufont)
+ tempx = ami_font_width_glyph(ufont, utf16,
+ utf16next, emwidth);
}
- if(x < (tx + tempx))
- {
+ tx += tempx;
+
+ if(tx < x) {
*actual_x = tx;
- i = len+1;
- }
- else
- {
- co += utf8len;
+ } else {
+ *char_offset = utf8_pos;
+ free(outf16);
+ return true;
}
- tx += tempx;
- string += utf8len;
utf16 += utf16charlen;
+ utf8_pos = utf8_next(string, length, utf8_pos);
}
- if(co >= (length))
- {
- *actual_x = tx;
- co = length;
- }
-
- *char_offset = co;
+ *actual_x = tx;
+ *char_offset = length;
free(outf16);
-
return true;
}
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=e678df267e0840aea58...
commit e678df267e0840aea58fed63cd3922a23a15915a
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Handle UTF-16 multi-length characters properly
diff --git a/amiga/font.c b/amiga/font.c
index ed47f4b..bffce63 100644
--- a/amiga/font.c
+++ b/amiga/font.c
@@ -72,6 +72,74 @@ struct ami_font_node
struct TimeVal lastused;
};
+const uint16 sc_table[] = {
+ 0x0061, 0x1D00, /* a */
+ 0x0062, 0x0299, /* b */
+ 0x0063, 0x1D04, /* c */
+ 0x0064, 0x1D05, /* d */
+ 0x0065, 0x1D07, /* e */
+ 0x0066, 0xA730, /* f */
+ 0x0067, 0x0262, /* g */
+ 0x0068, 0x029C, /* h */
+ 0x0069, 0x026A, /* i */
+ 0x006A, 0x1D0A, /* j */
+ 0x006B, 0x1D0B, /* k */
+ 0x006C, 0x029F, /* l */
+ 0x006D, 0x1D0D, /* m */
+ 0x006E, 0x0274, /* n */
+ 0x006F, 0x1D0F, /* o */
+ 0x0070, 0x1D18, /* p */
+ 0x0071, 0xA7EE, /* q (proposed) (Adobe codepoint 0xF771) */
+ 0x0072, 0x0280, /* r */
+ 0x0073, 0xA731, /* s */
+ 0x0074, 0x1D1B, /* t */
+ 0x0075, 0x1D1C, /* u */
+ 0x0076, 0x1D20, /* v */
+ 0x0077, 0x1D21, /* w */
+ 0x0078, 0xA7EF, /* x (proposed) (Adobe codepoint 0xF778) */
+ 0x0079, 0x028F, /* y */
+ 0x007A, 0x1D22, /* z */
+
+ 0x00C6, 0x1D01, /* ae */
+ 0x0153, 0x0276, /* oe */
+
+#if 0
+/* TODO: fill in the non-small caps character ids for these */
+ 0x0000, 0x1D03, /* barred b */
+ 0x0000, 0x0281, /* inverted r */
+ 0x0000, 0x1D19, /* reversed r */
+ 0x0000, 0x1D1A, /* turned r */
+ 0x0000, 0x029B, /* g with hook */
+ 0x0000, 0x1D06, /* eth � */
+ 0x0000, 0x1D0C, /* l with stroke */
+ 0x0000, 0xA7FA, /* turned m */
+ 0x0000, 0x1D0E, /* reversed n */
+ 0x0000, 0x1D10, /* open o */
+ 0x0000, 0x1D15, /* ou */
+ 0x0000, 0x1D23, /* ezh */
+ 0x0000, 0x1D26, /* gamma */
+ 0x0000, 0x1D27, /* lamda */
+ 0x0000, 0x1D28, /* pi */
+ 0x0000, 0x1D29, /* rho */
+ 0x0000, 0x1D2A, /* psi */
+ 0x0000, 0x1D2B, /* el */
+ 0x0000, 0xA776, /* rum */
+
+ 0x0000, 0x1DDB, /* combining g */
+ 0x0000, 0x1DDE, /* combining l */
+ 0x0000, 0x1DDF, /* combining m */
+ 0x0000, 0x1DE1, /* combining n */
+ 0x0000, 0x1DE2, /* combining r */
+
+ 0x0000, 0x1DA6, /* modifier i */
+ 0x0000, 0x1DA7, /* modifier i with stroke */
+ 0x0000, 0x1DAB, /* modifier l */
+ 0x0000, 0x1DB0, /* modifier n */
+ 0x0000, 0x1DB8, /* modifier u */
+#endif
+ 0, 0};
+
+
struct MinList *ami_font_list = NULL;
struct List ami_diskfontlib_list;
lwc_string *glypharray[0xffff + 1];
@@ -79,9 +147,9 @@ ULONG ami_devicedpi;
ULONG ami_xdpi;
int32 ami_font_plot_glyph(struct OutlineFont *ofont, struct RastPort *rp,
- uint16 char1, uint16 char2, uint32 x, uint32 y, uint32 emwidth, bool aa);
+ uint16 *char1, uint16 *char2, uint32 x, uint32 y, uint32 emwidth, bool aa);
int32 ami_font_width_glyph(struct OutlineFont *ofont,
- uint16 char1, uint16 char2, uint32 emwidth);
+ uint16 *char1, uint16 *char2, uint32 emwidth);
struct OutlineFont *ami_open_outline_font(const plot_font_style_t *fstyle,
uint16 codepoint);
static void ami_font_cleanup(struct MinList *ami_font_list);
@@ -132,7 +200,7 @@ bool nsfont_position_in_string(const plot_font_style_t *fstyle,
int x, size_t *char_offset, int *actual_x)
{
uint16 *utf16 = NULL, *outf16 = NULL;
- uint16 utf16next = 0;
+ uint16 *utf16next = NULL;
FIXED kern = 0;
struct OutlineFont *ofont, *ufont = NULL;
uint32 tx=0,i=0;
@@ -160,9 +228,9 @@ bool nsfont_position_in_string(const plot_font_style_t *fstyle,
utf8len = utf8_char_byte_length(string);
- utf16next = utf16[utf16charlen];
+ utf16next = &utf16[utf16charlen];
- tempx = ami_font_width_glyph(ofont, *utf16, utf16next, emwidth);
+ tempx = ami_font_width_glyph(ofont, utf16, utf16next, emwidth);
if(tempx == 0)
{
@@ -173,7 +241,7 @@ bool nsfont_position_in_string(const plot_font_style_t *fstyle,
if(ufont)
{
- tempx = ami_font_width_glyph(ufont, *utf16, utf16next, emwidth);
+ tempx = ami_font_width_glyph(ufont, utf16, utf16next, emwidth);
}
/*
if(tempx == 0)
@@ -241,7 +309,7 @@ bool nsfont_split(const plot_font_style_t *fstyle,
{
ULONG co;
uint16 *utf16 = NULL,*outf16 = NULL;
- uint16 utf16next = 0;
+ uint16 *utf16next = NULL;
FIXED kern = 0;
int utf16charlen = 0;
struct OutlineFont *ofont, *ufont = NULL;
@@ -263,16 +331,16 @@ bool nsfont_split(const plot_font_style_t *fstyle,
else
utf16charlen = 2;
- utf16next = utf16[utf16charlen];
+ utf16next = &utf16[utf16charlen];
- tempx = ami_font_width_glyph(ofont, *utf16, utf16next, emwidth);
+ tempx = ami_font_width_glyph(ofont, utf16, utf16next, emwidth);
if (tempx == 0) {
if (ufont == NULL)
ufont = ami_open_outline_font(fstyle, *utf16);
if (ufont)
- tempx = ami_font_width_glyph(ufont, *utf16,
+ tempx = ami_font_width_glyph(ufont, utf16,
utf16next, emwidth);
}
@@ -517,7 +585,7 @@ struct OutlineFont *ami_open_outline_font(const plot_font_style_t *fstyle,
}
int32 ami_font_plot_glyph(struct OutlineFont *ofont, struct RastPort *rp,
- uint16 char1, uint16 char2, uint32 x, uint32 y, uint32 emwidth, bool aa)
+ uint16 *char1, uint16 *char2, uint32 x, uint32 y, uint32 emwidth, bool aa)
{
struct GlyphMap *glyph;
UBYTE *glyphbm;
@@ -532,8 +600,8 @@ int32 ami_font_plot_glyph(struct OutlineFont *ofont, struct RastPort *rp,
}
if(ESetInfo(&ofont->olf_EEngine,
- OT_GlyphCode, char1,
- OT_GlyphCode2, char2,
+ OT_GlyphCode, *char1,
+ OT_GlyphCode2, *char2,
TAG_END) == OTERR_Success)
{
if(EObtainInfo(&ofont->olf_EEngine,
@@ -577,7 +645,7 @@ int32 ami_font_plot_glyph(struct OutlineFont *ofont, struct RastPort *rp,
}
int32 ami_font_width_glyph(struct OutlineFont *ofont,
- uint16 char1, uint16 char2, uint32 emwidth)
+ uint16 *char1, uint16 *char2, uint32 emwidth)
{
int32 char_advance = 0;
FIXED kern = 0;
@@ -586,8 +654,8 @@ int32 ami_font_width_glyph(struct OutlineFont *ofont,
struct GlyphWidthEntry *gwnode;
if(ESetInfo(&ofont->olf_EEngine,
- OT_GlyphCode, char1,
- OT_GlyphCode2, char1,
+ OT_GlyphCode, *char1,
+ OT_GlyphCode2, *char1,
TAG_END) == OTERR_Success)
{
if(EObtainInfo(&ofont->olf_EEngine,
@@ -601,8 +669,8 @@ int32 ami_font_width_glyph(struct OutlineFont *ofont,
if(char2) {
if(ESetInfo(&ofont->olf_EEngine,
- OT_GlyphCode, char1,
- OT_GlyphCode2, char2,
+ OT_GlyphCode, *char1,
+ OT_GlyphCode2, *char2,
TAG_END) == OTERR_Success)
{
EObtainInfo(&ofont->olf_EEngine,
@@ -617,81 +685,14 @@ int32 ami_font_width_glyph(struct OutlineFont *ofont,
return char_advance;
}
-uint16 ami_font_translate_smallcaps(uint16 utf16char)
+const uint16 *ami_font_translate_smallcaps(uint16 *utf16char)
{
- uint16 *p;
- uint16 sc_table[] = {
- 0x0061, 0x1D00, /* a */
- 0x0062, 0x0299, /* b */
- 0x0063, 0x1D04, /* c */
- 0x0064, 0x1D05, /* d */
- 0x0065, 0x1D07, /* e */
- 0x0066, 0xA730, /* f */
- 0x0067, 0x0262, /* g */
- 0x0068, 0x029C, /* h */
- 0x0069, 0x026A, /* i */
- 0x006A, 0x1D0A, /* j */
- 0x006B, 0x1D0B, /* k */
- 0x006C, 0x029F, /* l */
- 0x006D, 0x1D0D, /* m */
- 0x006E, 0x0274, /* n */
- 0x006F, 0x1D0F, /* o */
- 0x0070, 0x1D18, /* p */
- 0x0071, 0xA7EE, /* q (proposed) (Adobe codepoint 0xF771) */
- 0x0072, 0x0280, /* r */
- 0x0073, 0xA731, /* s */
- 0x0074, 0x1D1B, /* t */
- 0x0075, 0x1D1C, /* u */
- 0x0076, 0x1D20, /* v */
- 0x0077, 0x1D21, /* w */
- 0x0078, 0xA7EF, /* x (proposed) (Adobe codepoint 0xF778) */
- 0x0079, 0x028F, /* y */
- 0x007A, 0x1D22, /* z */
-
- 0x00C6, 0x1D01, /* ae */
- 0x0153, 0x0276, /* oe */
-
-#if 0
-/* TODO: fill in the non-small caps character ids for these */
- 0x0000, 0x1D03, /* barred b */
- 0x0000, 0x0281, /* inverted r */
- 0x0000, 0x1D19, /* reversed r */
- 0x0000, 0x1D1A, /* turned r */
- 0x0000, 0x029B, /* g with hook */
- 0x0000, 0x1D06, /* eth � */
- 0x0000, 0x1D0C, /* l with stroke */
- 0x0000, 0xA7FA, /* turned m */
- 0x0000, 0x1D0E, /* reversed n */
- 0x0000, 0x1D10, /* open o */
- 0x0000, 0x1D15, /* ou */
- 0x0000, 0x1D23, /* ezh */
- 0x0000, 0x1D26, /* gamma */
- 0x0000, 0x1D27, /* lamda */
- 0x0000, 0x1D28, /* pi */
- 0x0000, 0x1D29, /* rho */
- 0x0000, 0x1D2A, /* psi */
- 0x0000, 0x1D2B, /* el */
- 0x0000, 0xA776, /* rum */
-
- 0x0000, 0x1DDB, /* combining g */
- 0x0000, 0x1DDE, /* combining l */
- 0x0000, 0x1DDF, /* combining m */
- 0x0000, 0x1DE1, /* combining n */
- 0x0000, 0x1DE2, /* combining r */
-
- 0x0000, 0x1DA6, /* modifier i */
- 0x0000, 0x1DA7, /* modifier i with stroke */
- 0x0000, 0x1DAB, /* modifier l */
- 0x0000, 0x1DB0, /* modifier n */
- 0x0000, 0x1DB8, /* modifier u */
-#endif
- 0, 0};
-
+ const uint16 *p;
p = &sc_table[0];
while (*p != 0)
{
- if(*p == utf16char) return p[1];
+ if(*p == *utf16char) return &p[1];
p++;
}
@@ -702,8 +703,8 @@ ULONG ami_unicode_text(struct RastPort *rp, const char *string, ULONG length,
const plot_font_style_t *fstyle, ULONG dx, ULONG dy, bool aa)
{
uint16 *utf16 = NULL, *outf16 = NULL;
- uint16 utf16charsc = 0, utf16nextsc = 0;
- uint16 utf16next = 0;
+ uint16 *utf16charsc = 0, *utf16nextsc = 0;
+ uint16 *utf16next = 0;
int utf16charlen;
struct OutlineFont *ofont, *ufont = NULL;
ULONG i,gx,gy;
@@ -727,12 +728,12 @@ ULONG ami_unicode_text(struct RastPort *rp, const char *string, ULONG length,
else
utf16charlen = 2;
- utf16next = utf16[utf16charlen];
+ utf16next = &utf16[utf16charlen];
if(fstyle->flags & FONTF_SMALLCAPS)
{
- utf16charsc = ami_font_translate_smallcaps(*utf16);
- utf16nextsc = ami_font_translate_smallcaps(utf16next);
+ utf16charsc = (uint16 *)ami_font_translate_smallcaps(utf16);
+ utf16nextsc = (uint16 *)ami_font_translate_smallcaps(utf16next);
if(rp) {
tempx = ami_font_plot_glyph(ofont, rp, utf16charsc, utf16nextsc,
@@ -745,10 +746,10 @@ ULONG ami_unicode_text(struct RastPort *rp, const char *string, ULONG length,
if(tempx == 0) {
if(rp) {
- tempx = ami_font_plot_glyph(ofont, rp, *utf16, utf16next,
+ tempx = ami_font_plot_glyph(ofont, rp, utf16, utf16next,
dx + x, dy, emwidth, aa);
} else {
- tempx = ami_font_width_glyph(ofont, *utf16, utf16next, emwidth);
+ tempx = ami_font_width_glyph(ofont, utf16, utf16next, emwidth);
}
}
@@ -762,10 +763,10 @@ ULONG ami_unicode_text(struct RastPort *rp, const char *string, ULONG length,
if(ufont)
{
if(rp) {
- tempx = ami_font_plot_glyph(ufont, rp, *utf16, utf16next,
+ tempx = ami_font_plot_glyph(ufont, rp, utf16, utf16next,
dx + x, dy, emwidth, aa);
} else {
- tempx = ami_font_width_glyph(ufont, *utf16, utf16next, emwidth);
+ tempx = ami_font_width_glyph(ufont, utf16, utf16next, emwidth);
}
}
/*
-----------------------------------------------------------------------
Summary of changes:
amiga/font.c | 256 +++++++++++++++++++++++++++-------------------------------
1 files changed, 120 insertions(+), 136 deletions(-)
diff --git a/amiga/font.c b/amiga/font.c
index ed47f4b..df0567f 100644
--- a/amiga/font.c
+++ b/amiga/font.c
@@ -72,6 +72,74 @@ struct ami_font_node
struct TimeVal lastused;
};
+const uint16 sc_table[] = {
+ 0x0061, 0x1D00, /* a */
+ 0x0062, 0x0299, /* b */
+ 0x0063, 0x1D04, /* c */
+ 0x0064, 0x1D05, /* d */
+ 0x0065, 0x1D07, /* e */
+ 0x0066, 0xA730, /* f */
+ 0x0067, 0x0262, /* g */
+ 0x0068, 0x029C, /* h */
+ 0x0069, 0x026A, /* i */
+ 0x006A, 0x1D0A, /* j */
+ 0x006B, 0x1D0B, /* k */
+ 0x006C, 0x029F, /* l */
+ 0x006D, 0x1D0D, /* m */
+ 0x006E, 0x0274, /* n */
+ 0x006F, 0x1D0F, /* o */
+ 0x0070, 0x1D18, /* p */
+ 0x0071, 0xA7EE, /* q (proposed) (Adobe codepoint 0xF771) */
+ 0x0072, 0x0280, /* r */
+ 0x0073, 0xA731, /* s */
+ 0x0074, 0x1D1B, /* t */
+ 0x0075, 0x1D1C, /* u */
+ 0x0076, 0x1D20, /* v */
+ 0x0077, 0x1D21, /* w */
+ 0x0078, 0xA7EF, /* x (proposed) (Adobe codepoint 0xF778) */
+ 0x0079, 0x028F, /* y */
+ 0x007A, 0x1D22, /* z */
+
+ 0x00C6, 0x1D01, /* ae */
+ 0x0153, 0x0276, /* oe */
+
+#if 0
+/* TODO: fill in the non-small caps character ids for these */
+ 0x0000, 0x1D03, /* barred b */
+ 0x0000, 0x0281, /* inverted r */
+ 0x0000, 0x1D19, /* reversed r */
+ 0x0000, 0x1D1A, /* turned r */
+ 0x0000, 0x029B, /* g with hook */
+ 0x0000, 0x1D06, /* eth � */
+ 0x0000, 0x1D0C, /* l with stroke */
+ 0x0000, 0xA7FA, /* turned m */
+ 0x0000, 0x1D0E, /* reversed n */
+ 0x0000, 0x1D10, /* open o */
+ 0x0000, 0x1D15, /* ou */
+ 0x0000, 0x1D23, /* ezh */
+ 0x0000, 0x1D26, /* gamma */
+ 0x0000, 0x1D27, /* lamda */
+ 0x0000, 0x1D28, /* pi */
+ 0x0000, 0x1D29, /* rho */
+ 0x0000, 0x1D2A, /* psi */
+ 0x0000, 0x1D2B, /* el */
+ 0x0000, 0xA776, /* rum */
+
+ 0x0000, 0x1DDB, /* combining g */
+ 0x0000, 0x1DDE, /* combining l */
+ 0x0000, 0x1DDF, /* combining m */
+ 0x0000, 0x1DE1, /* combining n */
+ 0x0000, 0x1DE2, /* combining r */
+
+ 0x0000, 0x1DA6, /* modifier i */
+ 0x0000, 0x1DA7, /* modifier i with stroke */
+ 0x0000, 0x1DAB, /* modifier l */
+ 0x0000, 0x1DB0, /* modifier n */
+ 0x0000, 0x1DB8, /* modifier u */
+#endif
+ 0, 0};
+
+
struct MinList *ami_font_list = NULL;
struct List ami_diskfontlib_list;
lwc_string *glypharray[0xffff + 1];
@@ -79,9 +147,9 @@ ULONG ami_devicedpi;
ULONG ami_xdpi;
int32 ami_font_plot_glyph(struct OutlineFont *ofont, struct RastPort *rp,
- uint16 char1, uint16 char2, uint32 x, uint32 y, uint32 emwidth, bool aa);
+ uint16 *char1, uint16 *char2, uint32 x, uint32 y, uint32 emwidth, bool aa);
int32 ami_font_width_glyph(struct OutlineFont *ofont,
- uint16 char1, uint16 char2, uint32 emwidth);
+ uint16 *char1, uint16 *char2, uint32 emwidth);
struct OutlineFont *ami_open_outline_font(const plot_font_style_t *fstyle,
uint16 codepoint);
static void ami_font_cleanup(struct MinList *ami_font_list);
@@ -132,82 +200,65 @@ bool nsfont_position_in_string(const plot_font_style_t *fstyle,
int x, size_t *char_offset, int *actual_x)
{
uint16 *utf16 = NULL, *outf16 = NULL;
- uint16 utf16next = 0;
+ uint16 *utf16next = NULL;
FIXED kern = 0;
struct OutlineFont *ofont, *ufont = NULL;
uint32 tx=0,i=0;
size_t len, utf8len = 0;
uint8 *utf8;
+ int utf8_pos = 0;
uint32 co = 0;
int utf16charlen;
ULONG emwidth = (ULONG)NSA_FONT_EMWIDTH(fstyle->size);
int32 tempx;
- len = utf8_bounded_length(string, length);
if(utf8_to_enc(string,"UTF-16",length,(char **)&utf16) != UTF8_CONVERT_OK) return false;
outf16 = utf16;
-
if(!(ofont = ami_open_outline_font(fstyle, 0))) return false;
- *char_offset = length;
+ *char_offset = 0;
+ *actual_x = 0;
- for(i=0;i<len;i++)
- {
+ while (utf8_pos < length) {
if ((*utf16 < 0xD800) || (0xDFFF < *utf16))
utf16charlen = 1;
else
utf16charlen = 2;
- utf8len = utf8_char_byte_length(string);
-
- utf16next = utf16[utf16charlen];
+ utf16next = &utf16[utf16charlen];
- tempx = ami_font_width_glyph(ofont, *utf16, utf16next, emwidth);
+ tempx = ami_font_width_glyph(ofont, utf16, utf16next, emwidth);
- if(tempx == 0)
- {
- if(ufont == NULL)
- {
+ if (tempx == 0) {
+ if (ufont == NULL)
ufont = ami_open_outline_font(fstyle, *utf16);
- }
- if(ufont)
- {
- tempx = ami_font_width_glyph(ufont, *utf16, utf16next, emwidth);
- }
-/*
- if(tempx == 0)
- {
- tempx = ami_font_width_glyph(ofont, NULL, 0xfffd, utf16next, emwidth);
- }
-*/
- }
-
- if(x < (tx + tempx))
- {
- *actual_x = tx;
- i = len+1;
- }
- else
- {
- co += utf8len;
+ if (ufont)
+ tempx = ami_font_width_glyph(ufont, utf16,
+ utf16next, emwidth);
}
tx += tempx;
- string += utf8len;
utf16 += utf16charlen;
- }
+ utf8_pos = utf8_next(string, length, utf8_pos);
- if(co >= (length))
- {
- *actual_x = tx;
- co = length;
+ if(tx < x) {
+ *actual_x = tx;
+ *char_offset = utf8_pos;
+ } else {
+ if((x - *actual_x) > (tx - x)) {
+ *actual_x = tx;
+ *char_offset = utf8_pos;
+ }
+ free(outf16);
+ return true;
+ }
}
- *char_offset = co;
+ *actual_x = tx;
+ *char_offset = length;
free(outf16);
-
return true;
}
@@ -241,7 +292,7 @@ bool nsfont_split(const plot_font_style_t *fstyle,
{
ULONG co;
uint16 *utf16 = NULL,*outf16 = NULL;
- uint16 utf16next = 0;
+ uint16 *utf16next = NULL;
FIXED kern = 0;
int utf16charlen = 0;
struct OutlineFont *ofont, *ufont = NULL;
@@ -263,16 +314,16 @@ bool nsfont_split(const plot_font_style_t *fstyle,
else
utf16charlen = 2;
- utf16next = utf16[utf16charlen];
+ utf16next = &utf16[utf16charlen];
- tempx = ami_font_width_glyph(ofont, *utf16, utf16next, emwidth);
+ tempx = ami_font_width_glyph(ofont, utf16, utf16next, emwidth);
if (tempx == 0) {
if (ufont == NULL)
ufont = ami_open_outline_font(fstyle, *utf16);
if (ufont)
- tempx = ami_font_width_glyph(ufont, *utf16,
+ tempx = ami_font_width_glyph(ufont, utf16,
utf16next, emwidth);
}
@@ -517,7 +568,7 @@ struct OutlineFont *ami_open_outline_font(const plot_font_style_t *fstyle,
}
int32 ami_font_plot_glyph(struct OutlineFont *ofont, struct RastPort *rp,
- uint16 char1, uint16 char2, uint32 x, uint32 y, uint32 emwidth, bool aa)
+ uint16 *char1, uint16 *char2, uint32 x, uint32 y, uint32 emwidth, bool aa)
{
struct GlyphMap *glyph;
UBYTE *glyphbm;
@@ -532,8 +583,8 @@ int32 ami_font_plot_glyph(struct OutlineFont *ofont, struct RastPort *rp,
}
if(ESetInfo(&ofont->olf_EEngine,
- OT_GlyphCode, char1,
- OT_GlyphCode2, char2,
+ OT_GlyphCode, *char1,
+ OT_GlyphCode2, *char2,
TAG_END) == OTERR_Success)
{
if(EObtainInfo(&ofont->olf_EEngine,
@@ -577,7 +628,7 @@ int32 ami_font_plot_glyph(struct OutlineFont *ofont, struct RastPort *rp,
}
int32 ami_font_width_glyph(struct OutlineFont *ofont,
- uint16 char1, uint16 char2, uint32 emwidth)
+ uint16 *char1, uint16 *char2, uint32 emwidth)
{
int32 char_advance = 0;
FIXED kern = 0;
@@ -586,8 +637,8 @@ int32 ami_font_width_glyph(struct OutlineFont *ofont,
struct GlyphWidthEntry *gwnode;
if(ESetInfo(&ofont->olf_EEngine,
- OT_GlyphCode, char1,
- OT_GlyphCode2, char1,
+ OT_GlyphCode, *char1,
+ OT_GlyphCode2, *char1,
TAG_END) == OTERR_Success)
{
if(EObtainInfo(&ofont->olf_EEngine,
@@ -601,8 +652,8 @@ int32 ami_font_width_glyph(struct OutlineFont *ofont,
if(char2) {
if(ESetInfo(&ofont->olf_EEngine,
- OT_GlyphCode, char1,
- OT_GlyphCode2, char2,
+ OT_GlyphCode, *char1,
+ OT_GlyphCode2, *char2,
TAG_END) == OTERR_Success)
{
EObtainInfo(&ofont->olf_EEngine,
@@ -617,81 +668,14 @@ int32 ami_font_width_glyph(struct OutlineFont *ofont,
return char_advance;
}
-uint16 ami_font_translate_smallcaps(uint16 utf16char)
+const uint16 *ami_font_translate_smallcaps(uint16 *utf16char)
{
- uint16 *p;
- uint16 sc_table[] = {
- 0x0061, 0x1D00, /* a */
- 0x0062, 0x0299, /* b */
- 0x0063, 0x1D04, /* c */
- 0x0064, 0x1D05, /* d */
- 0x0065, 0x1D07, /* e */
- 0x0066, 0xA730, /* f */
- 0x0067, 0x0262, /* g */
- 0x0068, 0x029C, /* h */
- 0x0069, 0x026A, /* i */
- 0x006A, 0x1D0A, /* j */
- 0x006B, 0x1D0B, /* k */
- 0x006C, 0x029F, /* l */
- 0x006D, 0x1D0D, /* m */
- 0x006E, 0x0274, /* n */
- 0x006F, 0x1D0F, /* o */
- 0x0070, 0x1D18, /* p */
- 0x0071, 0xA7EE, /* q (proposed) (Adobe codepoint 0xF771) */
- 0x0072, 0x0280, /* r */
- 0x0073, 0xA731, /* s */
- 0x0074, 0x1D1B, /* t */
- 0x0075, 0x1D1C, /* u */
- 0x0076, 0x1D20, /* v */
- 0x0077, 0x1D21, /* w */
- 0x0078, 0xA7EF, /* x (proposed) (Adobe codepoint 0xF778) */
- 0x0079, 0x028F, /* y */
- 0x007A, 0x1D22, /* z */
-
- 0x00C6, 0x1D01, /* ae */
- 0x0153, 0x0276, /* oe */
-
-#if 0
-/* TODO: fill in the non-small caps character ids for these */
- 0x0000, 0x1D03, /* barred b */
- 0x0000, 0x0281, /* inverted r */
- 0x0000, 0x1D19, /* reversed r */
- 0x0000, 0x1D1A, /* turned r */
- 0x0000, 0x029B, /* g with hook */
- 0x0000, 0x1D06, /* eth � */
- 0x0000, 0x1D0C, /* l with stroke */
- 0x0000, 0xA7FA, /* turned m */
- 0x0000, 0x1D0E, /* reversed n */
- 0x0000, 0x1D10, /* open o */
- 0x0000, 0x1D15, /* ou */
- 0x0000, 0x1D23, /* ezh */
- 0x0000, 0x1D26, /* gamma */
- 0x0000, 0x1D27, /* lamda */
- 0x0000, 0x1D28, /* pi */
- 0x0000, 0x1D29, /* rho */
- 0x0000, 0x1D2A, /* psi */
- 0x0000, 0x1D2B, /* el */
- 0x0000, 0xA776, /* rum */
-
- 0x0000, 0x1DDB, /* combining g */
- 0x0000, 0x1DDE, /* combining l */
- 0x0000, 0x1DDF, /* combining m */
- 0x0000, 0x1DE1, /* combining n */
- 0x0000, 0x1DE2, /* combining r */
-
- 0x0000, 0x1DA6, /* modifier i */
- 0x0000, 0x1DA7, /* modifier i with stroke */
- 0x0000, 0x1DAB, /* modifier l */
- 0x0000, 0x1DB0, /* modifier n */
- 0x0000, 0x1DB8, /* modifier u */
-#endif
- 0, 0};
-
+ const uint16 *p;
p = &sc_table[0];
while (*p != 0)
{
- if(*p == utf16char) return p[1];
+ if(*p == *utf16char) return &p[1];
p++;
}
@@ -702,8 +686,8 @@ ULONG ami_unicode_text(struct RastPort *rp, const char *string, ULONG length,
const plot_font_style_t *fstyle, ULONG dx, ULONG dy, bool aa)
{
uint16 *utf16 = NULL, *outf16 = NULL;
- uint16 utf16charsc = 0, utf16nextsc = 0;
- uint16 utf16next = 0;
+ uint16 *utf16charsc = 0, *utf16nextsc = 0;
+ uint16 *utf16next = 0;
int utf16charlen;
struct OutlineFont *ofont, *ufont = NULL;
ULONG i,gx,gy;
@@ -727,12 +711,12 @@ ULONG ami_unicode_text(struct RastPort *rp, const char *string, ULONG length,
else
utf16charlen = 2;
- utf16next = utf16[utf16charlen];
+ utf16next = &utf16[utf16charlen];
if(fstyle->flags & FONTF_SMALLCAPS)
{
- utf16charsc = ami_font_translate_smallcaps(*utf16);
- utf16nextsc = ami_font_translate_smallcaps(utf16next);
+ utf16charsc = (uint16 *)ami_font_translate_smallcaps(utf16);
+ utf16nextsc = (uint16 *)ami_font_translate_smallcaps(utf16next);
if(rp) {
tempx = ami_font_plot_glyph(ofont, rp, utf16charsc, utf16nextsc,
@@ -745,10 +729,10 @@ ULONG ami_unicode_text(struct RastPort *rp, const char *string, ULONG length,
if(tempx == 0) {
if(rp) {
- tempx = ami_font_plot_glyph(ofont, rp, *utf16, utf16next,
+ tempx = ami_font_plot_glyph(ofont, rp, utf16, utf16next,
dx + x, dy, emwidth, aa);
} else {
- tempx = ami_font_width_glyph(ofont, *utf16, utf16next, emwidth);
+ tempx = ami_font_width_glyph(ofont, utf16, utf16next, emwidth);
}
}
@@ -762,10 +746,10 @@ ULONG ami_unicode_text(struct RastPort *rp, const char *string, ULONG length,
if(ufont)
{
if(rp) {
- tempx = ami_font_plot_glyph(ufont, rp, *utf16, utf16next,
+ tempx = ami_font_plot_glyph(ufont, rp, utf16, utf16next,
dx + x, dy, emwidth, aa);
} else {
- tempx = ami_font_width_glyph(ufont, *utf16, utf16next, emwidth);
+ tempx = ami_font_width_glyph(ufont, utf16, utf16next, emwidth);
}
}
/*
--
NetSurf Browser
9 years, 10 months
netsurf-website: branch master updated. b77dd0ce2d4715314dd70a8fe9aba405197fa326
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf-website.git/shortlog/b77dd0ce2d471...
...commit http://git.netsurf-browser.org/netsurf-website.git/commit/b77dd0ce2d47153...
...tree http://git.netsurf-browser.org/netsurf-website.git/tree/b77dd0ce2d4715314...
The branch, master has been updated
via b77dd0ce2d4715314dd70a8fe9aba405197fa326 (commit)
from 1f27008153aeedf9aa955dc806d8e682e7ba7764 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf-website.git/commit/?id=b77dd0ce2d4...
commit b77dd0ce2d4715314dd70a8fe9aba405197fa326
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Add wakefield show news.
diff --git a/about/news.en b/about/news.en
index 75afaff..ee6ba90 100644
--- a/about/news.en
+++ b/about/news.en
@@ -57,6 +57,8 @@
<h1>News</h1>
<dl class="news">
+<dt><a href="http://www.wakefieldshow.org.uk/">NetSurf at the Wakefield Show</a> <span>23 Mar 2013</span></dt>
+<dd>The NetSurf developers will be exhibiting at the Wakefield RISC OS trade show on Saturday 20th April. Please visit our stand to discuss issues, future plans, or just to meet the developers.</dd>
<dt><a href="http://vlists.pepperfish.net/pipermail/netsurf-users-netsurf-browser.org/...">New textarea handling</a> <span>11 Feb 2013</span></dt>
<dd>We've rewritten NetSurf's textarea support, so composing webmail, forum posting, and form filling should be more reliable now. Support for text selection and other behaviour is improved.</dd>
<dt><a href="http://ci.netsurf-browser.org/builds/">Early JavaScript builds available</a> <span>13 Dec 2012</span></dt>
@@ -147,7 +149,7 @@
<div class="footer">
-<p>Copyright 2003 - 2012 The NetSurf Developers</p>
+<p>Copyright 2003 - 2013 The NetSurf Developers</p>
</div>
</div>
diff --git a/index.en b/index.en
index 4432c4a..8e0b441 100644
--- a/index.en
+++ b/index.en
@@ -146,12 +146,12 @@
<h2 id="news">Latest news</h2>
<dl class="frontnews">
+<dt><a href="http://www.wakefieldshow.org.uk/">NetSurf at the Wakefield Show</a> <span>23 Mar 2013</span></dt>
+<dd>The NetSurf developers will be exhibiting at the Wakefield RISC OS trade show on Saturday 20th April. Please visit our stand to discuss issues, future plans, or just to meet the developers.</dd>
<dt><a href="http://vlists.pepperfish.net/pipermail/netsurf-users-netsurf-browser.org/...">New textarea handling</a> <span>11 Feb 2013</span></dt>
<dd>We've rewritten NetSurf's textarea support, so composing webmail, forum posting, and form filling should be more reliable now. Support for text selection and other behaviour is improved.</dd>
<dt><a href="http://ci.netsurf-browser.org/builds/">Early JavaScript builds available</a> <span>13 Dec 2012</span></dt>
<dd>While there is a very long way to go before NetSurf becomes a fully JavaScript-capable browser, brave users may like to try the JavaScript enabled test builds from our <a href="http://ci.netsurf-browser.org/builds/">autobuilder</a>.</dd>
-<dt><a href="http://vincentsanders.blogspot.co.uk/2012/11/another-netsurf-developer-wo...">Development progress</a> <span>05 Nov 2012</span></dt>
-<dd>The NetSurf Developers held another <a href="http://vincentsanders.blogspot.co.uk/2012/11/another-netsurf-developer-wo...">workshop</a> over the weekend. During the event we were able to consolidate several aspects of the browser after the previous <a href="/projects/libdom/">LibDOM</a> integration. LibDOM's performance was optimised, and the remaining usage of LibXML was removed from NetSurf. Thanks to <a href="http://www.collabora.com/">Collabora</a> who kindly hosted the workshop.</dd>
</dl>
<p class="more"><a href="/about/news" class="seemore">See more news</a></p>
@@ -200,7 +200,7 @@
</div>
<div class="footer">
-<p>Copyright 2003 - 2012 The NetSurf Developers</p>
+<p>Copyright 2003 - 2013 The NetSurf Developers</p>
</div>
</div>
-----------------------------------------------------------------------
Summary of changes:
about/news.en | 4 +++-
index.en | 6 +++---
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/about/news.en b/about/news.en
index 75afaff..ee6ba90 100644
--- a/about/news.en
+++ b/about/news.en
@@ -57,6 +57,8 @@
<h1>News</h1>
<dl class="news">
+<dt><a href="http://www.wakefieldshow.org.uk/">NetSurf at the Wakefield Show</a> <span>23 Mar 2013</span></dt>
+<dd>The NetSurf developers will be exhibiting at the Wakefield RISC OS trade show on Saturday 20th April. Please visit our stand to discuss issues, future plans, or just to meet the developers.</dd>
<dt><a href="http://vlists.pepperfish.net/pipermail/netsurf-users-netsurf-browser.org/...">New textarea handling</a> <span>11 Feb 2013</span></dt>
<dd>We've rewritten NetSurf's textarea support, so composing webmail, forum posting, and form filling should be more reliable now. Support for text selection and other behaviour is improved.</dd>
<dt><a href="http://ci.netsurf-browser.org/builds/">Early JavaScript builds available</a> <span>13 Dec 2012</span></dt>
@@ -147,7 +149,7 @@
<div class="footer">
-<p>Copyright 2003 - 2012 The NetSurf Developers</p>
+<p>Copyright 2003 - 2013 The NetSurf Developers</p>
</div>
</div>
diff --git a/index.en b/index.en
index 4432c4a..8e0b441 100644
--- a/index.en
+++ b/index.en
@@ -146,12 +146,12 @@
<h2 id="news">Latest news</h2>
<dl class="frontnews">
+<dt><a href="http://www.wakefieldshow.org.uk/">NetSurf at the Wakefield Show</a> <span>23 Mar 2013</span></dt>
+<dd>The NetSurf developers will be exhibiting at the Wakefield RISC OS trade show on Saturday 20th April. Please visit our stand to discuss issues, future plans, or just to meet the developers.</dd>
<dt><a href="http://vlists.pepperfish.net/pipermail/netsurf-users-netsurf-browser.org/...">New textarea handling</a> <span>11 Feb 2013</span></dt>
<dd>We've rewritten NetSurf's textarea support, so composing webmail, forum posting, and form filling should be more reliable now. Support for text selection and other behaviour is improved.</dd>
<dt><a href="http://ci.netsurf-browser.org/builds/">Early JavaScript builds available</a> <span>13 Dec 2012</span></dt>
<dd>While there is a very long way to go before NetSurf becomes a fully JavaScript-capable browser, brave users may like to try the JavaScript enabled test builds from our <a href="http://ci.netsurf-browser.org/builds/">autobuilder</a>.</dd>
-<dt><a href="http://vincentsanders.blogspot.co.uk/2012/11/another-netsurf-developer-wo...">Development progress</a> <span>05 Nov 2012</span></dt>
-<dd>The NetSurf Developers held another <a href="http://vincentsanders.blogspot.co.uk/2012/11/another-netsurf-developer-wo...">workshop</a> over the weekend. During the event we were able to consolidate several aspects of the browser after the previous <a href="/projects/libdom/">LibDOM</a> integration. LibDOM's performance was optimised, and the remaining usage of LibXML was removed from NetSurf. Thanks to <a href="http://www.collabora.com/">Collabora</a> who kindly hosted the workshop.</dd>
</dl>
<p class="more"><a href="/about/news" class="seemore">See more news</a></p>
@@ -200,7 +200,7 @@
</div>
<div class="footer">
-<p>Copyright 2003 - 2012 The NetSurf Developers</p>
+<p>Copyright 2003 - 2013 The NetSurf Developers</p>
</div>
</div>
--
NetSurf website source for *.netsurf-browser.org
9 years, 10 months
netsurf: branch master updated. 70fbca36060e2c358a6dc54da853ba6d5ec8724d
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/70fbca36060e2c358a6dc...
...commit http://git.netsurf-browser.org/netsurf.git/commit/70fbca36060e2c358a6dc54...
...tree http://git.netsurf-browser.org/netsurf.git/tree/70fbca36060e2c358a6dc54da...
The branch, master has been updated
via 70fbca36060e2c358a6dc54da853ba6d5ec8724d (commit)
via b603cafbaa718202048d6118063005f56dc9a79c (commit)
from b23c580f338ba13983edb5ad49f2a1242e0bc3d5 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=70fbca36060e2c358a6...
commit 70fbca36060e2c358a6dc54da853ba6d5ec8724d
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Reduce redraw area for selection set/change/clear.
diff --git a/desktop/textarea.c b/desktop/textarea.c
index 2ba1c53..15d35e1 100644
--- a/desktop/textarea.c
+++ b/desktop/textarea.c
@@ -459,7 +459,6 @@ static bool textarea_select(struct textarea *ta, int b_start, int b_end,
int swap;
bool pre_existing_selection = (ta->sel_start != -1);
struct textarea_msg msg;
- int line_start = 0, line_end = 0;
if (b_start == b_end) {
textarea_clear_selection(ta);
@@ -483,18 +482,29 @@ static bool textarea_select(struct textarea *ta, int b_start, int b_end,
msg.data.redraw.x1 = ta->vis_width - ta->border_width -
((ta->bar_y == NULL) ? 0 : SCROLLBAR_WIDTH);
- if (force_redraw || !pre_existing_selection ||
- (ta->sel_start != b_start && ta->sel_end != b_end)) {
- /* Asked to redraw everything, or there's a new selection, or
- * both ends of the selection have moved */
+ if (force_redraw) {
+ /* Asked to redraw everything */
msg.data.redraw.y0 = ta->border_width;
msg.data.redraw.y1 = ta->vis_height - ta->border_width -
((ta->bar_x == NULL) ? 0 : SCROLLBAR_WIDTH);
} else {
- /* Redraw to cover change in selection start or change in
- * selection end */
+ /* Try to minimise redraw region */
unsigned int b_low, b_high;
- if (ta->sel_start != b_start) {
+ int line_start = 0, line_end = 0;
+
+ if (!pre_existing_selection) {
+ /* There's a new selection */
+ b_low = b_start;
+ b_high = b_end;
+
+ } else if (ta->sel_start != b_start && ta->sel_end != b_end) {
+ /* Both ends of the selection have moved */
+ b_low = (ta->sel_start < b_start) ?
+ ta->sel_start : b_start;
+ b_high = (ta->sel_end > b_end) ?
+ ta->sel_end : b_end;
+
+ } else if (ta->sel_start != b_start) {
/* Selection start changed */
if ((signed)ta->sel_start < b_start) {
b_low = ta->sel_start;
@@ -503,6 +513,7 @@ static bool textarea_select(struct textarea *ta, int b_start, int b_end,
b_low = b_start;
b_high = ta->sel_start;
}
+
} else {
/* Selection end changed */
if ((signed)ta->sel_end < b_end) {
@@ -514,6 +525,7 @@ static bool textarea_select(struct textarea *ta, int b_start, int b_end,
}
}
+ /* Find redraw start/end lines */
for (line_end = 0; line_end < ta->line_count - 1; line_end++)
if (ta->lines[line_end + 1].b_start > b_low) {
line_start = line_end;
@@ -523,6 +535,7 @@ static bool textarea_select(struct textarea *ta, int b_start, int b_end,
if (ta->lines[line_end + 1].b_start > b_high)
break;
+ /* Set vertical redraw range */
msg.data.redraw.y0 = max(ta->border_width,
ta->line_height * line_start +
ta->text_y_offset - ta->scroll_y);
@@ -2677,22 +2690,37 @@ textarea_mouse_status textarea_mouse_action(struct textarea *ta,
bool textarea_clear_selection(struct textarea *ta)
{
struct textarea_msg msg;
+ int line_end, line_start = 0;
if (ta->sel_start == -1)
/* No selection to clear */
return false;
+ /* Find selection start & end lines */
+ for (line_end = 0; line_end < ta->line_count - 1; line_end++)
+ if (ta->lines[line_end + 1].b_start > (unsigned)ta->sel_start) {
+ line_start = line_end;
+ break;
+ }
+ for (; line_end < ta->line_count - 1; line_end++)
+ if (ta->lines[line_end + 1].b_start > (unsigned)ta->sel_end)
+ break;
+
/* Clear selection and redraw */
ta->sel_start = ta->sel_end = -1;
msg.ta = ta;
msg.type = TEXTAREA_MSG_REDRAW_REQUEST;
msg.data.redraw.x0 = ta->border_width;
- msg.data.redraw.y0 = ta->border_width;
+ msg.data.redraw.y0 = max(ta->border_width,
+ ta->line_height * line_start +
+ ta->text_y_offset - ta->scroll_y);
msg.data.redraw.x1 = ta->vis_width - ta->border_width -
((ta->bar_y == NULL) ? 0 : SCROLLBAR_WIDTH);
- msg.data.redraw.y1 = ta->vis_height - ta->border_width -
- ((ta->bar_x == NULL) ? 0 : SCROLLBAR_WIDTH);
+ msg.data.redraw.y1 = min(ta->vis_height - ta->border_width -
+ ((ta->bar_x == NULL) ? 0 : SCROLLBAR_WIDTH),
+ ta->line_height * line_end + ta->text_y_offset +
+ ta->line_height - ta->scroll_y);
ta->callback(ta->data, &msg);
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=b603cafbaa718202048...
commit b603cafbaa718202048d6118063005f56dc9a79c
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Move line start calc into reflow handler.
diff --git a/desktop/textarea.c b/desktop/textarea.c
index 8bf0cf0..2ba1c53 100644
--- a/desktop/textarea.c
+++ b/desktop/textarea.c
@@ -842,16 +842,17 @@ static bool textarea_reflow_singleline(struct textarea *ta, size_t b_off,
/**
- * Reflow a text area from the given line onwards
+ * Reflow a multiline textarea from the given line onwards
*
- * \param ta Text area to reflow
- * \param start Line number to begin reflow on
+ * \param ta Textarea to reflow
+ * \param b_start 0-based byte offset in ta->text to start of modification
* \return true on success false otherwise
*/
-static bool textarea_reflow_multiline(struct textarea *ta, unsigned int start)
+static bool textarea_reflow_multiline(struct textarea *ta, size_t b_start)
{
char *text;
unsigned int len;
+ unsigned int start;
size_t b_off;
int x;
char *space, *para_end;
@@ -874,14 +875,16 @@ static bool textarea_reflow_multiline(struct textarea *ta, unsigned int start)
ta->lines_alloc_size = LINE_CHUNK_SIZE;
}
+ /* Get line of start of changes */
+ for (start = 0; (signed) start < ta->line_count - 1; start++)
+ if (ta->lines[start + 1].b_start > b_start)
+ break;
+
/* Find max number of lines before vertical scrollbar is required */
scroll_lines = (ta->vis_height - 2 * ta->border_width -
ta->pad_top - ta->pad_bottom) /
ta->line_height;
- if ((signed)start > ta->line_count)
- start = 0;
-
/* Have to start on line before where the changes are in case an
* added space makes the text before the space on a soft-wrapped line
* fit on the line above */
@@ -1177,7 +1180,7 @@ static bool textarea_set_caret_xy(struct textarea *ta, int x, int y,
static bool textarea_insert_text(struct textarea *ta, const char *text,
size_t b_off, size_t b_len, int *byte_delta, struct rect *r)
{
- int char_delta, line;
+ int char_delta;
const size_t show_b_off = b_off;
if (ta->flags & TEXTAREA_READONLY)
@@ -1233,10 +1236,7 @@ static bool textarea_insert_text(struct textarea *ta, const char *text,
/* See to reflow */
if (ta->flags & TEXTAREA_MULTILINE) {
- for (line = 0; line < ta->line_count - 1; line++)
- if (ta->lines[line + 1].b_start > b_off)
- break;
- if (!textarea_reflow_multiline(ta, line))
+ if (!textarea_reflow_multiline(ta, show_b_off))
return false;
} else {
if (!textarea_reflow_singleline(ta, show_b_off, r))
@@ -1294,7 +1294,7 @@ static bool textarea_replace_text(struct textarea *ta, size_t b_start,
size_t b_end, const char *rep, size_t rep_len,
bool add_to_clipboard, int *byte_delta, struct rect *r)
{
- int char_delta, line;
+ int char_delta;
const size_t show_b_off = b_start;
*byte_delta = 0;
@@ -1388,10 +1388,7 @@ static bool textarea_replace_text(struct textarea *ta, size_t b_start,
/* See to reflow */
if (ta->flags & TEXTAREA_MULTILINE) {
- for (line = 0; line < ta->line_count - 1; line++)
- if (ta->lines[line + 1].b_start > b_start)
- break;
- if (!textarea_reflow_multiline(ta, line))
+ if (!textarea_reflow_multiline(ta, b_start))
return false;
} else {
if (!textarea_reflow_singleline(ta, show_b_off, r))
-----------------------------------------------------------------------
Summary of changes:
desktop/textarea.c | 81 ++++++++++++++++++++++++++++++++++------------------
1 files changed, 53 insertions(+), 28 deletions(-)
diff --git a/desktop/textarea.c b/desktop/textarea.c
index 8bf0cf0..15d35e1 100644
--- a/desktop/textarea.c
+++ b/desktop/textarea.c
@@ -459,7 +459,6 @@ static bool textarea_select(struct textarea *ta, int b_start, int b_end,
int swap;
bool pre_existing_selection = (ta->sel_start != -1);
struct textarea_msg msg;
- int line_start = 0, line_end = 0;
if (b_start == b_end) {
textarea_clear_selection(ta);
@@ -483,18 +482,29 @@ static bool textarea_select(struct textarea *ta, int b_start, int b_end,
msg.data.redraw.x1 = ta->vis_width - ta->border_width -
((ta->bar_y == NULL) ? 0 : SCROLLBAR_WIDTH);
- if (force_redraw || !pre_existing_selection ||
- (ta->sel_start != b_start && ta->sel_end != b_end)) {
- /* Asked to redraw everything, or there's a new selection, or
- * both ends of the selection have moved */
+ if (force_redraw) {
+ /* Asked to redraw everything */
msg.data.redraw.y0 = ta->border_width;
msg.data.redraw.y1 = ta->vis_height - ta->border_width -
((ta->bar_x == NULL) ? 0 : SCROLLBAR_WIDTH);
} else {
- /* Redraw to cover change in selection start or change in
- * selection end */
+ /* Try to minimise redraw region */
unsigned int b_low, b_high;
- if (ta->sel_start != b_start) {
+ int line_start = 0, line_end = 0;
+
+ if (!pre_existing_selection) {
+ /* There's a new selection */
+ b_low = b_start;
+ b_high = b_end;
+
+ } else if (ta->sel_start != b_start && ta->sel_end != b_end) {
+ /* Both ends of the selection have moved */
+ b_low = (ta->sel_start < b_start) ?
+ ta->sel_start : b_start;
+ b_high = (ta->sel_end > b_end) ?
+ ta->sel_end : b_end;
+
+ } else if (ta->sel_start != b_start) {
/* Selection start changed */
if ((signed)ta->sel_start < b_start) {
b_low = ta->sel_start;
@@ -503,6 +513,7 @@ static bool textarea_select(struct textarea *ta, int b_start, int b_end,
b_low = b_start;
b_high = ta->sel_start;
}
+
} else {
/* Selection end changed */
if ((signed)ta->sel_end < b_end) {
@@ -514,6 +525,7 @@ static bool textarea_select(struct textarea *ta, int b_start, int b_end,
}
}
+ /* Find redraw start/end lines */
for (line_end = 0; line_end < ta->line_count - 1; line_end++)
if (ta->lines[line_end + 1].b_start > b_low) {
line_start = line_end;
@@ -523,6 +535,7 @@ static bool textarea_select(struct textarea *ta, int b_start, int b_end,
if (ta->lines[line_end + 1].b_start > b_high)
break;
+ /* Set vertical redraw range */
msg.data.redraw.y0 = max(ta->border_width,
ta->line_height * line_start +
ta->text_y_offset - ta->scroll_y);
@@ -842,16 +855,17 @@ static bool textarea_reflow_singleline(struct textarea *ta, size_t b_off,
/**
- * Reflow a text area from the given line onwards
+ * Reflow a multiline textarea from the given line onwards
*
- * \param ta Text area to reflow
- * \param start Line number to begin reflow on
+ * \param ta Textarea to reflow
+ * \param b_start 0-based byte offset in ta->text to start of modification
* \return true on success false otherwise
*/
-static bool textarea_reflow_multiline(struct textarea *ta, unsigned int start)
+static bool textarea_reflow_multiline(struct textarea *ta, size_t b_start)
{
char *text;
unsigned int len;
+ unsigned int start;
size_t b_off;
int x;
char *space, *para_end;
@@ -874,14 +888,16 @@ static bool textarea_reflow_multiline(struct textarea *ta, unsigned int start)
ta->lines_alloc_size = LINE_CHUNK_SIZE;
}
+ /* Get line of start of changes */
+ for (start = 0; (signed) start < ta->line_count - 1; start++)
+ if (ta->lines[start + 1].b_start > b_start)
+ break;
+
/* Find max number of lines before vertical scrollbar is required */
scroll_lines = (ta->vis_height - 2 * ta->border_width -
ta->pad_top - ta->pad_bottom) /
ta->line_height;
- if ((signed)start > ta->line_count)
- start = 0;
-
/* Have to start on line before where the changes are in case an
* added space makes the text before the space on a soft-wrapped line
* fit on the line above */
@@ -1177,7 +1193,7 @@ static bool textarea_set_caret_xy(struct textarea *ta, int x, int y,
static bool textarea_insert_text(struct textarea *ta, const char *text,
size_t b_off, size_t b_len, int *byte_delta, struct rect *r)
{
- int char_delta, line;
+ int char_delta;
const size_t show_b_off = b_off;
if (ta->flags & TEXTAREA_READONLY)
@@ -1233,10 +1249,7 @@ static bool textarea_insert_text(struct textarea *ta, const char *text,
/* See to reflow */
if (ta->flags & TEXTAREA_MULTILINE) {
- for (line = 0; line < ta->line_count - 1; line++)
- if (ta->lines[line + 1].b_start > b_off)
- break;
- if (!textarea_reflow_multiline(ta, line))
+ if (!textarea_reflow_multiline(ta, show_b_off))
return false;
} else {
if (!textarea_reflow_singleline(ta, show_b_off, r))
@@ -1294,7 +1307,7 @@ static bool textarea_replace_text(struct textarea *ta, size_t b_start,
size_t b_end, const char *rep, size_t rep_len,
bool add_to_clipboard, int *byte_delta, struct rect *r)
{
- int char_delta, line;
+ int char_delta;
const size_t show_b_off = b_start;
*byte_delta = 0;
@@ -1388,10 +1401,7 @@ static bool textarea_replace_text(struct textarea *ta, size_t b_start,
/* See to reflow */
if (ta->flags & TEXTAREA_MULTILINE) {
- for (line = 0; line < ta->line_count - 1; line++)
- if (ta->lines[line + 1].b_start > b_start)
- break;
- if (!textarea_reflow_multiline(ta, line))
+ if (!textarea_reflow_multiline(ta, b_start))
return false;
} else {
if (!textarea_reflow_singleline(ta, show_b_off, r))
@@ -2680,22 +2690,37 @@ textarea_mouse_status textarea_mouse_action(struct textarea *ta,
bool textarea_clear_selection(struct textarea *ta)
{
struct textarea_msg msg;
+ int line_end, line_start = 0;
if (ta->sel_start == -1)
/* No selection to clear */
return false;
+ /* Find selection start & end lines */
+ for (line_end = 0; line_end < ta->line_count - 1; line_end++)
+ if (ta->lines[line_end + 1].b_start > (unsigned)ta->sel_start) {
+ line_start = line_end;
+ break;
+ }
+ for (; line_end < ta->line_count - 1; line_end++)
+ if (ta->lines[line_end + 1].b_start > (unsigned)ta->sel_end)
+ break;
+
/* Clear selection and redraw */
ta->sel_start = ta->sel_end = -1;
msg.ta = ta;
msg.type = TEXTAREA_MSG_REDRAW_REQUEST;
msg.data.redraw.x0 = ta->border_width;
- msg.data.redraw.y0 = ta->border_width;
+ msg.data.redraw.y0 = max(ta->border_width,
+ ta->line_height * line_start +
+ ta->text_y_offset - ta->scroll_y);
msg.data.redraw.x1 = ta->vis_width - ta->border_width -
((ta->bar_y == NULL) ? 0 : SCROLLBAR_WIDTH);
- msg.data.redraw.y1 = ta->vis_height - ta->border_width -
- ((ta->bar_x == NULL) ? 0 : SCROLLBAR_WIDTH);
+ msg.data.redraw.y1 = min(ta->vis_height - ta->border_width -
+ ((ta->bar_x == NULL) ? 0 : SCROLLBAR_WIDTH),
+ ta->line_height * line_end + ta->text_y_offset +
+ ta->line_height - ta->scroll_y);
ta->callback(ta->data, &msg);
--
NetSurf Browser
9 years, 10 months
libnsfb: branch vince/wayland updated. e9fb6419fee39416f16d09d4505bd6c8ebf05045
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/libnsfb.git/shortlog/e9fb6419fee39416f16d0...
...commit http://git.netsurf-browser.org/libnsfb.git/commit/e9fb6419fee39416f16d09d...
...tree http://git.netsurf-browser.org/libnsfb.git/tree/e9fb6419fee39416f16d09d45...
The branch, vince/wayland has been updated
via e9fb6419fee39416f16d09d4505bd6c8ebf05045 (commit)
via 433c8b3244b4c4e665aac5510e50d0f2dbe93d31 (commit)
from f75a698b15f978c854cc424ee79a38e157165091 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/libnsfb.git/commit/?id=e9fb6419fee39416f16...
commit e9fb6419fee39416f16d09d4505bd6c8ebf05045
Author: Vincent Sanders <vincent.sanders(a)collabora.co.uk>
Commit: Vincent Sanders <vincent.sanders(a)collabora.co.uk>
works if you cause messages to be delivered to allow the input pump to run
diff --git a/src/surface/wld.c b/src/surface/wld.c
index ded996d..76067e7 100644
--- a/src/surface/wld.c
+++ b/src/surface/wld.c
@@ -40,6 +40,73 @@
#include "plot.h"
#include "cursor.h"
+/** structure for display, registry and other global objects that
+ * should be cached when connecting to a wayland instance
+ */
+struct wld_connection {
+ struct wl_display *display; /**< connection object */
+ struct wl_registry *registry; /**< registry object */
+
+ /** compositor object, available once teh registry messages have
+ * been processed
+ */
+ struct wl_compositor *compositor;
+
+ /** shell object, available once the registry messages have been
+ * processed
+ */
+ struct wl_shell *shell;
+
+ /** shared memory object, available once the registry messages
+ * have been processed
+ */
+ struct wl_shm *shm;
+
+ /** shared memory formats available */
+ uint32_t shm_formats;
+};
+
+/* wayland window encompasing the display and shell surfaces */
+struct wld_window {
+ struct wld_connection* connection; /**< connection to wayland server */
+
+ struct wl_surface *surface;
+ struct wl_shell_surface *shell_surface;
+
+ int width, height;
+};
+
+struct wld_shm_buffer {
+ struct wl_buffer *buffer; /**< wayland buffer object */
+ void *data; /**< mapped memory */
+ int size; /**< size of mapped memory */
+ bool inuse; /**< flag to indicate if the buffer has been released
+ * after commit to a surface.
+ */
+};
+
+typedef struct wldstate_s {
+ struct wld_connection* connection; /**< connection to wayland server */
+ struct wld_window *window;
+ struct wld_shm_buffer *shm_buffer;
+#if 0
+ xcb_connection_t *connection; /* The x server connection */
+ xcb_screen_t *screen; /* The screen to put the window on */
+ xcb_key_symbols_t *keysymbols; /* keysym mappings */
+
+ xcb_shm_segment_info_t shminfo;
+
+ xcb_image_t *image; /* The X image buffer */
+
+ xcb_window_t window; /* The handle to the window */
+ xcb_pixmap_t pmap; /* The handle to the backing pixmap */
+ xcb_gcontext_t gc; /* The handle to the pixmap plotting graphics context */
+ xcb_shm_seg_t segment; /* The handle to the image shared memory */
+#endif
+
+} wldstate_t;
+
+
#if 0
#if defined(NSFB_NEED_HINTS_ALLOC)
@@ -585,14 +652,9 @@ xcopy(nsfb_t *nsfb, nsfb_bbox_t *srcbox, nsfb_bbox_t *dstbox)
#endif
-static int
-wld_set_geometry(nsfb_t *nsfb, int width, int height, enum nsfb_format_e format)
-{
-}
-#if 0
static int
-x_set_geometry(nsfb_t *nsfb, int width, int height, enum nsfb_format_e format)
+wld_set_geometry(nsfb_t *nsfb, int width, int height, enum nsfb_format_e format)
{
if (nsfb->surface_priv != NULL)
return -1; /* if were already initialised fail */
@@ -604,11 +666,10 @@ x_set_geometry(nsfb_t *nsfb, int width, int height, enum nsfb_format_e format)
/* select default sw plotters for format */
select_plotters(nsfb);
- nsfb->plotter_fns->copy = xcopy;
-
- return 0;
}
+#if 0
+
static xcb_format_t *
find_format(xcb_connection_t * c, uint8_t depth, uint8_t bpp)
@@ -780,32 +841,6 @@ create_blank_cursor(xcb_connection_t *conn, const xcb_screen_t *scr)
}
#endif
-/** structure for display, registry and other global objects that
- * should be cached when connecting to a wayland instance
- */
-struct wld_connection {
- struct wl_display *display; /**< connection object */
- struct wl_registry *registry; /**< registry object */
-
- /** compositor object, available once teh registry messages have
- * been processed
- */
- struct wl_compositor *compositor;
-
- /** shell object, available once the registry messages have been
- * processed
- */
- struct wl_shell *shell;
-
- /** shared memory object, available once the registry messages
- * have been processed
- */
- struct wl_shm *shm;
-
- /** shared memory formats available */
- uint32_t shm_formats;
-};
-
/** shared memory interface format available callback
*
@@ -977,36 +1012,29 @@ new_connection(void)
}
-typedef struct wldstate_s {
- struct wld_connection* connection; /**< connection to wayland server */
- struct wld_window *window;
- struct wld_shm_buffer *shm_buffer;
-#if 0
- xcb_connection_t *connection; /* The x server connection */
- xcb_screen_t *screen; /* The screen to put the window on */
- xcb_key_symbols_t *keysymbols; /* keysym mappings */
-
- xcb_shm_segment_info_t shminfo;
-
- xcb_image_t *image; /* The X image buffer */
- xcb_window_t window; /* The handle to the window */
- xcb_pixmap_t pmap; /* The handle to the backing pixmap */
- xcb_gcontext_t gc; /* The handle to the pixmap plotting graphics context */
- xcb_shm_seg_t segment; /* The handle to the image shared memory */
-#endif
+static int
+update_and_redraw(struct wldstate_s *wldstate,
+ int x,
+ int y,
+ int width,
+ int height)
+{
+ wl_surface_attach(wldstate->window->surface,
+ wldstate->shm_buffer->buffer,
+ 0,
+ 0);
-} wldstate_t;
+ wl_surface_damage(wldstate->window->surface, x, y, width, height);
-/* wayland window encompasing the display and shell surfaces */
-struct wld_window {
- struct wld_connection* connection; /**< connection to wayland server */
+ wl_surface_commit(wldstate->window->surface);
+ wldstate->shm_buffer->inuse = true;
- struct wl_surface *surface;
- struct wl_shell_surface *shell_surface;
+ /** @todo should this be here? */
+ wl_display_roundtrip(wldstate->connection->display);
- int width, height;
-};
+ return 0;
+}
static void
handle_ping(void *data, struct wl_shell_surface *shell_surface,
@@ -1137,14 +1165,6 @@ os_create_anonymous_file(off_t size)
return fd;
}
-struct wld_shm_buffer {
- struct wl_buffer *buffer; /**< wayland buffer object */
- void *data; /**< mapped memory */
- int size; /**< size of mapped memory */
- bool inuse; /**< flag to indicate if the buffer has been released
- * after commit to a surface.
- */
-};
static void
buffer_release(void *data, struct wl_buffer *buffer)
@@ -1277,6 +1297,11 @@ static int wld_initialise(nsfb_t *nsfb)
return -1; /* error */
}
+ nsfb->ptr = wldstate->shm_buffer->data;
+ nsfb->linelen = nsfb->width * 4;
+
+ update_and_redraw(wldstate,0,0, nsfb->width, nsfb->height);
+
nsfb->surface_priv = wldstate;
return 0;
@@ -1447,6 +1472,8 @@ static bool wld_input(nsfb_t *nsfb, nsfb_event_t *event, int timeout)
return true;
}
+ event->type = NSFB_EVENT_NONE;
+
return false;
}
@@ -1659,6 +1686,12 @@ x_cursor(nsfb_t *nsfb, struct nsfb_cursor_s *cursor)
static int wld_update(nsfb_t *nsfb, nsfb_bbox_t *box)
{
+ wldstate_t *wldstate = nsfb->surface_priv;
+
+ if (wldstate != NULL) {
+ update_and_redraw(wldstate, box->x0, box->y0, box->x1 - box->x0, box->y1 - box->y0);
+ }
+ return 0;
}
#if 0
commitdiff http://git.netsurf-browser.org/libnsfb.git/commit/?id=433c8b3244b4c4e665a...
commit 433c8b3244b4c4e665aac5510e50d0f2dbe93d31
Author: Vincent Sanders <vincent.sanders(a)collabora.co.uk>
Commit: Vincent Sanders <vincent.sanders(a)collabora.co.uk>
basic window opening working
diff --git a/src/surface/wld.c b/src/surface/wld.c
index d450738..ded996d 100644
--- a/src/surface/wld.c
+++ b/src/surface/wld.c
@@ -13,15 +13,22 @@
#include <stdio.h>
#include <string.h>
-#include <sys/ipc.h>
-#include <sys/shm.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sys/mman.h>
+#if 0
#include <xcb/xcb.h>
#include <xcb/xcb_image.h>
#include <xcb/xcb_atom.h>
#include <xcb/xcb_icccm.h>
#include <xcb/xcb_aux.h>
#include <xcb/xcb_keysyms.h>
+#endif
+#include <wayland-client.h>
#include "libnsfb.h"
#include "libnsfb_event.h"
@@ -33,6 +40,8 @@
#include "plot.h"
#include "cursor.h"
+#if 0
+
#if defined(NSFB_NEED_HINTS_ALLOC)
static xcb_size_hints_t *
xcb_alloc_size_hints(void)
@@ -574,11 +583,14 @@ xcopy(nsfb_t *nsfb, nsfb_bbox_t *srcbox, nsfb_bbox_t *dstbox)
}
+#endif
+
static int
wld_set_geometry(nsfb_t *nsfb, int width, int height, enum nsfb_format_e format)
{
}
+#if 0
static int
x_set_geometry(nsfb_t *nsfb, int width, int height, enum nsfb_format_e format)
{
@@ -766,6 +778,7 @@ create_blank_cursor(xcb_connection_t *conn, const xcb_screen_t *scr)
}
return cur;
}
+#endif
/** structure for display, registry and other global objects that
* should be cached when connecting to a wayland instance
@@ -794,19 +807,19 @@ struct wld_connection {
};
-/** shared memory interface format available callback
+/** shared memory interface format available callback
*
* @param ctx context from when listener was added.
- * @param wl_shm The shared memory object.
- * @param format The available shared memory format. Found in
- * wayland-client-protocol.h there are currently only two
+ * @param wl_shm The shared memory object.
+ * @param format The available shared memory format. Found in
+ * wayland-client-protocol.h there are currently only two
* formats available (A|X)RGB8888 so using a bitfield is ok.
*/
static void
shm_format(void *ctx, struct wl_shm *wl_shm, uint32_t format)
{
struct wld_connection* connection = ctx;
-
+
connection->shm_formats |= (1 << format);
}
@@ -818,7 +831,7 @@ struct wl_shm_listener shm_listenter = {
/** registry global addition callback
*
- * @param ctx context from when listener was added
+ * @param ctx context from when listener was added
*/
static void
registry_handle_global(void *ctx,
@@ -850,8 +863,8 @@ registry_handle_global(void *ctx,
* and add a listener for the shared memory callbacks
*/
connection->shm = wl_registry_bind(registry,
- id,
- &wl_shm_interface,
+ id,
+ &wl_shm_interface,
1);
if (connection->shm != NULL) {
connection->shm_formats = 0;
@@ -875,6 +888,30 @@ static const struct wl_registry_listener registry_listener = {
};
+static void
+free_connection(struct wld_connection* connection)
+{
+ if (connection->compositor != NULL) {
+ wl_compositor_destroy(connection->compositor);
+ }
+
+ if (connection->shell != NULL) {
+ wl_shell_destroy(connection->shell);
+ }
+
+ if (connection->shm != NULL) {
+ wl_shm_destroy(connection->shm);
+ }
+
+ wl_registry_destroy(connection->registry);
+
+ wl_display_flush(connection->display);
+
+ wl_display_disconnect(connection->display);
+
+ free(connection);
+}
+
/** construct a new connection to the wayland instance and aquire all
* necessary global objects
*/
@@ -928,7 +965,7 @@ new_connection(void)
wl_display_roundtrip(connection->display);
/* check the XRGB8888 shared memory format is available */
- if (!(display->formats & (1 << WL_SHM_FORMAT_XRGB8888))) {
+ if (!(connection->shm_formats & (1 << WL_SHM_FORMAT_XRGB8888))) {
fprintf(stderr, "WL_SHM_FORMAT_XRGB8888 not available\n");
free_connection(connection);
@@ -939,33 +976,11 @@ new_connection(void)
return connection;
}
-static void
-free_connection(struct wld_connection* connection)
-{
- if (connection->compositor != NULL) {
- wl_compositor_destroy(connection->compositor);
- }
-
- if (connection->shell != NULL) {
- wl_shell_destroy(connection->shell);
- }
-
- if (connection->shm != NULL) {
- wl_shm_destroy(connection->shm);
- }
-
- wl_registry_destroy(connection->registry);
-
- wl_display_flush(connection->display);
-
- wl_display_disconnect(connection->display);
-
- free(connection);
-}
typedef struct wldstate_s {
struct wld_connection* connection; /**< connection to wayland server */
struct wld_window *window;
+ struct wld_shm_buffer *shm_buffer;
#if 0
xcb_connection_t *connection; /* The x server connection */
xcb_screen_t *screen; /* The screen to put the window on */
@@ -989,14 +1004,8 @@ struct wld_window {
struct wl_surface *surface;
struct wl_shell_surface *shell_surface;
- struct wl_callback *callback;
int width, height;
-
-#if 0
- struct buffer buffers[2];
- struct buffer *prev_buffer;
-#endif
};
static void
@@ -1034,7 +1043,6 @@ new_window(struct wld_connection *connection, int width, int height)
}
window->connection = connection;
- window->callback = NULL;
window->width = width;
window->height = height;
@@ -1069,10 +1077,6 @@ new_window(struct wld_connection *connection, int width, int height)
static void
free_window(struct wld_window *window)
{
- if (window->callback != NULL) {
-
- wl_callback_destroy(window->callback);
- }
wl_shell_surface_destroy(window->shell_surface);
wl_surface_destroy(window->surface);
@@ -1080,6 +1084,143 @@ free_window(struct wld_window *window)
free(window);
}
+/*
+ * Create a new, unique, anonymous file of the given size, and
+ * return the file descriptor for it. The file descriptor is set
+ * CLOEXEC. The file is immediately suitable for mmap()'ing
+ * the given size at offset zero.
+ *
+ * The file should not have a permanent backing store like a disk,
+ * but may have if XDG_RUNTIME_DIR is not properly implemented in OS.
+ *
+ * The file name is deleted from the file system.
+ *
+ * The file is suitable for buffer sharing between processes by
+ * transmitting the file descriptor over Unix sockets using the
+ * SCM_RIGHTS methods.
+ */
+static int
+os_create_anonymous_file(off_t size)
+{
+ static const char template[] = "/weston-shared-XXXXXX";
+ const char *path;
+ char *name;
+ int fd;
+
+ path = getenv("XDG_RUNTIME_DIR");
+ if (!path) {
+ errno = ENOENT;
+ return -1;
+ }
+
+ name = malloc(strlen(path) + sizeof(template));
+ if (!name)
+ return -1;
+
+ strcpy(name, path);
+ strcat(name, template);
+
+ fd = mkostemp(name, O_CLOEXEC);
+ if (fd >= 0)
+ unlink(name);
+
+ free(name);
+
+ if (fd < 0)
+ return -1;
+
+ if (ftruncate(fd, size) < 0) {
+ close(fd);
+ return -1;
+ }
+
+ return fd;
+}
+
+struct wld_shm_buffer {
+ struct wl_buffer *buffer; /**< wayland buffer object */
+ void *data; /**< mapped memory */
+ int size; /**< size of mapped memory */
+ bool inuse; /**< flag to indicate if the buffer has been released
+ * after commit to a surface.
+ */
+};
+
+static void
+buffer_release(void *data, struct wl_buffer *buffer)
+{
+ struct wld_shm_buffer *shmbuf = data;
+
+ shmbuf->inuse = false;
+}
+
+static const struct wl_buffer_listener buffer_listener = {
+ buffer_release
+};
+
+static struct wld_shm_buffer *
+new_shm_buffer(struct wl_shm *shm,
+ int width,
+ int height,
+ uint32_t format)
+{
+ struct wl_shm_pool *pool;
+ struct wld_shm_buffer *shmbuff;
+ int fd;
+ int stride;
+
+ shmbuff = calloc(1, sizeof(struct wld_shm_buffer));
+ if (shmbuff == NULL) {
+ return NULL;
+ }
+
+ stride = width * 4;
+ shmbuff->size = stride * height;
+
+ fd = os_create_anonymous_file(shmbuff->size);
+ if (fd < 0) {
+ free(shmbuff);
+ return NULL;
+ }
+
+ shmbuff->data = mmap(NULL,
+ shmbuff->size,
+ PROT_READ | PROT_WRITE,
+ MAP_SHARED,
+ fd,
+ 0);
+ if (shmbuff->data == MAP_FAILED) {
+ close(fd);
+ free(shmbuff);
+ return NULL;
+ }
+
+ pool = wl_shm_create_pool(shm, fd, shmbuff->size);
+ shmbuff->buffer = wl_shm_pool_create_buffer(pool,
+ 0,
+ width,
+ height,
+ stride,
+ format);
+ wl_shm_pool_destroy(pool);
+ close(fd);
+
+ if (shmbuff->buffer == NULL) {
+ munmap(shmbuff->data, shmbuff->size);
+ free(shmbuff);
+ return NULL;
+ }
+
+ wl_buffer_add_listener(shmbuff->buffer, &buffer_listener, shmbuff);
+
+ return shmbuff;
+}
+
+static void free_shm_buffer(struct wld_shm_buffer *shmbuf)
+{
+ munmap(shmbuf->data, shmbuf->size);
+ free(shmbuf);
+}
static int wld_initialise(nsfb_t *nsfb)
{
@@ -1101,19 +1242,38 @@ static int wld_initialise(nsfb_t *nsfb)
wldstate->connection = new_connection();
if (wldstate->connection == NULL) {
fprintf(stderr, "Error initialising wayland connection\n");
+
free(wldstate);
+
return -1; /* error */
}
- wldstate->window = new_window(wldstate->connection,
- nsfb->width,
+ wldstate->window = new_window(wldstate->connection,
+ nsfb->width,
nsfb->height);
- if (wldstate->connection == NULL) {
+ if (wldstate->window == NULL) {
fprintf(stderr, "Error creating wayland window\n");
free_connection(wldstate->connection);
free(wldstate);
+
+ return -1; /* error */
+ }
+
+ wldstate->shm_buffer = new_shm_buffer(wldstate->connection->shm,
+ nsfb->width,
+ nsfb->height,
+ WL_SHM_FORMAT_XRGB8888);
+ if (wldstate->shm_buffer == NULL) {
+ fprintf(stderr, "Error creating wayland shared memory\n");
+
+ free_window(wldstate->window);
+
+ free_connection(wldstate->connection);
+
+ free(wldstate);
+
return -1; /* error */
}
@@ -1130,11 +1290,14 @@ static int wld_finalise(nsfb_t *nsfb)
return 0; /* not initialised */
}
+ free_shm_buffer(wldstate->shm_buffer);
+
free_window(wldstate->window);
free_connection(wldstate->connection);
}
+#if 0
static int x_initialise(nsfb_t *nsfb)
{
uint32_t mask;
@@ -1265,11 +1428,29 @@ static int x_finalise(nsfb_t *nsfb)
return 0;
}
+#endif
static bool wld_input(nsfb_t *nsfb, nsfb_event_t *event, int timeout)
{
+ wldstate_t *wldstate = nsfb->surface_priv;
+ int ret = 0;
+
+ if (wldstate == NULL) {
+ return false;
+ }
+
+ ret = wl_display_dispatch(wldstate->connection->display);
+ if (ret == -1) {
+ /* error, time to quit */
+ event->type = NSFB_EVENT_CONTROL;
+ event->value.controlcode = NSFB_CONTROL_QUIT;
+ return true;
+ }
+
+ return false;
}
+#if 0
static bool x_input(nsfb_t *nsfb, nsfb_event_t *event, int timeout)
{
xcb_generic_event_t *e;
@@ -1423,13 +1604,10 @@ static bool x_input(nsfb_t *nsfb, nsfb_event_t *event, int timeout)
return true;
}
+#endif
static int wld_claim(nsfb_t *nsfb, nsfb_bbox_t *box)
{
-}
-
-static int x_claim(nsfb_t *nsfb, nsfb_bbox_t *box)
-{
struct nsfb_cursor_s *cursor = nsfb->cursor;
if ((cursor != NULL) &&
@@ -1440,12 +1618,12 @@ static int x_claim(nsfb_t *nsfb, nsfb_bbox_t *box)
return 0;
}
-
static int
wld_cursor(nsfb_t *nsfb, struct nsfb_cursor_s *cursor)
{
}
+#if 0
static int
x_cursor(nsfb_t *nsfb, struct nsfb_cursor_s *cursor)
{
@@ -1477,11 +1655,13 @@ x_cursor(nsfb_t *nsfb, struct nsfb_cursor_s *cursor)
}
return true;
}
+#endif
static int wld_update(nsfb_t *nsfb, nsfb_bbox_t *box)
{
}
+#if 0
static int x_update(nsfb_t *nsfb, nsfb_bbox_t *box)
{
xstate_t *xstate = nsfb->surface_priv;
@@ -1496,6 +1676,7 @@ static int x_update(nsfb_t *nsfb, nsfb_bbox_t *box)
return 0;
}
+#endif
const nsfb_surface_rtns_t wld_rtns = {
.initialise = wld_initialise,
-----------------------------------------------------------------------
Summary of changes:
src/surface/wld.c | 434 +++++++++++++++++++++++++++++++++++++++--------------
1 files changed, 324 insertions(+), 110 deletions(-)
diff --git a/src/surface/wld.c b/src/surface/wld.c
index d450738..76067e7 100644
--- a/src/surface/wld.c
+++ b/src/surface/wld.c
@@ -13,15 +13,22 @@
#include <stdio.h>
#include <string.h>
-#include <sys/ipc.h>
-#include <sys/shm.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sys/mman.h>
+#if 0
#include <xcb/xcb.h>
#include <xcb/xcb_image.h>
#include <xcb/xcb_atom.h>
#include <xcb/xcb_icccm.h>
#include <xcb/xcb_aux.h>
#include <xcb/xcb_keysyms.h>
+#endif
+#include <wayland-client.h>
#include "libnsfb.h"
#include "libnsfb_event.h"
@@ -33,6 +40,75 @@
#include "plot.h"
#include "cursor.h"
+/** structure for display, registry and other global objects that
+ * should be cached when connecting to a wayland instance
+ */
+struct wld_connection {
+ struct wl_display *display; /**< connection object */
+ struct wl_registry *registry; /**< registry object */
+
+ /** compositor object, available once teh registry messages have
+ * been processed
+ */
+ struct wl_compositor *compositor;
+
+ /** shell object, available once the registry messages have been
+ * processed
+ */
+ struct wl_shell *shell;
+
+ /** shared memory object, available once the registry messages
+ * have been processed
+ */
+ struct wl_shm *shm;
+
+ /** shared memory formats available */
+ uint32_t shm_formats;
+};
+
+/* wayland window encompasing the display and shell surfaces */
+struct wld_window {
+ struct wld_connection* connection; /**< connection to wayland server */
+
+ struct wl_surface *surface;
+ struct wl_shell_surface *shell_surface;
+
+ int width, height;
+};
+
+struct wld_shm_buffer {
+ struct wl_buffer *buffer; /**< wayland buffer object */
+ void *data; /**< mapped memory */
+ int size; /**< size of mapped memory */
+ bool inuse; /**< flag to indicate if the buffer has been released
+ * after commit to a surface.
+ */
+};
+
+typedef struct wldstate_s {
+ struct wld_connection* connection; /**< connection to wayland server */
+ struct wld_window *window;
+ struct wld_shm_buffer *shm_buffer;
+#if 0
+ xcb_connection_t *connection; /* The x server connection */
+ xcb_screen_t *screen; /* The screen to put the window on */
+ xcb_key_symbols_t *keysymbols; /* keysym mappings */
+
+ xcb_shm_segment_info_t shminfo;
+
+ xcb_image_t *image; /* The X image buffer */
+
+ xcb_window_t window; /* The handle to the window */
+ xcb_pixmap_t pmap; /* The handle to the backing pixmap */
+ xcb_gcontext_t gc; /* The handle to the pixmap plotting graphics context */
+ xcb_shm_seg_t segment; /* The handle to the image shared memory */
+#endif
+
+} wldstate_t;
+
+
+#if 0
+
#if defined(NSFB_NEED_HINTS_ALLOC)
static xcb_size_hints_t *
xcb_alloc_size_hints(void)
@@ -574,13 +650,11 @@ xcopy(nsfb_t *nsfb, nsfb_bbox_t *srcbox, nsfb_bbox_t *dstbox)
}
-static int
-wld_set_geometry(nsfb_t *nsfb, int width, int height, enum nsfb_format_e format)
-{
-}
+#endif
+
static int
-x_set_geometry(nsfb_t *nsfb, int width, int height, enum nsfb_format_e format)
+wld_set_geometry(nsfb_t *nsfb, int width, int height, enum nsfb_format_e format)
{
if (nsfb->surface_priv != NULL)
return -1; /* if were already initialised fail */
@@ -592,11 +666,10 @@ x_set_geometry(nsfb_t *nsfb, int width, int height, enum nsfb_format_e format)
/* select default sw plotters for format */
select_plotters(nsfb);
- nsfb->plotter_fns->copy = xcopy;
-
- return 0;
}
+#if 0
+
static xcb_format_t *
find_format(xcb_connection_t * c, uint8_t depth, uint8_t bpp)
@@ -766,47 +839,22 @@ create_blank_cursor(xcb_connection_t *conn, const xcb_screen_t *scr)
}
return cur;
}
-
-/** structure for display, registry and other global objects that
- * should be cached when connecting to a wayland instance
- */
-struct wld_connection {
- struct wl_display *display; /**< connection object */
- struct wl_registry *registry; /**< registry object */
-
- /** compositor object, available once teh registry messages have
- * been processed
- */
- struct wl_compositor *compositor;
-
- /** shell object, available once the registry messages have been
- * processed
- */
- struct wl_shell *shell;
-
- /** shared memory object, available once the registry messages
- * have been processed
- */
- struct wl_shm *shm;
-
- /** shared memory formats available */
- uint32_t shm_formats;
-};
+#endif
-/** shared memory interface format available callback
+/** shared memory interface format available callback
*
* @param ctx context from when listener was added.
- * @param wl_shm The shared memory object.
- * @param format The available shared memory format. Found in
- * wayland-client-protocol.h there are currently only two
+ * @param wl_shm The shared memory object.
+ * @param format The available shared memory format. Found in
+ * wayland-client-protocol.h there are currently only two
* formats available (A|X)RGB8888 so using a bitfield is ok.
*/
static void
shm_format(void *ctx, struct wl_shm *wl_shm, uint32_t format)
{
struct wld_connection* connection = ctx;
-
+
connection->shm_formats |= (1 << format);
}
@@ -818,7 +866,7 @@ struct wl_shm_listener shm_listenter = {
/** registry global addition callback
*
- * @param ctx context from when listener was added
+ * @param ctx context from when listener was added
*/
static void
registry_handle_global(void *ctx,
@@ -850,8 +898,8 @@ registry_handle_global(void *ctx,
* and add a listener for the shared memory callbacks
*/
connection->shm = wl_registry_bind(registry,
- id,
- &wl_shm_interface,
+ id,
+ &wl_shm_interface,
1);
if (connection->shm != NULL) {
connection->shm_formats = 0;
@@ -875,6 +923,30 @@ static const struct wl_registry_listener registry_listener = {
};
+static void
+free_connection(struct wld_connection* connection)
+{
+ if (connection->compositor != NULL) {
+ wl_compositor_destroy(connection->compositor);
+ }
+
+ if (connection->shell != NULL) {
+ wl_shell_destroy(connection->shell);
+ }
+
+ if (connection->shm != NULL) {
+ wl_shm_destroy(connection->shm);
+ }
+
+ wl_registry_destroy(connection->registry);
+
+ wl_display_flush(connection->display);
+
+ wl_display_disconnect(connection->display);
+
+ free(connection);
+}
+
/** construct a new connection to the wayland instance and aquire all
* necessary global objects
*/
@@ -928,7 +1000,7 @@ new_connection(void)
wl_display_roundtrip(connection->display);
/* check the XRGB8888 shared memory format is available */
- if (!(display->formats & (1 << WL_SHM_FORMAT_XRGB8888))) {
+ if (!(connection->shm_formats & (1 << WL_SHM_FORMAT_XRGB8888))) {
fprintf(stderr, "WL_SHM_FORMAT_XRGB8888 not available\n");
free_connection(connection);
@@ -939,66 +1011,31 @@ new_connection(void)
return connection;
}
-static void
-free_connection(struct wld_connection* connection)
-{
- if (connection->compositor != NULL) {
- wl_compositor_destroy(connection->compositor);
- }
- if (connection->shell != NULL) {
- wl_shell_destroy(connection->shell);
- }
- if (connection->shm != NULL) {
- wl_shm_destroy(connection->shm);
- }
+static int
+update_and_redraw(struct wldstate_s *wldstate,
+ int x,
+ int y,
+ int width,
+ int height)
+{
+ wl_surface_attach(wldstate->window->surface,
+ wldstate->shm_buffer->buffer,
+ 0,
+ 0);
- wl_registry_destroy(connection->registry);
+ wl_surface_damage(wldstate->window->surface, x, y, width, height);
- wl_display_flush(connection->display);
+ wl_surface_commit(wldstate->window->surface);
+ wldstate->shm_buffer->inuse = true;
- wl_display_disconnect(connection->display);
+ /** @todo should this be here? */
+ wl_display_roundtrip(wldstate->connection->display);
- free(connection);
+ return 0;
}
-typedef struct wldstate_s {
- struct wld_connection* connection; /**< connection to wayland server */
- struct wld_window *window;
-#if 0
- xcb_connection_t *connection; /* The x server connection */
- xcb_screen_t *screen; /* The screen to put the window on */
- xcb_key_symbols_t *keysymbols; /* keysym mappings */
-
- xcb_shm_segment_info_t shminfo;
-
- xcb_image_t *image; /* The X image buffer */
-
- xcb_window_t window; /* The handle to the window */
- xcb_pixmap_t pmap; /* The handle to the backing pixmap */
- xcb_gcontext_t gc; /* The handle to the pixmap plotting graphics context */
- xcb_shm_seg_t segment; /* The handle to the image shared memory */
-#endif
-
-} wldstate_t;
-
-/* wayland window encompasing the display and shell surfaces */
-struct wld_window {
- struct wld_connection* connection; /**< connection to wayland server */
-
- struct wl_surface *surface;
- struct wl_shell_surface *shell_surface;
- struct wl_callback *callback;
-
- int width, height;
-
-#if 0
- struct buffer buffers[2];
- struct buffer *prev_buffer;
-#endif
-};
-
static void
handle_ping(void *data, struct wl_shell_surface *shell_surface,
uint32_t serial)
@@ -1034,7 +1071,6 @@ new_window(struct wld_connection *connection, int width, int height)
}
window->connection = connection;
- window->callback = NULL;
window->width = width;
window->height = height;
@@ -1069,10 +1105,6 @@ new_window(struct wld_connection *connection, int width, int height)
static void
free_window(struct wld_window *window)
{
- if (window->callback != NULL) {
-
- wl_callback_destroy(window->callback);
- }
wl_shell_surface_destroy(window->shell_surface);
wl_surface_destroy(window->surface);
@@ -1080,6 +1112,135 @@ free_window(struct wld_window *window)
free(window);
}
+/*
+ * Create a new, unique, anonymous file of the given size, and
+ * return the file descriptor for it. The file descriptor is set
+ * CLOEXEC. The file is immediately suitable for mmap()'ing
+ * the given size at offset zero.
+ *
+ * The file should not have a permanent backing store like a disk,
+ * but may have if XDG_RUNTIME_DIR is not properly implemented in OS.
+ *
+ * The file name is deleted from the file system.
+ *
+ * The file is suitable for buffer sharing between processes by
+ * transmitting the file descriptor over Unix sockets using the
+ * SCM_RIGHTS methods.
+ */
+static int
+os_create_anonymous_file(off_t size)
+{
+ static const char template[] = "/weston-shared-XXXXXX";
+ const char *path;
+ char *name;
+ int fd;
+
+ path = getenv("XDG_RUNTIME_DIR");
+ if (!path) {
+ errno = ENOENT;
+ return -1;
+ }
+
+ name = malloc(strlen(path) + sizeof(template));
+ if (!name)
+ return -1;
+
+ strcpy(name, path);
+ strcat(name, template);
+
+ fd = mkostemp(name, O_CLOEXEC);
+ if (fd >= 0)
+ unlink(name);
+
+ free(name);
+
+ if (fd < 0)
+ return -1;
+
+ if (ftruncate(fd, size) < 0) {
+ close(fd);
+ return -1;
+ }
+
+ return fd;
+}
+
+
+static void
+buffer_release(void *data, struct wl_buffer *buffer)
+{
+ struct wld_shm_buffer *shmbuf = data;
+
+ shmbuf->inuse = false;
+}
+
+static const struct wl_buffer_listener buffer_listener = {
+ buffer_release
+};
+
+static struct wld_shm_buffer *
+new_shm_buffer(struct wl_shm *shm,
+ int width,
+ int height,
+ uint32_t format)
+{
+ struct wl_shm_pool *pool;
+ struct wld_shm_buffer *shmbuff;
+ int fd;
+ int stride;
+
+ shmbuff = calloc(1, sizeof(struct wld_shm_buffer));
+ if (shmbuff == NULL) {
+ return NULL;
+ }
+
+ stride = width * 4;
+ shmbuff->size = stride * height;
+
+ fd = os_create_anonymous_file(shmbuff->size);
+ if (fd < 0) {
+ free(shmbuff);
+ return NULL;
+ }
+
+ shmbuff->data = mmap(NULL,
+ shmbuff->size,
+ PROT_READ | PROT_WRITE,
+ MAP_SHARED,
+ fd,
+ 0);
+ if (shmbuff->data == MAP_FAILED) {
+ close(fd);
+ free(shmbuff);
+ return NULL;
+ }
+
+ pool = wl_shm_create_pool(shm, fd, shmbuff->size);
+ shmbuff->buffer = wl_shm_pool_create_buffer(pool,
+ 0,
+ width,
+ height,
+ stride,
+ format);
+ wl_shm_pool_destroy(pool);
+ close(fd);
+
+ if (shmbuff->buffer == NULL) {
+ munmap(shmbuff->data, shmbuff->size);
+ free(shmbuff);
+ return NULL;
+ }
+
+ wl_buffer_add_listener(shmbuff->buffer, &buffer_listener, shmbuff);
+
+ return shmbuff;
+}
+
+static void free_shm_buffer(struct wld_shm_buffer *shmbuf)
+{
+ munmap(shmbuf->data, shmbuf->size);
+ free(shmbuf);
+}
static int wld_initialise(nsfb_t *nsfb)
{
@@ -1101,22 +1262,46 @@ static int wld_initialise(nsfb_t *nsfb)
wldstate->connection = new_connection();
if (wldstate->connection == NULL) {
fprintf(stderr, "Error initialising wayland connection\n");
+
free(wldstate);
+
return -1; /* error */
}
- wldstate->window = new_window(wldstate->connection,
- nsfb->width,
+ wldstate->window = new_window(wldstate->connection,
+ nsfb->width,
nsfb->height);
- if (wldstate->connection == NULL) {
+ if (wldstate->window == NULL) {
fprintf(stderr, "Error creating wayland window\n");
free_connection(wldstate->connection);
free(wldstate);
+
return -1; /* error */
}
+ wldstate->shm_buffer = new_shm_buffer(wldstate->connection->shm,
+ nsfb->width,
+ nsfb->height,
+ WL_SHM_FORMAT_XRGB8888);
+ if (wldstate->shm_buffer == NULL) {
+ fprintf(stderr, "Error creating wayland shared memory\n");
+
+ free_window(wldstate->window);
+
+ free_connection(wldstate->connection);
+
+ free(wldstate);
+
+ return -1; /* error */
+ }
+
+ nsfb->ptr = wldstate->shm_buffer->data;
+ nsfb->linelen = nsfb->width * 4;
+
+ update_and_redraw(wldstate,0,0, nsfb->width, nsfb->height);
+
nsfb->surface_priv = wldstate;
return 0;
@@ -1130,11 +1315,14 @@ static int wld_finalise(nsfb_t *nsfb)
return 0; /* not initialised */
}
+ free_shm_buffer(wldstate->shm_buffer);
+
free_window(wldstate->window);
free_connection(wldstate->connection);
}
+#if 0
static int x_initialise(nsfb_t *nsfb)
{
uint32_t mask;
@@ -1265,11 +1453,31 @@ static int x_finalise(nsfb_t *nsfb)
return 0;
}
+#endif
static bool wld_input(nsfb_t *nsfb, nsfb_event_t *event, int timeout)
{
+ wldstate_t *wldstate = nsfb->surface_priv;
+ int ret = 0;
+
+ if (wldstate == NULL) {
+ return false;
+ }
+
+ ret = wl_display_dispatch(wldstate->connection->display);
+ if (ret == -1) {
+ /* error, time to quit */
+ event->type = NSFB_EVENT_CONTROL;
+ event->value.controlcode = NSFB_CONTROL_QUIT;
+ return true;
+ }
+
+ event->type = NSFB_EVENT_NONE;
+
+ return false;
}
+#if 0
static bool x_input(nsfb_t *nsfb, nsfb_event_t *event, int timeout)
{
xcb_generic_event_t *e;
@@ -1423,13 +1631,10 @@ static bool x_input(nsfb_t *nsfb, nsfb_event_t *event, int timeout)
return true;
}
+#endif
static int wld_claim(nsfb_t *nsfb, nsfb_bbox_t *box)
{
-}
-
-static int x_claim(nsfb_t *nsfb, nsfb_bbox_t *box)
-{
struct nsfb_cursor_s *cursor = nsfb->cursor;
if ((cursor != NULL) &&
@@ -1440,12 +1645,12 @@ static int x_claim(nsfb_t *nsfb, nsfb_bbox_t *box)
return 0;
}
-
static int
wld_cursor(nsfb_t *nsfb, struct nsfb_cursor_s *cursor)
{
}
+#if 0
static int
x_cursor(nsfb_t *nsfb, struct nsfb_cursor_s *cursor)
{
@@ -1477,11 +1682,19 @@ x_cursor(nsfb_t *nsfb, struct nsfb_cursor_s *cursor)
}
return true;
}
+#endif
static int wld_update(nsfb_t *nsfb, nsfb_bbox_t *box)
{
+ wldstate_t *wldstate = nsfb->surface_priv;
+
+ if (wldstate != NULL) {
+ update_and_redraw(wldstate, box->x0, box->y0, box->x1 - box->x0, box->y1 - box->y0);
+ }
+ return 0;
}
+#if 0
static int x_update(nsfb_t *nsfb, nsfb_bbox_t *box)
{
xstate_t *xstate = nsfb->surface_priv;
@@ -1496,6 +1709,7 @@ static int x_update(nsfb_t *nsfb, nsfb_bbox_t *box)
return 0;
}
+#endif
const nsfb_surface_rtns_t wld_rtns = {
.initialise = wld_initialise,
--
NetSurf Framebuffer library
9 years, 10 months
netsurf: branch master updated. b23c580f338ba13983edb5ad49f2a1242e0bc3d5
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/b23c580f338ba13983edb...
...commit http://git.netsurf-browser.org/netsurf.git/commit/b23c580f338ba13983edb5a...
...tree http://git.netsurf-browser.org/netsurf.git/tree/b23c580f338ba13983edb5ad4...
The branch, master has been updated
via b23c580f338ba13983edb5ad49f2a1242e0bc3d5 (commit)
via 48dc679d7bfe9f45bd50d86882d88a9ddb1d659c (commit)
via 15cb6886f2ddee80dc5163aae95d148044bc6882 (commit)
via 1f9e1ca84b0db9591ac0fb204ead59c10ee8b9fe (commit)
from c91db66e2dbb0fe183b5f473bfeb454540e64a42 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=b23c580f338ba13983e...
commit b23c580f338ba13983edb5ad49f2a1242e0bc3d5
Merge: c91db66 48dc679
Author: Daniel Silverstone (parasomnia chroot) <dsilvers(a)digital-scurf.org>
Commit: Daniel Silverstone (parasomnia chroot) <dsilvers(a)digital-scurf.org>
Merge remote-tracking branch 'origin/mmu_man/beos-fixes'
-----------------------------------------------------------------------
Summary of changes:
Makefile | 2 +-
beos/font.cpp | 5 +++--
beos/scaffolding.cpp | 18 ++++++++++++------
3 files changed, 16 insertions(+), 9 deletions(-)
diff --git a/Makefile b/Makefile
index f17f19a..ddce6bf 100644
--- a/Makefile
+++ b/Makefile
@@ -542,7 +542,7 @@ ifeq ($(TARGET),beos)
$(Q)$(BEOS_SETVER) $(EXETARGET) \
-app $(VERSION_MAJ) $(VERSION_MIN) 0 d 0 \
-short "NetSurf $(VERSION_FULL)" \
- -long "NetSurf $(VERSION_FULL) © 2003 - 2012 The NetSurf Developers"
+ -long "NetSurf $(VERSION_FULL) © 2003 - 2013 The NetSurf Developers"
$(VQ)echo " MIMESET: $(EXETARGET)"
$(Q)$(BEOS_MIMESET) $(EXETARGET)
endif
diff --git a/beos/font.cpp b/beos/font.cpp
index c2d5e7b..b73c9cc 100644
--- a/beos/font.cpp
+++ b/beos/font.cpp
@@ -141,11 +141,12 @@ bool nsfont_position_in_string(const plot_font_style_t *fstyle,
font.GetEscapements(string, len, escapements);
// slow but it should work
for (i = 0; string[index] && i < len; i++) {
- if (x < current)
- break;
esc += escapements[i];
current = font.Size() * esc;
index += utf8_char_len(&string[index]);
+ // is current char already too far away?
+ if (x < current)
+ break;
}
*actual_x = (int)current;
*char_offset = i; //index;
diff --git a/beos/scaffolding.cpp b/beos/scaffolding.cpp
index 7f2b120..9954dd6 100644
--- a/beos/scaffolding.cpp
+++ b/beos/scaffolding.cpp
@@ -142,6 +142,7 @@ struct replicant_thread_info {
static int open_windows = 0; /**< current number of open browsers */
static NSBaseView *replicant_view = NULL; /**< if not NULL, the replicant View we are running NetSurf for */
static sem_id replicant_done_sem = -1;
+static thread_id replicant_thread = -1;
static void nsbeos_window_update_back_forward(struct beos_scaffolding *);
static void nsbeos_throb(void *);
@@ -224,9 +225,14 @@ NSBaseView::NSBaseView(BMessage *archive)
NSBaseView::~NSBaseView()
{
//warn_user ("~NSBaseView()", NULL);
- BMessage *message = new BMessage(B_QUIT_REQUESTED);
- nsbeos_pipe_message_top(message, NULL, fScaffolding);
- while (acquire_sem(replicant_done_sem) == EINTR);
+ if (replicated) {
+ BMessage *message = new BMessage(B_QUIT_REQUESTED);
+ nsbeos_pipe_message_top(message, NULL, fScaffolding);
+ while (acquire_sem(replicant_done_sem) == EINTR);
+ //debugger("plop");
+ status_t status = -1;
+ wait_for_thread(replicant_thread, &status);
+ }
}
@@ -397,15 +403,15 @@ NSBaseView::Instantiate(BMessage *archive)
gui_init_replicant(2, info->args);
replicant_done_sem = create_sem(0, "NS Replicant created");
- thread_id nsMainThread = spawn_thread(nsbeos_replicant_main_thread,
+ replicant_thread = spawn_thread(nsbeos_replicant_main_thread,
"NetSurf Main Thread", B_NORMAL_PRIORITY, info);
- if (nsMainThread < B_OK) {
+ if (replicant_thread < B_OK) {
delete_sem(replicant_done_sem);
delete info;
delete view;
return NULL;
}
- resume_thread(nsMainThread);
+ resume_thread(replicant_thread);
//XXX: deadlocks BeHappy
//while (acquire_sem(replicant_done_sem) == EINTR);
--
NetSurf Browser
9 years, 10 months
netsurf: branch mmu_man/beos-fixes updated. 48dc679d7bfe9f45bd50d86882d88a9ddb1d659c
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/48dc679d7bfe9f45bd50d...
...commit http://git.netsurf-browser.org/netsurf.git/commit/48dc679d7bfe9f45bd50d86...
...tree http://git.netsurf-browser.org/netsurf.git/tree/48dc679d7bfe9f45bd50d8688...
The branch, mmu_man/beos-fixes has been updated
via 48dc679d7bfe9f45bd50d86882d88a9ddb1d659c (commit)
from 15cb6886f2ddee80dc5163aae95d148044bc6882 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=48dc679d7bfe9f45bd5...
commit 48dc679d7bfe9f45bd50d86882d88a9ddb1d659c
Author: François Revol <revol(a)free.fr>
Commit: François Revol <revol(a)free.fr>
beos: Fix replicants
Waiting on the semaphore was not enough, it was causing a crash on
replicant removal. Now we wait for the replicant main thread to exit.
It fixes replicants, at least when a single one is used per application.
Using more than one still causes issues due to some libs not liking
being used twice (hlcache it seems).
diff --git a/beos/scaffolding.cpp b/beos/scaffolding.cpp
index 7f2b120..9954dd6 100644
--- a/beos/scaffolding.cpp
+++ b/beos/scaffolding.cpp
@@ -142,6 +142,7 @@ struct replicant_thread_info {
static int open_windows = 0; /**< current number of open browsers */
static NSBaseView *replicant_view = NULL; /**< if not NULL, the replicant View we are running NetSurf for */
static sem_id replicant_done_sem = -1;
+static thread_id replicant_thread = -1;
static void nsbeos_window_update_back_forward(struct beos_scaffolding *);
static void nsbeos_throb(void *);
@@ -224,9 +225,14 @@ NSBaseView::NSBaseView(BMessage *archive)
NSBaseView::~NSBaseView()
{
//warn_user ("~NSBaseView()", NULL);
- BMessage *message = new BMessage(B_QUIT_REQUESTED);
- nsbeos_pipe_message_top(message, NULL, fScaffolding);
- while (acquire_sem(replicant_done_sem) == EINTR);
+ if (replicated) {
+ BMessage *message = new BMessage(B_QUIT_REQUESTED);
+ nsbeos_pipe_message_top(message, NULL, fScaffolding);
+ while (acquire_sem(replicant_done_sem) == EINTR);
+ //debugger("plop");
+ status_t status = -1;
+ wait_for_thread(replicant_thread, &status);
+ }
}
@@ -397,15 +403,15 @@ NSBaseView::Instantiate(BMessage *archive)
gui_init_replicant(2, info->args);
replicant_done_sem = create_sem(0, "NS Replicant created");
- thread_id nsMainThread = spawn_thread(nsbeos_replicant_main_thread,
+ replicant_thread = spawn_thread(nsbeos_replicant_main_thread,
"NetSurf Main Thread", B_NORMAL_PRIORITY, info);
- if (nsMainThread < B_OK) {
+ if (replicant_thread < B_OK) {
delete_sem(replicant_done_sem);
delete info;
delete view;
return NULL;
}
- resume_thread(nsMainThread);
+ resume_thread(replicant_thread);
//XXX: deadlocks BeHappy
//while (acquire_sem(replicant_done_sem) == EINTR);
-----------------------------------------------------------------------
Summary of changes:
beos/scaffolding.cpp | 18 ++++++++++++------
1 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/beos/scaffolding.cpp b/beos/scaffolding.cpp
index 7f2b120..9954dd6 100644
--- a/beos/scaffolding.cpp
+++ b/beos/scaffolding.cpp
@@ -142,6 +142,7 @@ struct replicant_thread_info {
static int open_windows = 0; /**< current number of open browsers */
static NSBaseView *replicant_view = NULL; /**< if not NULL, the replicant View we are running NetSurf for */
static sem_id replicant_done_sem = -1;
+static thread_id replicant_thread = -1;
static void nsbeos_window_update_back_forward(struct beos_scaffolding *);
static void nsbeos_throb(void *);
@@ -224,9 +225,14 @@ NSBaseView::NSBaseView(BMessage *archive)
NSBaseView::~NSBaseView()
{
//warn_user ("~NSBaseView()", NULL);
- BMessage *message = new BMessage(B_QUIT_REQUESTED);
- nsbeos_pipe_message_top(message, NULL, fScaffolding);
- while (acquire_sem(replicant_done_sem) == EINTR);
+ if (replicated) {
+ BMessage *message = new BMessage(B_QUIT_REQUESTED);
+ nsbeos_pipe_message_top(message, NULL, fScaffolding);
+ while (acquire_sem(replicant_done_sem) == EINTR);
+ //debugger("plop");
+ status_t status = -1;
+ wait_for_thread(replicant_thread, &status);
+ }
}
@@ -397,15 +403,15 @@ NSBaseView::Instantiate(BMessage *archive)
gui_init_replicant(2, info->args);
replicant_done_sem = create_sem(0, "NS Replicant created");
- thread_id nsMainThread = spawn_thread(nsbeos_replicant_main_thread,
+ replicant_thread = spawn_thread(nsbeos_replicant_main_thread,
"NetSurf Main Thread", B_NORMAL_PRIORITY, info);
- if (nsMainThread < B_OK) {
+ if (replicant_thread < B_OK) {
delete_sem(replicant_done_sem);
delete info;
delete view;
return NULL;
}
- resume_thread(nsMainThread);
+ resume_thread(replicant_thread);
//XXX: deadlocks BeHappy
//while (acquire_sem(replicant_done_sem) == EINTR);
--
NetSurf Browser
9 years, 10 months
netsurf: branch master updated. c91db66e2dbb0fe183b5f473bfeb454540e64a42
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/c91db66e2dbb0fe183b5f...
...commit http://git.netsurf-browser.org/netsurf.git/commit/c91db66e2dbb0fe183b5f47...
...tree http://git.netsurf-browser.org/netsurf.git/tree/c91db66e2dbb0fe183b5f473b...
The branch, master has been updated
via c91db66e2dbb0fe183b5f473bfeb454540e64a42 (commit)
from ad53da023d7126286d2b8944d52ecf65ff801a24 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=c91db66e2dbb0fe183b...
commit c91db66e2dbb0fe183b5f473bfeb454540e64a42
Author: Ole Loots <ole(a)monochrom.net>
Commit: Ole Loots <ole(a)monochrom.net>
Fixed handling of filepath passed via commandline.
diff --git a/atari/gui.c b/atari/gui.c
index fe32a4a..ef6ab07 100644
--- a/atari/gui.c
+++ b/atari/gui.c
@@ -1067,10 +1067,9 @@ int main(int argc, char** argv)
LOG(("Creating initial browser window..."));
addr = option_homepage_url;
- if (strncmp(addr, "file://", 7)) {
+ if (strncmp(addr, "file://", 7) && strncmp(addr, "http://", 7)) {
if (stat(addr, &stat_buf) == 0) {
- file_url = malloc(strlen(addr)+8);
- sprintf(file_url, "file://%s", addr);
+ file_url = local_file_to_url(addr);
addr = file_url;
}
}
-----------------------------------------------------------------------
Summary of changes:
atari/gui.c | 5 ++---
1 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/atari/gui.c b/atari/gui.c
index fe32a4a..ef6ab07 100644
--- a/atari/gui.c
+++ b/atari/gui.c
@@ -1067,10 +1067,9 @@ int main(int argc, char** argv)
LOG(("Creating initial browser window..."));
addr = option_homepage_url;
- if (strncmp(addr, "file://", 7)) {
+ if (strncmp(addr, "file://", 7) && strncmp(addr, "http://", 7)) {
if (stat(addr, &stat_buf) == 0) {
- file_url = malloc(strlen(addr)+8);
- sprintf(file_url, "file://%s", addr);
+ file_url = local_file_to_url(addr);
addr = file_url;
}
}
--
NetSurf Browser
9 years, 10 months
netsurf: branch mmu_man/beos-fixes updated. 15cb6886f2ddee80dc5163aae95d148044bc6882
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/15cb6886f2ddee80dc516...
...commit http://git.netsurf-browser.org/netsurf.git/commit/15cb6886f2ddee80dc5163a...
...tree http://git.netsurf-browser.org/netsurf.git/tree/15cb6886f2ddee80dc5163aae...
The branch, mmu_man/beos-fixes has been updated
via 15cb6886f2ddee80dc5163aae95d148044bc6882 (commit)
from 1f9e1ca84b0db9591ac0fb204ead59c10ee8b9fe (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=15cb6886f2ddee80dc5...
commit 15cb6886f2ddee80dc5163aae95d148044bc6882
Author: François Revol <revol(a)free.fr>
Commit: François Revol <revol(a)free.fr>
beos: update copyright years in the version info
diff --git a/Makefile b/Makefile
index f17f19a..ddce6bf 100644
--- a/Makefile
+++ b/Makefile
@@ -542,7 +542,7 @@ ifeq ($(TARGET),beos)
$(Q)$(BEOS_SETVER) $(EXETARGET) \
-app $(VERSION_MAJ) $(VERSION_MIN) 0 d 0 \
-short "NetSurf $(VERSION_FULL)" \
- -long "NetSurf $(VERSION_FULL) © 2003 - 2012 The NetSurf Developers"
+ -long "NetSurf $(VERSION_FULL) © 2003 - 2013 The NetSurf Developers"
$(VQ)echo " MIMESET: $(EXETARGET)"
$(Q)$(BEOS_MIMESET) $(EXETARGET)
endif
-----------------------------------------------------------------------
Summary of changes:
Makefile | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/Makefile b/Makefile
index f17f19a..ddce6bf 100644
--- a/Makefile
+++ b/Makefile
@@ -542,7 +542,7 @@ ifeq ($(TARGET),beos)
$(Q)$(BEOS_SETVER) $(EXETARGET) \
-app $(VERSION_MAJ) $(VERSION_MIN) 0 d 0 \
-short "NetSurf $(VERSION_FULL)" \
- -long "NetSurf $(VERSION_FULL) © 2003 - 2012 The NetSurf Developers"
+ -long "NetSurf $(VERSION_FULL) © 2003 - 2013 The NetSurf Developers"
$(VQ)echo " MIMESET: $(EXETARGET)"
$(Q)$(BEOS_MIMESET) $(EXETARGET)
endif
--
NetSurf Browser
9 years, 10 months