Ejemplo n.º 1
0
void ro_gui_drag_save_link(gui_save_type save_type, const char *url,
		const char *title, struct gui_window *g)
{
	wimp_pointer pointer;
	char icon_buf[20];
	os_error *error;

	/* Close the save window because otherwise we need two contexts
	*/
	xwimp_create_menu(wimp_CLOSE_MENU, 0, 0);
	ro_gui_dialog_close(dialog_saveas);

	gui_save_url = url;
	gui_save_title = title;
	gui_save_sourcew = g->window;
	saving_from_dialog = false;

	error = xwimp_get_pointer_info(&pointer);
	if (error) {
		LOG(("xwimp_get_pointer_info: 0x%x: %s",
				error->errnum, error->errmess));
		warn_user("WimpError", error->errmess);
		return;
	}

	ro_gui_save_set_state(NULL, save_type, url, save_leafname, icon_buf);

	gui_current_drag_type = GUI_DRAG_SAVE;

	ro_gui_drag_icon(pointer.pos.x, pointer.pos.y, icon_buf);
}
Ejemplo n.º 2
0
Archivo: mouse.c Proyecto: ysei/NetSurf
void ro_mouse_poll(void)
{
	wimp_pointer	pointer;
	os_error	*error;

	/* If no trackers are active, just exit. */

	if (ro_mouse_drag_track_callback == NULL &&
			ro_mouse_poll_track_callback == NULL)
		return;

	error = xwimp_get_pointer_info(&pointer);
	if (error) {
		LOG(("xwimp_get_pointer_info: 0x%x: %s",
			error->errnum, error->errmess));
		warn_user("WimpError", error->errmess);
		return;
	}

	/* Process the drag tracker, if one is active. */

	if (ro_mouse_drag_track_callback != NULL)
		ro_mouse_drag_track_callback(&pointer, ro_mouse_drag_data);

	/* Process the window tracker, if one is active. */

	if (ro_mouse_poll_track_callback != NULL)
		ro_mouse_poll_track_callback(&pointer, ro_mouse_poll_data);
}
Ejemplo n.º 3
0
/**
 * Handle OK click/keypress in the save dialog.
 *
 * \param  w  window handle of save dialog
 * \return true on success, false on failure
 */
bool ro_gui_save_ok(wimp_w w)
{
	const char *name = ro_gui_get_icon_string(w, ICON_SAVE_PATH);
	wimp_pointer pointer;
	char path[256];

	if (!strrchr(name, '.')) {
		warn_user("NoPathError", NULL);
		return false;
	}

	ro_gui_convert_save_path(path, sizeof path, name);
	gui_save_sourcew = w;
	saving_from_dialog = true;
	gui_save_send_dataload = false;
	gui_save_close_after = xwimp_get_pointer_info(&pointer)
						|| !(pointer.buttons & wimp_CLICK_ADJUST);
	memcpy(&gui_save_message.data.data_xfer.file_name, path, 1 + strlen(path));

	if (ro_gui_save_content(gui_save_content, path, !option_confirm_overwrite)) {
		ro_gui_save_done();
		return true;
	}
	return false;
}
Ejemplo n.º 4
0
void gui_drag_save_object(gui_save_type save_type, hlcache_handle *c,
		struct gui_window *g)
{
	wimp_pointer pointer;
	char icon_buf[20];
	os_error *error;

	/* Close the save window because otherwise we need two contexts
	*/
	xwimp_create_menu(wimp_CLOSE_MENU, 0, 0);
	ro_gui_dialog_close(dialog_saveas);

	gui_save_sourcew = g->window;
	saving_from_dialog = false;

	error = xwimp_get_pointer_info(&pointer);
	if (error) {
		LOG(("xwimp_get_pointer_info: 0x%x: %s",
				error->errnum, error->errmess));
		warn_user("WimpError", error->errmess);
		return;
	}

	ro_gui_save_set_state(c, save_type, nsurl_access(hlcache_handle_get_url(c)),
			save_leafname, LEAFNAME_MAX,
			icon_buf, sizeof(icon_buf));

	gui_current_drag_type = GUI_DRAG_SAVE;

