28#include <oslib/osfile.h>
29#include <oslib/wimp.h>
48#ifndef wimp_DRAG_CLAIM_SUPPRESS_DRAGBOX
49#define wimp_DRAG_CLAIM_SUPPRESS_DRAGBOX ((wimp_drag_claim_flags) 0x2u)
89 wimp_full_message_claim_entity msg;
90 wimp_auto_scroll_info scroll;
91 wimp_window_state
state;
95 NSLOG(netsurf, INFO,
"starting text_selection drag");
98 error = xwimp_get_window_state(&
state);
100 NSLOG(netsurf, INFO,
"xwimp_get_window_state 0x%x: %s",
101 error->errnum, error->errmess);
107 msg.size =
sizeof(msg);
109 msg.action = message_CLAIM_ENTITY;
110 msg.flags = wimp_CLAIM_CARET_OR_SELECTION;
112 error = xwimp_send_message(wimp_USER_MESSAGE,
113 (wimp_message*)&msg, wimp_BROADCAST);
115 NSLOG(netsurf, INFO,
"xwimp_send_message: 0x%x: %s",
116 error->errnum, error->errmess);
122 scroll.pause_zone_sizes.x0 = 80;
123 scroll.pause_zone_sizes.y0 = 80;
124 scroll.pause_zone_sizes.x1 = 80;
125 scroll.pause_zone_sizes.y1 = 80;
126 scroll.pause_duration = 0;
127 scroll.state_change = (
void *)0;
128 error = xwimp_auto_scroll(wimp_AUTO_SCROLL_ENABLE_VERTICAL |
129 wimp_AUTO_SCROLL_ENABLE_HORIZONTAL,
132 NSLOG(netsurf, INFO,
"xwimp_auto_scroll: 0x%x: %s",
133 error->errnum, error->errmess);
138 drag.type = wimp_DRAG_USER_POINT;
140 drag.bbox.x0 = -16384;
141 drag.bbox.y0 = -16384;
142 drag.bbox.x1 = 16384;
143 drag.bbox.y1 = 16384;
145 error = xwimp_drag_box(&drag);
147 NSLOG(netsurf, INFO,
"xwimp_drag_box: 0x%x : %s",
148 error->errnum, error->errmess);
164 wimp_auto_scroll_info scroll;
165 wimp_pointer pointer;
171 error = xwimp_auto_scroll(0, &scroll, 0);
173 NSLOG(netsurf, INFO,
"xwimp_auto_scroll: 0x%x: %s",
174 error->errnum, error->errmess);
176 error = xwimp_drag_box((wimp_drag*)-1);
178 NSLOG(netsurf, INFO,
"xwimp_drag_box: 0x%x : %s",
179 error->errnum, error->errmess);
183 error = xwimp_get_pointer_info(&pointer);
185 NSLOG(netsurf, INFO,
"xwimp_get_pointer_info 0x%x : %s",
186 error->errnum, error->errmess);
212 new_cb = malloc(length);
216 memcpy(new_cb,
buffer, length);
225 wimp_full_message_claim_entity msg;
228 NSLOG(netsurf, INFO,
"claiming clipboard");
230 msg.size =
sizeof(msg);
232 msg.action = message_CLAIM_ENTITY;
233 msg.flags = wimp_CLAIM_CLIPBOARD;
235 error = xwimp_send_message(wimp_USER_MESSAGE,
236 (wimp_message*)&msg, wimp_BROADCAST);
238 NSLOG(netsurf, INFO,
"xwimp_send_message: 0x%x: %s",
239 error->errnum, error->errmess);
317 wimp_full_message_data_request msg;
324 msg.action = message_DATA_REQUEST;
329 msg.flags = wimp_DATA_REQUEST_CLIPBOARD;
330 msg.file_types[0] = osfile_TYPE_TEXT;
331 msg.file_types[1] = ~0;
334 (wimp_message *) &msg, wimp_BROADCAST,
336 if (success ==
false) {
355 wimp_full_message_data_xfer *dataxfer)
364 if (dataxfer->file_type != osfile_TYPE_TEXT) {
370 dataxfer->your_ref = dataxfer->my_ref;
371 dataxfer->size = offsetof(wimp_full_message_data_xfer, file_name) + 16;
372 dataxfer->action = message_DATA_SAVE_ACK;
373 dataxfer->est_size = -1;
374 memcpy(dataxfer->file_name,
"<Wimp$Scrap>",
SLEN(
"<Wimp$Scrap>") + 1);
377 (wimp_message *) dataxfer, dataxfer->sender,
379 if (success ==
false) {
396 wimp_full_message_data_xfer *dataxfer)
404 fp = fopen(dataxfer->file_name,
"r");
407 fseek(fp, 0, SEEK_END);
409 fseek(fp, 0, SEEK_SET);
412 char *local_cb = malloc(size);
413 if (local_cb != NULL) {
415 fread(local_cb, 1, size, fp);
431 dataxfer->action = message_DATA_LOAD_ACK;
432 dataxfer->your_ref = dataxfer->my_ref;
434 (wimp_message *) dataxfer, dataxfer->sender, NULL);
453 NSLOG(netsurf, INFO,
"%x", claim->flags);
455 if (claim->flags & wimp_CLAIM_CARET_OR_SELECTION) {
459 if (claim->flags & wimp_CLAIM_CLIPBOARD) {
477 (req->flags & wimp_DATA_REQUEST_CLIPBOARD)) {
478 wimp_full_message_data_xfer message;
491 size = offsetof(wimp_full_message_data_xfer, file_name) + 9;
492 message.size = (size + 3) & ~3;
493 message.your_ref = req->my_ref;
494 message.action = message_DATA_SAVE;
497 message.pos = req->pos;
498 message.file_type = osfile_TYPE_TEXT;
500 memcpy(message.file_name,
"TextFile", 9);
503 &message, req->sender);
529 error = xosfile_save_stamped(
path, osfile_TYPE_TEXT,
531 (
byte*) local_cb + strlen(local_cb));
536 NSLOG(netsurf, INFO,
"xosfile_save_stamped: 0x%x: %s",
537 error->errnum, error->errmess);
553 wimp_full_message_dragging *drag = (wimp_full_message_dragging*)message;
562 if ((drag->flags & wimp_DRAGGING_TERMINATE_DRAG) || !g) {
592 wimp_full_message_drag_claim *claim = (wimp_full_message_drag_claim*)message;
607 !(claim->flags & wimp_DRAG_CLAIM_POINTER_CHANGED)) {
617 wimp_full_message_dragging dragmsg;
619 NSLOG(netsurf, INFO,
"sending DRAGGING to %p, %d", pointer->w,
622 dragmsg.size = offsetof(wimp_full_message_dragging, file_types) + 8;
623 dragmsg.your_ref = 0;
624 dragmsg.action = message_DRAGGING;
625 dragmsg.w = pointer->w;
626 dragmsg.i = pointer->i;
627 dragmsg.pos = pointer->pos;
631 dragmsg.flags = wimp_DRAGGING_FROM_SELECTION;
633 dragmsg.file_types[0] = osfile_TYPE_TEXT;
634 dragmsg.file_types[1] = ~0;
646 (wimp_message*)&dragmsg, pointer->w, pointer->i,
void gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape)
Change mouse pointer shape.
Browser window creation and manipulation interface.
void browser_window_mouse_track(struct browser_window *bw, browser_mouse_state mouse, int x, int y)
Handle non-click mouse action in a browser window.
static osspriteop_area * buffer
The buffer characteristics.
nserror
Enumeration of error codes.
nserror utf8_to_local_encoding(const char *string, size_t len, char **result)
nserror utf8_from_local_encoding(const char *string, size_t len, char **result)
void ro_mouse_drag_start(void(*drag_end)(wimp_dragged *dragged, void *data), void(*drag_track)(wimp_pointer *pointer, void *data), void(*drag_cancel)(void *data), void *data)
Start a drag, providing a function to be called when the Wimp_DragEnd event is received and optionall...
Mouse dragging and tracking support interface for RISC OS.
static bool owns_caret_and_selection
bool ro_gui_save_clipboard(const char *path)
Save the clipboard contents to a file.
static void gui_set_clipboard(const char *buffer, size_t length, nsclipboard_styles styles[], int n_styles)
Core tells front end to put given text in clipboard.
#define wimp_DRAG_CLAIM_SUPPRESS_DRAGBOX
static wimp_drag_claim_flags last_claim_flags
static wimp_t dragging_claimant
static void gui_get_clipboard(char **buffer, size_t *length)
Core asks front end for clipboard contents.
static bool owns_clipboard
static void ro_gui_dragging_bounced(wimp_message *message)
Our message_DRAGGING message was bounced, ie.
static size_t clip_length
static void ro_gui_selection_drag_end(wimp_dragged *drag, void *g)
End of text selection drag operation.
void ro_gui_selection_data_request(wimp_full_message_data_request *req)
Responds to DATA_REQUEST message, returning information about the clipboard contents if we own the cl...
static void * paste_cb_pw
static ro_gui_selection_prepare_paste_cb paste_cb
static void ro_gui_selection_prepare_paste_complete(void)
void ro_gui_selection_claim_entity(wimp_full_message_claim_entity *claim)
Responds to CLAIM_ENTITY message notifying us that the caret and selection or clipboard have been cla...
static void ro_gui_selection_prepare_paste_bounced(wimp_message *message)
static struct gui_clipboard_table clipboard_table
static void ro_gui_discard_clipboard_contents(void)
Discard the current contents of the clipboard, if any, releasing the memory it uses.
struct gui_clipboard_table * riscos_clipboard_table
static struct gui_window * last_start_window
void gui_start_selection(struct gui_window *g)
Start drag-selecting text within a browser window (RO-dependent part)
bool ro_gui_selection_prepare_paste_datasave(wimp_full_message_data_xfer *dataxfer)
Prepare to paste data from another application (step 2)
static bool dragging_claimed
Receive of Dragging message has claimed it.
void ro_gui_selection_drag_reset(void)
Reset drag-and-drop state when drag completes (DataSave received)
void ro_gui_selection_prepare_paste(wimp_w w, ro_gui_selection_prepare_paste_cb cb, void *pw)
Prepare to paste data from another application.
static os_box dragging_box
void ro_gui_selection_dragging(wimp_message *message)
Handler for Message_Dragging, used to implement auto-scrolling and ghost caret when a drag is in prog...
void ro_gui_selection_send_dragging(wimp_pointer *pointer)
bool ro_gui_selection_prepare_paste_dataload(wimp_full_message_data_xfer *dataxfer)
Prepare to paste data from another application (step 3)
static int paste_prev_message
void ro_gui_selection_drag_claim(wimp_message *message)
Text selection import/export (interface).
void(* ro_gui_selection_prepare_paste_cb)(void *pw)
Browser window handling (interface).
Interface to platform-specific clipboard operations.
Interface to platform-specific graphical user interface window operations.
@ GUI_SAVE_CLIPBOARD_CONTENTS
#define NSLOG(catname, level, logmsg, args...)
bool ro_message_send_message(wimp_event_no event, wimp_message *message, wimp_t task, void(*callback)(wimp_message *message))
Sends a message and registers a return route for a bounce.
bool ro_message_send_message_to_window(wimp_event_no event, wimp_message *message, wimp_w to_w, wimp_i to_i, void(*callback)(wimp_message *message), wimp_t *to_t)
Sends a message and registers a return route for a bounce.
Automated RISC OS message routing (interface).
wimp_t task_handle
RISC OS wimp task handle.
nserror ro_warn_user(const char *warning, const char *detail)
Display a warning for a serious problem (eg memory exhaustion).
File/object/selection saving (Interface).
bool ro_gui_window_to_window_pos(struct gui_window *g, int x, int y, os_coord *pos)
Convert x,y screen co-ordinates into window co-ordinates.
void ro_gui_window_mouse_at(wimp_pointer *pointer, void *data)
Handle pointer movements in a browser window.
struct gui_window * ro_gui_window_lookup(wimp_w window)
Convert a RISC OS window handle to a gui_window.
void ro_gui_send_datasave(gui_save_type save_type, wimp_full_message_data_xfer *message, wimp_t to)
Send DataSave message on behalf of clipboard code and remember that it's the clipboard contents we're...
void ro_gui_drag_box_cancel(void)
Interface to utility string handling.
function table for clipboard operations.
void(* get)(char **buffer, size_t *length)
Core asks front end for clipboard contents.
first entry in window list
struct fbtk_widget_s * window
struct browser_window * bw
The 'content' window that is rendered in the gui_window.
UCS conversion tables (interface) This is only used if nothing claims Service_International,...
UTF-8 manipulation functions (interface).
Interface to a number of general purpose functionality.
#define SLEN(x)
Calculate length of constant C string.
static nserror path(const struct redraw_context *ctx, const plot_style_t *pstyle, const float *p, unsigned int n, const float transform[6])
Plots a path.