	ro_gui_drag_icon(pointer.pos.x, pointer.pos.y, icon_buf);
}
Ejemplo n.º 5
0
query_id query_user(const char *query, const char *detail,
		const query_callback *cb, void *pw,
		const char *yes, const char *no)
{
	wimp_pointer pointer;
	if (xwimp_get_pointer_info(&pointer))
		pointer.pos.y = pointer.pos.x = -1;

	return query_user_xy(query, detail, cb, pw, yes, no,
				pointer.pos.x, pointer.pos.y);
}
Ejemplo n.º 6
0
void ro_gui_menu_selection(wimp_selection *selection)
{
	int			i; //, j;
	wimp_menu_entry		*menu_entry;
	menu_action		action;
	wimp_pointer		pointer;
	os_error		*error;
	int			previous_menu_icon = current_menu_icon;

	/* if we are using gui_multitask then menu selection events
	 * may be delivered after the menu has been closed. As such,
	 * we simply ignore these events. */
	if (!current_menu)
		return;

	assert(current_menu_window);

	/* get the menu entry and associated action and definition */
	menu_entry = &current_menu->entries[selection->items[0]];
	for (i = 1; selection->items[i] != -1; i++)
		menu_entry = &menu_entry->sub_menu->
				entries[selection->items[i]];
	action = ro_gui_menu_find_action(current_menu, menu_entry);

	/* Deal with the menu action.  If this manages to re-prepare the
	 * menu for re-opening, we test for and act on Adjust clicks.
	 */

	if (!ro_gui_wimp_event_menu_selection(current_menu_window,
			current_menu_icon, current_menu, selection, action))
		return;

	/* re-open the menu for Adjust clicks */
	error = xwimp_get_pointer_info(&pointer);
	if (error) {
		LOG(("xwimp_get_pointer_info: 0x%x: %s",
				error->errnum, error->errmess));
		warn_user("WimpError", error->errmess);
		ro_gui_menu_closed();
		return;
	}

	if (pointer.buttons != wimp_CLICK_ADJUST) {
		ro_gui_menu_closed();
		return;
	}

	ro_gui_menu_create(current_menu, 0, 0, current_menu_window);
	current_menu_icon = previous_menu_icon;
}
Ejemplo n.º 7
0
void ro_gui_download_drag_end(wimp_dragged *drag)
{
	wimp_pointer pointer;
	wimp_message message;
	struct gui_download_window *dw = download_window_current;
	const char *leaf;
	os_error *error;

	if (dw->saved || dw->error)
		return;

	error = xwimp_get_pointer_info(&pointer);
	if (error) {
		LOG(("xwimp_get_pointer_info: 0x%x: %s",
				error->errnum, error->errmess));
		warn_user("WimpError", error->errmess);
		return;
	}

	/* ignore drags to the download window itself */
	if (pointer.w == dw->window) return;

	leaf = strrchr(dw->path, '.');
	if (leaf)
		leaf++;
	else
		leaf = dw->path;
	ro_gui_convert_save_path(message.data.data_xfer.file_name, 212, leaf);

	message.your_ref = 0;
	message.action = message_DATA_SAVE;
	message.data.data_xfer.w = pointer.w;
	message.data.data_xfer.i = pointer.i;
	message.data.data_xfer.pos.x = pointer.pos.x;
	message.data.data_xfer.pos.y = pointer.pos.y;
	message.data.data_xfer.est_size = dw->total_size ? dw->total_size :
			dw->received;
	message.data.data_xfer.file_type = dw->file_type;
	message.size = 44 + ((strlen(message.data.data_xfer.file_name) + 4) &
			(~3u));

	error = xwimp_send_message_to_window(wimp_USER_MESSAGE, &message,
			pointer.w, pointer.i, 0);
	if (error) {
		LOG(("xwimp_send_message_to_window: 0x%x: %s",
				error->errnum, error->errmess));
		warn_user("WimpError", error->errmess);
	}
}
Ejemplo n.º 8
0
void ro_gui_save_drag_end(wimp_dragged *drag)
{
	const char *name;
	wimp_pointer pointer;
	wimp_message message;
	os_error *error;
	char *dp, *ep;
	char *local_name = NULL;
	utf8_convert_ret err;

	if (dragbox_active)
		ro_gui_drag_box_cancel();

	error = xwimp_get_pointer_info(&pointer);
	if (error) {
		LOG(("xwimp_get_pointer_info: 0x%x: %s",
				error->errnum, error->errmess));
		warn_user("WimpError", error->errmess);
		return;
	}

	/* perform hit-test if the destination is the same as the source window;
		we want to allow drag-saving from a page into the input fields within
		the page, but avoid accidental replacements of the current page */
	if (gui_save_sourcew != (wimp_w)-1 && pointer.w == gui_save_sourcew) {
		int dx = (drag->final.x1 + drag->final.x0)/2;
		int dy = (drag->final.y1 + drag->final.y0)/2;
		struct gui_window *g;
		bool dest_ok = false;
		os_coord pos;

		g = ro_gui_window_lookup(gui_save_sourcew);

		if (g && ro_gui_window_to_window_pos(g, dx, dy, &pos)) {
			dest_ok = browser_window_drop_file_at_point(g->bw,
					pos.x, pos.y, NULL);
		}
		if (!dest_ok) {
			/* cancel the drag operation */
			gui_current_drag_type = GUI_DRAG_NONE;
			return;
		}
	}
Ejemplo n.º 9
0
void gui_drag_save_selection(struct selection *s, struct gui_window *g)
{
	wimp_pointer pointer;
	char icon_buf[20];
	os_error *error;

	/* Close the save window because otherwise we need two contexts
	*/
	xwimp_create_menu(wimp_CLOSE_MENU, 0, 0);
	ro_gui_dialog_close(dialog_saveas);

	gui_save_sourcew = g->window;
	saving_from_dialog = false;

	error = xwimp_get_pointer_info(&pointer);
	if (error) {
		LOG(("xwimp_get_pointer_info: 0x%x: %s",
				error->errnum, error->errmess));
		warn_user("WimpError", error->errmess);
		return;
	}


	if (gui_save_selection == NULL)
		free(gui_save_selection);

	gui_save_selection = selection_get_copy(s);

	ro_gui_save_set_state(NULL, GUI_SAVE_TEXT_SELECTION, NULL,
			save_leafname, LEAFNAME_MAX,
			icon_buf, sizeof(icon_buf));

	gui_current_drag_type = GUI_DRAG_SAVE;

	ro_gui_drag_icon(pointer.pos.x, pointer.pos.y, icon_buf);
}
Ejemplo n.º 10
0
void ro_gui_save_drag_end(wimp_dragged *drag)
{
	const char *name;
	wimp_pointer pointer;
	wimp_message message;
	os_error *error;
	char *dp, *ep;
	char *local_name = NULL;
	utf8_convert_ret err;

	if (dragbox_active)
		ro_gui_drag_box_cancel();

	error = xwimp_get_pointer_info(&pointer);
	if (error) {
		LOG(("xwimp_get_pointer_info: 0x%x: %s",
				error->errnum, error->errmess));
		warn_user("WimpError", error->errmess);
		return;
	}

	/* perform hit-test if the destination is the same as the source window;
		we want to allow drag-saving from a page into the input fields within
		the page, but avoid accidental replacements of the current page */
	if (gui_save_sourcew != (wimp_w)-1 && pointer.w == gui_save_sourcew) {
		int dx = (drag->final.x1 + drag->final.x0)/2;
		int dy = (drag->final.y1 + drag->final.y0)/2;
		struct gui_window *g;
		bool dest_ok = false;
		os_coord pos;

		g = ro_gui_window_lookup(gui_save_sourcew);

		if (g && ro_gui_window_to_window_pos(g, dx, dy, &pos)) {
			hlcache_handle *h = g->bw->current_content;

			if (h && content_get_type(h) == CONTENT_HTML) {
				struct box *box = html_get_box_tree(h);
				int box_x, box_y;

				/* Consider the margins of the html page now */
				box_x = box->margin[LEFT];
				box_y = box->margin[TOP];

				while (!dest_ok && (box = box_at_point(box,
						pos.x, pos.y, &box_x, &box_y,
						&h))) {
					if (box->style && 
							css_computed_visibility(
								box->style) == 
							CSS_VISIBILITY_HIDDEN)
						continue;

					if (box->gadget) {
						switch (box->gadget->type) {
							case GADGET_FILE:
							case GADGET_TEXTBOX:
							case GADGET_TEXTAREA:
							case GADGET_PASSWORD:
								dest_ok = true;
								break;

							default:	/* appease compiler */
								break;
						}
					}
				}
			}
		}
		if (!dest_ok) {
			/* cancel the drag operation */
			gui_current_drag_type = GUI_DRAG_NONE;
			return;
		}
	}