2011-03-12 18:08:07 +03:00
|
|
|
/*
|
|
|
|
* Copyright 2011 Daniel Silverstone <dsilvers@digital-scurf.org>
|
|
|
|
*
|
|
|
|
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
|
|
|
*
|
|
|
|
* NetSurf is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; version 2 of the License.
|
|
|
|
*
|
|
|
|
* NetSurf is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Browser-related callbacks */
|
|
|
|
|
|
|
|
#include <stdio.h>
|
2016-04-22 00:36:21 +03:00
|
|
|
#include <stdlib.h>
|
2011-03-12 18:08:07 +03:00
|
|
|
|
2016-04-20 01:20:29 +03:00
|
|
|
#include "utils/utils.h"
|
2011-03-12 18:08:07 +03:00
|
|
|
#include "utils/ring.h"
|
2011-03-12 20:27:18 +03:00
|
|
|
#include "utils/log.h"
|
2013-02-18 16:24:49 +04:00
|
|
|
#include "utils/messages.h"
|
2014-10-17 12:27:58 +04:00
|
|
|
#include "desktop/mouse.h"
|
2016-05-30 13:01:40 +03:00
|
|
|
#include "netsurf/window.h"
|
2014-10-17 12:27:58 +04:00
|
|
|
#include "desktop/browser.h"
|
2016-05-04 17:08:36 +03:00
|
|
|
#include "desktop/plotters.h"
|
2014-10-17 12:27:58 +04:00
|
|
|
#include "content/hlcache.h"
|
2011-03-12 18:08:07 +03:00
|
|
|
|
|
|
|
#include "monkey/browser.h"
|
2011-06-30 19:48:07 +04:00
|
|
|
#include "monkey/plot.h"
|
2011-03-12 18:08:07 +03:00
|
|
|
|
|
|
|
static uint32_t win_ctr = 0;
|
|
|
|
|
|
|
|
static struct gui_window *gw_ring = NULL;
|
|
|
|
|
2016-04-29 12:53:31 +03:00
|
|
|
/* exported function documented in monkey/browser.h */
|
|
|
|
nserror monkey_warn_user(const char *warning, const char *detail)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "WARN %s %s\n", warning, detail);
|
|
|
|
return NSERROR_OK;
|
|
|
|
}
|
|
|
|
|
2011-03-12 18:08:07 +03:00
|
|
|
struct gui_window *
|
|
|
|
monkey_find_window_by_num(uint32_t win_num)
|
|
|
|
{
|
|
|
|
struct gui_window *ret = NULL;
|
|
|
|
|
|
|
|
RING_ITERATE_START(struct gui_window, gw_ring, c_ring) {
|
|
|
|
if (c_ring->win_num == win_num) {
|
|
|
|
ret = c_ring;
|
|
|
|
RING_ITERATE_STOP(gw_ring, c_ring);
|
|
|
|
}
|
|
|
|
} RING_ITERATE_END(gw_ring, c_ring);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2014-06-30 19:40:56 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* callback from core to reformat a window.
|
|
|
|
*/
|
|
|
|
static void monkey_window_reformat(struct gui_window *gw)
|
2011-03-12 18:08:07 +03:00
|
|
|
{
|
2014-06-30 19:40:56 +04:00
|
|
|
browser_window_reformat(gw->bw, false, gw->width, gw->height);
|
2011-03-12 18:08:07 +03:00
|
|
|
}
|
|
|
|
|
2011-03-12 20:54:02 +03:00
|
|
|
void
|
|
|
|
monkey_kill_browser_windows(void)
|
|
|
|
{
|
|
|
|
while (gw_ring != NULL) {
|
|
|
|
browser_window_destroy(gw_ring->bw);
|
|
|
|
}
|
|
|
|
}
|
2011-03-12 18:08:07 +03:00
|
|
|
|
2014-01-12 21:07:34 +04:00
|
|
|
static struct gui_window *
|
2014-01-12 02:34:12 +04:00
|
|
|
gui_window_create(struct browser_window *bw,
|
2014-02-09 17:07:39 +04:00
|
|
|
struct gui_window *existing,
|
|
|
|
gui_window_create_flags flags)
|
2011-03-12 18:08:07 +03:00
|
|
|
{
|
|
|
|
struct gui_window *ret = calloc(sizeof(*ret), 1);
|
|
|
|
if (ret == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
ret->win_num = win_ctr++;
|
|
|
|
ret->bw = bw;
|
|
|
|
|
|
|
|
ret->width = 800;
|
|
|
|
ret->height = 600;
|
|
|
|
|
2014-02-09 17:07:39 +04:00
|
|
|
fprintf(stdout, "WINDOW NEW WIN %u FOR %p EXISTING %p NEWTAB %s CLONE %s\n",
|
|
|
|
ret->win_num, bw, existing, flags & GW_CREATE_TAB ? "TRUE" : "FALSE",
|
|
|
|
flags & GW_CREATE_CLONE ? "TRUE" : "FALSE");
|
2011-03-12 20:27:18 +03:00
|
|
|
fprintf(stdout, "WINDOW SIZE WIN %u WIDTH %d HEIGHT %d\n",
|
2011-03-12 18:08:07 +03:00
|
|
|
ret->win_num, ret->width, ret->height);
|
|
|
|
|
|
|
|
RING_INSERT(gw_ring, ret);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2014-01-12 21:07:34 +04:00
|
|
|
static void
|
2011-03-12 18:08:07 +03:00
|
|
|
gui_window_destroy(struct gui_window *g)
|
|
|
|
{
|
2011-03-12 20:27:18 +03:00
|
|
|
fprintf(stdout, "WINDOW DESTROY WIN %u\n", g->win_num);
|
2011-03-12 18:08:07 +03:00
|
|
|
RING_REMOVE(gw_ring, g);
|
|
|
|
free(g);
|
|
|
|
}
|
|
|
|
|
2014-01-12 21:07:34 +04:00
|
|
|
static void
|
2011-03-12 18:08:07 +03:00
|
|
|
gui_window_set_title(struct gui_window *g, const char *title)
|
|
|
|
{
|
2011-03-12 20:27:18 +03:00
|
|
|
fprintf(stdout, "WINDOW TITLE WIN %u STR %s\n", g->win_num, title);
|
2011-03-12 18:08:07 +03:00
|
|
|
}
|
|
|
|
|
2014-01-13 03:50:54 +04:00
|
|
|
static void
|
2011-03-12 18:08:07 +03:00
|
|
|
gui_window_redraw_window(struct gui_window *g)
|
|
|
|
{
|
2011-03-12 20:27:18 +03:00
|
|
|
fprintf(stdout, "WINDOW REDRAW WIN %u\n", g->win_num);
|
2011-03-12 18:08:07 +03:00
|
|
|
}
|
|
|
|
|
2014-01-13 15:38:35 +04:00
|
|
|
static void
|
2011-03-12 18:08:07 +03:00
|
|
|
gui_window_get_dimensions(struct gui_window *g, int *width, int *height,
|
|
|
|
bool scaled)
|
|
|
|
{
|
2011-03-12 20:27:18 +03:00
|
|
|
fprintf(stdout, "WINDOW GET_DIMENSIONS WIN %u WIDTH %d HEIGHT %d\n",
|
2011-03-12 18:08:07 +03:00
|
|
|
g->win_num, g->width, g->height);
|
|
|
|
*width = g->width;
|
|
|
|
*height = g->height;
|
|
|
|
}
|
|
|
|
|
2014-01-13 02:55:26 +04:00
|
|
|
static void
|
2011-03-12 18:08:07 +03:00
|
|
|
gui_window_new_content(struct gui_window *g)
|
|
|
|
{
|
2011-03-12 20:27:18 +03:00
|
|
|
fprintf(stdout, "WINDOW NEW_CONTENT WIN %u\n", g->win_num);
|
2011-03-12 18:08:07 +03:00
|
|
|
}
|
|
|
|
|
2014-01-12 21:07:34 +04:00
|
|
|
static void
|
2011-03-12 18:08:07 +03:00
|
|
|
gui_window_set_icon(struct gui_window *g, hlcache_handle *icon)
|
|
|
|
{
|
2011-03-12 20:27:18 +03:00
|
|
|
fprintf(stdout, "WINDOW NEW_ICON WIN %u\n", g->win_num);
|
2011-03-12 18:08:07 +03:00
|
|
|
}
|
|
|
|
|
2014-01-12 21:07:34 +04:00
|
|
|
static void
|
2011-03-12 18:08:07 +03:00
|
|
|
gui_window_start_throbber(struct gui_window *g)
|
|
|
|
{
|
2011-03-12 20:27:18 +03:00
|
|
|
fprintf(stdout, "WINDOW START_THROBBER WIN %u\n", g->win_num);
|
2011-03-12 18:08:07 +03:00
|
|
|
}
|
|
|
|
|
2014-01-12 21:07:34 +04:00
|
|
|
static void
|
2011-03-12 18:08:07 +03:00
|
|
|
gui_window_stop_throbber(struct gui_window *g)
|
|
|
|
{
|
2011-03-12 20:27:18 +03:00
|
|
|
fprintf(stdout, "WINDOW STOP_THROBBER WIN %u\n", g->win_num);
|
2011-03-12 18:08:07 +03:00
|
|
|
}
|
|
|
|
|
2014-01-13 05:08:15 +04:00
|
|
|
static void
|
2011-03-12 18:08:07 +03:00
|
|
|
gui_window_set_scroll(struct gui_window *g, int sx, int sy)
|
|
|
|
{
|
|
|
|
g->scrollx = sx;
|
|
|
|
g->scrolly = sy;
|
2011-03-12 20:27:18 +03:00
|
|
|
fprintf(stdout, "WINDOW SET_SCROLL WIN %u X %d Y %d\n", g->win_num, sx, sy);
|
2011-03-12 18:08:07 +03:00
|
|
|
}
|
|
|
|
|
2014-01-13 03:50:54 +04:00
|
|
|
static void
|
2011-07-06 16:56:31 +04:00
|
|
|
gui_window_update_box(struct gui_window *g, const struct rect *rect)
|
2011-03-12 18:08:07 +03:00
|
|
|
{
|
2011-03-12 20:27:18 +03:00
|
|
|
fprintf(stdout, "WINDOW UPDATE_BOX WIN %u X %d Y %d WIDTH %d HEIGHT %d\n",
|
2011-07-06 16:56:31 +04:00
|
|
|
g->win_num, rect->x0, rect->y0,
|
|
|
|
(rect->x1 - rect->x0), (rect->y1 - rect->y0));
|
2011-03-12 18:08:07 +03:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-01-13 15:38:35 +04:00
|
|
|
static void
|
2011-03-12 18:08:07 +03:00
|
|
|
gui_window_update_extent(struct gui_window *g)
|
|
|
|
{
|
2014-10-16 00:35:14 +04:00
|
|
|
int width, height;
|
|
|
|
|
|
|
|
if (browser_window_get_extents(g->bw, false, &width, &height) != NSERROR_OK)
|
2011-03-12 18:08:07 +03:00
|
|
|
return;
|
|
|
|
|
2011-03-12 20:27:18 +03:00
|
|
|
fprintf(stdout, "WINDOW UPDATE_EXTENT WIN %u WIDTH %d HEIGHT %d\n",
|
2014-10-16 00:35:14 +04:00
|
|
|
g->win_num, width, height);
|
2011-03-12 18:08:07 +03:00
|
|
|
}
|
|
|
|
|
2014-01-13 18:51:27 +04:00
|
|
|
static void
|
2011-03-12 18:08:07 +03:00
|
|
|
gui_window_set_status(struct gui_window *g, const char *text)
|
|
|
|
{
|
2011-03-12 20:27:18 +03:00
|
|
|
fprintf(stdout, "WINDOW SET_STATUS WIN %u STR %s\n", g->win_num, text);
|
2011-03-12 18:08:07 +03:00
|
|
|
}
|
|
|
|
|
2014-01-13 18:51:27 +04:00
|
|
|
static void
|
2011-03-12 18:08:07 +03:00
|
|
|
gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape)
|
|
|
|
{
|
|
|
|
const char *ptr_name = "UNKNOWN";
|
|
|
|
|
|
|
|
switch (shape) {
|
|
|
|
case GUI_POINTER_POINT:
|
|
|
|
ptr_name = "POINT";
|
|
|
|
break;
|
|
|
|
case GUI_POINTER_CARET:
|
|
|
|
ptr_name = "CARET";
|
|
|
|
break;
|
|
|
|
case GUI_POINTER_UP:
|
|
|
|
ptr_name = "UP";
|
|
|
|
break;
|
|
|
|
case GUI_POINTER_DOWN:
|
|
|
|
ptr_name = "DOWN";
|
|
|
|
break;
|
|
|
|
case GUI_POINTER_LEFT:
|
|
|
|
ptr_name = "LEFT";
|
|
|
|
break;
|
|
|
|
case GUI_POINTER_RIGHT:
|
|
|
|
ptr_name = "RIGHT";
|
|
|
|
break;
|
|
|
|
case GUI_POINTER_LD:
|
|
|
|
ptr_name = "LD";
|
|
|
|
break;
|
|
|
|
case GUI_POINTER_RD:
|
|
|
|
ptr_name = "RD";
|
|
|
|
break;
|
|
|
|
case GUI_POINTER_LU:
|
|
|
|
ptr_name = "LU";
|
|
|
|
break;
|
|
|
|
case GUI_POINTER_RU:
|
|
|
|
ptr_name = "RU";
|
|
|
|
break;
|
|
|
|
case GUI_POINTER_CROSS:
|
|
|
|
ptr_name = "CROSS";
|
|
|
|
break;
|
|
|
|
case GUI_POINTER_MOVE:
|
|
|
|
ptr_name = "MOVE";
|
|
|
|
break;
|
|
|
|
case GUI_POINTER_WAIT:
|
|
|
|
ptr_name = "WAIT";
|
|
|
|
break;
|
|
|
|
case GUI_POINTER_HELP:
|
|
|
|
ptr_name = "HELP";
|
|
|
|
break;
|
|
|
|
case GUI_POINTER_MENU:
|
|
|
|
ptr_name = "MENU";
|
|
|
|
break;
|
|
|
|
case GUI_POINTER_PROGRESS:
|
|
|
|
ptr_name = "PROGRESS";
|
|
|
|
break;
|
|
|
|
case GUI_POINTER_NO_DROP:
|
|
|
|
ptr_name = "NO_DROP";
|
|
|
|
break;
|
|
|
|
case GUI_POINTER_NOT_ALLOWED:
|
|
|
|
ptr_name = "NOT_ALLOWED";
|
|
|
|
break;
|
|
|
|
case GUI_POINTER_DEFAULT:
|
|
|
|
ptr_name = "DEFAULT";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2011-03-12 20:27:18 +03:00
|
|
|
fprintf(stdout, "WINDOW SET_POINTER WIN %u POINTER %s\n", g->win_num, ptr_name);
|
2011-03-12 18:08:07 +03:00
|
|
|
}
|
|
|
|
|
2014-10-29 03:17:11 +03:00
|
|
|
static nserror
|
2014-11-03 01:30:45 +03:00
|
|
|
gui_window_set_url(struct gui_window *g, nsurl *url)
|
2011-03-12 18:08:07 +03:00
|
|
|
{
|
2014-11-03 01:30:45 +03:00
|
|
|
fprintf(stdout, "WINDOW SET_URL WIN %u URL %s\n", g->win_num, nsurl_access(url));
|
2014-10-29 03:17:11 +03:00
|
|
|
return NSERROR_OK;
|
2011-03-12 18:08:07 +03:00
|
|
|
}
|
|
|
|
|
2014-01-13 05:08:15 +04:00
|
|
|
static bool
|
2011-03-12 18:08:07 +03:00
|
|
|
gui_window_get_scroll(struct gui_window *g, int *sx, int *sy)
|
|
|
|
{
|
2011-03-12 20:27:18 +03:00
|
|
|
fprintf(stdout, "WINDOW GET_SCROLL WIN %u X %d Y %d\n",
|
2011-03-12 18:08:07 +03:00
|
|
|
g->win_num, g->scrollx, g->scrolly);
|
|
|
|
*sx = g->scrollx;
|
|
|
|
*sy = g->scrolly;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-01-13 02:55:26 +04:00
|
|
|
static bool
|
2011-03-12 18:08:07 +03:00
|
|
|
gui_window_scroll_start(struct gui_window *g)
|
|
|
|
{
|
2011-03-12 20:27:18 +03:00
|
|
|
fprintf(stdout, "WINDOW SCROLL_START WIN %u\n", g->win_num);
|
2011-03-12 18:08:07 +03:00
|
|
|
g->scrollx = g->scrolly = 0;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-01-13 02:55:26 +04:00
|
|
|
static void
|
2011-03-12 18:08:07 +03:00
|
|
|
gui_window_scroll_visible(struct gui_window *g, int x0, int y0,
|
|
|
|
int x1, int y1)
|
|
|
|
{
|
2011-03-12 20:27:18 +03:00
|
|
|
fprintf(stdout, "WINDOW SCROLL_VISIBLE WIN %u X0 %d Y0 %d X1 %d Y1 %d\n",
|
2011-03-12 18:08:07 +03:00
|
|
|
g->win_num, x0, y0, x1, y1);
|
|
|
|
}
|
|
|
|
|
2014-01-13 18:51:27 +04:00
|
|
|
static void
|
2013-03-06 02:53:33 +04:00
|
|
|
gui_window_place_caret(struct gui_window *g, int x, int y, int height,
|
|
|
|
const struct rect *clip)
|
2011-03-12 18:08:07 +03:00
|
|
|
{
|
2011-03-12 20:27:18 +03:00
|
|
|
fprintf(stdout, "WINDOW PLACE_CARET WIN %u X %d Y %d HEIGHT %d\n",
|
2011-03-12 18:08:07 +03:00
|
|
|
g->win_num, x, y, height);
|
|
|
|
}
|
|
|
|
|
2014-01-13 18:51:27 +04:00
|
|
|
static void
|
2011-03-12 18:08:07 +03:00
|
|
|
gui_window_remove_caret(struct gui_window *g)
|
|
|
|
{
|
2011-03-12 20:27:18 +03:00
|
|
|
fprintf(stdout, "WINDOW REMOVE_CARET WIN %u\n", g->win_num);
|
2011-03-12 18:08:07 +03:00
|
|
|
}
|
|
|
|
|
2014-01-12 21:07:34 +04:00
|
|
|
static bool
|
2012-01-11 18:20:26 +04:00
|
|
|
gui_window_drag_start(struct gui_window *g, gui_drag_type type,
|
2012-01-11 20:45:17 +04:00
|
|
|
const struct rect *rect)
|
2011-03-12 18:08:07 +03:00
|
|
|
{
|
2012-02-05 12:16:41 +04:00
|
|
|
fprintf(stdout, "WINDOW SCROLL_START WIN %u TYPE %i\n", g->win_num, type);
|
2011-03-12 18:08:07 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-11-04 02:05:59 +03:00
|
|
|
static nserror
|
|
|
|
gui_window_save_link(struct gui_window *g, nsurl *url, const char *title)
|
2011-03-12 18:08:07 +03:00
|
|
|
{
|
2011-03-12 20:27:18 +03:00
|
|
|
fprintf(stdout, "WINDOW SAVE_LINK WIN %u URL %s TITLE %s\n",
|
2014-11-04 02:05:59 +03:00
|
|
|
g->win_num, nsurl_access(url), title);
|
|
|
|
return NSERROR_OK;
|
2011-03-12 18:08:07 +03:00
|
|
|
}
|
2011-03-12 20:27:18 +03:00
|
|
|
|
2014-01-05 20:01:03 +04:00
|
|
|
|
2011-03-12 20:27:18 +03:00
|
|
|
|
|
|
|
/**** Handlers ****/
|
|
|
|
|
|
|
|
static void
|
|
|
|
monkey_window_handle_new(int argc, char **argv)
|
|
|
|
{
|
2013-02-14 22:21:11 +04:00
|
|
|
nsurl *url = NULL;
|
|
|
|
nserror error = NSERROR_OK;
|
|
|
|
|
2011-03-12 20:27:18 +03:00
|
|
|
if (argc > 3)
|
|
|
|
return;
|
2013-02-14 22:21:11 +04:00
|
|
|
|
|
|
|
if (argc == 3) {
|
|
|
|
error = nsurl_create(argv[2], &url);
|
|
|
|
}
|
|
|
|
if (error == NSERROR_OK) {
|
2014-02-10 18:08:45 +04:00
|
|
|
error = browser_window_create(BW_CREATE_HISTORY,
|
2013-02-14 22:21:11 +04:00
|
|
|
url,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
if (url != NULL) {
|
|
|
|
nsurl_unref(url);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (error != NSERROR_OK) {
|
2016-04-29 13:02:49 +03:00
|
|
|
monkey_warn_user(messages_get_errorcode(error), 0);
|
2013-02-14 22:21:11 +04:00
|
|
|
}
|
2011-03-12 20:27:18 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
monkey_window_handle_destroy(int argc, char **argv)
|
|
|
|
{
|
|
|
|
struct gui_window *gw;
|
|
|
|
uint32_t nr = atoi((argc > 2) ? argv[2] : "-1");
|
|
|
|
|
|
|
|
gw = monkey_find_window_by_num(nr);
|
|
|
|
|
|
|
|
if (gw == NULL) {
|
|
|
|
fprintf(stdout, "ERROR WINDOW NUM BAD\n");
|
|
|
|
} else {
|
|
|
|
browser_window_destroy(gw->bw);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
monkey_window_handle_go(int argc, char **argv)
|
|
|
|
{
|
|
|
|
struct gui_window *gw;
|
2016-04-29 12:53:31 +03:00
|
|
|
nsurl *url;
|
|
|
|
nsurl *ref_url = NULL;
|
|
|
|
nserror error;
|
2011-03-12 20:27:18 +03:00
|
|
|
|
|
|
|
if (argc < 4 || argc > 5) {
|
|
|
|
fprintf(stdout, "ERROR WINDOW GO ARGS BAD\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
gw = monkey_find_window_by_num(atoi(argv[2]));
|
|
|
|
|
|
|
|
if (gw == NULL) {
|
|
|
|
fprintf(stdout, "ERROR WINDOW NUM BAD\n");
|
2016-04-29 12:53:31 +03:00
|
|
|
return;
|
|
|
|
}
|
2013-02-14 19:09:28 +04:00
|
|
|
|
2016-04-29 12:53:31 +03:00
|
|
|
error = nsurl_create(argv[3], &url);
|
|
|
|
if (error == NSERROR_OK) {
|
|
|
|
if (argc == 5) {
|
|
|
|
error = nsurl_create(argv[4], &ref_url);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (error == NSERROR_OK) {
|
|
|
|
error = browser_window_navigate(gw->bw,
|
|
|
|
url,
|
|
|
|
ref_url,
|
|
|
|
BW_NAVIGATE_HISTORY,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
2013-02-14 19:09:28 +04:00
|
|
|
if (ref_url != NULL) {
|
|
|
|
nsurl_unref(ref_url);
|
|
|
|
}
|
|
|
|
}
|
2016-04-29 12:53:31 +03:00
|
|
|
nsurl_unref(url);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (error != NSERROR_OK) {
|
|
|
|
monkey_warn_user(messages_get_errorcode(error), 0);
|
2011-03-12 20:27:18 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-12 20:54:02 +03:00
|
|
|
static void
|
|
|
|
monkey_window_handle_redraw(int argc, char **argv)
|
|
|
|
{
|
|
|
|
struct gui_window *gw;
|
|
|
|
struct rect clip;
|
2011-06-30 19:48:07 +04:00
|
|
|
struct redraw_context ctx = {
|
|
|
|
.interactive = true,
|
2011-12-24 02:39:25 +04:00
|
|
|
.background_images = true,
|
2016-05-04 17:08:36 +03:00
|
|
|
.plot = monkey_plotters
|
2011-06-30 19:48:07 +04:00
|
|
|
};
|
2011-03-12 20:54:02 +03:00
|
|
|
|
|
|
|
if (argc != 3 && argc != 7) {
|
2011-11-25 22:08:30 +04:00
|
|
|
fprintf(stdout, "ERROR WINDOW REDRAW ARGS BAD\n");
|
2011-03-12 20:54:02 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
gw = monkey_find_window_by_num(atoi(argv[2]));
|
|
|
|
|
|
|
|
if (gw == NULL) {
|
|
|
|
fprintf(stdout, "ERROR WINDOW NUM BAD\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
clip.x0 = 0;
|
|
|
|
clip.y0 = 0;
|
|
|
|
clip.x1 = gw->width;
|
|
|
|
clip.y1 = gw->height;
|
|
|
|
|
|
|
|
if (argc == 7) {
|
|
|
|
clip.x0 = atoi(argv[3]);
|
|
|
|
clip.y0 = atoi(argv[4]);
|
|
|
|
clip.x1 = atoi(argv[5]);
|
|
|
|
clip.y1 = atoi(argv[6]);
|
|
|
|
}
|
|
|
|
|
2015-05-28 18:08:46 +03:00
|
|
|
LOG("Issue redraw");
|
2011-11-25 22:08:30 +04:00
|
|
|
fprintf(stdout, "WINDOW REDRAW WIN %d START\n", atoi(argv[2]));
|
2011-06-30 19:48:07 +04:00
|
|
|
browser_window_redraw(gw->bw, gw->scrollx, gw->scrolly, &clip, &ctx);
|
2011-11-25 22:08:30 +04:00
|
|
|
fprintf(stdout, "WINDOW REDRAW WIN %d STOP\n", atoi(argv[2]));
|
2011-03-12 20:54:02 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
monkey_window_handle_reload(int argc, char **argv)
|
|
|
|
{
|
|
|
|
struct gui_window *gw;
|
|
|
|
if (argc != 3 && argc != 4) {
|
2011-11-25 22:08:30 +04:00
|
|
|
fprintf(stdout, "ERROR WINDOW RELOAD ARGS BAD\n");
|
2011-03-12 20:54:02 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
gw = monkey_find_window_by_num(atoi(argv[2]));
|
|
|
|
|
|
|
|
if (gw == NULL) {
|
|
|
|
fprintf(stdout, "ERROR WINDOW NUM BAD\n");
|
|
|
|
} else {
|
|
|
|
browser_window_reload(gw->bw, argc == 4);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-12 20:27:18 +03:00
|
|
|
void
|
|
|
|
monkey_window_handle_command(int argc, char **argv)
|
|
|
|
{
|
|
|
|
if (argc == 1)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (strcmp(argv[1], "NEW") == 0) {
|
|
|
|
monkey_window_handle_new(argc, argv);
|
|
|
|
} else if (strcmp(argv[1], "DESTROY") == 0) {
|
|
|
|
monkey_window_handle_destroy(argc, argv);
|
|
|
|
} else if (strcmp(argv[1], "GO") == 0) {
|
|
|
|
monkey_window_handle_go(argc, argv);
|
2011-03-12 20:54:02 +03:00
|
|
|
} else if (strcmp(argv[1], "REDRAW") == 0) {
|
|
|
|
monkey_window_handle_redraw(argc, argv);
|
|
|
|
} else if (strcmp(argv[1], "RELOAD") == 0) {
|
|
|
|
monkey_window_handle_reload(argc, argv);
|
2011-11-25 22:08:30 +04:00
|
|
|
} else {
|
|
|
|
fprintf(stdout, "ERROR WINDOW COMMAND UNKNOWN %s\n", argv[1]);
|
2011-03-12 20:27:18 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2014-01-12 21:07:34 +04:00
|
|
|
|
2014-01-15 23:37:05 +04:00
|
|
|
static struct gui_window_table window_table = {
|
2014-01-12 21:07:34 +04:00
|
|
|
.create = gui_window_create,
|
|
|
|
.destroy = gui_window_destroy,
|
2014-01-13 03:50:54 +04:00
|
|
|
.redraw = gui_window_redraw_window,
|
|
|
|
.update = gui_window_update_box,
|
2014-01-13 05:08:15 +04:00
|
|
|
.get_scroll = gui_window_get_scroll,
|
|
|
|
.set_scroll = gui_window_set_scroll,
|
2014-01-13 15:38:35 +04:00
|
|
|
.get_dimensions = gui_window_get_dimensions,
|
|
|
|
.update_extent = gui_window_update_extent,
|
2014-06-30 19:40:56 +04:00
|
|
|
.reformat = monkey_window_reformat,
|
2014-01-12 21:07:34 +04:00
|
|
|
|
|
|
|
.set_title = gui_window_set_title,
|
|
|
|
.set_url = gui_window_set_url,
|
|
|
|
.set_icon = gui_window_set_icon,
|
2014-01-13 18:51:27 +04:00
|
|
|
.set_status = gui_window_set_status,
|
|
|
|
.set_pointer = gui_window_set_pointer,
|
|
|
|
.place_caret = gui_window_place_caret,
|
|
|
|
.remove_caret = gui_window_remove_caret,
|
2014-01-12 21:07:34 +04:00
|
|
|
.drag_start = gui_window_drag_start,
|
|
|
|
.save_link = gui_window_save_link,
|
2014-01-13 02:55:26 +04:00
|
|
|
.scroll_visible = gui_window_scroll_visible,
|
|
|
|
.scroll_start = gui_window_scroll_start,
|
|
|
|
.new_content = gui_window_new_content,
|
2014-01-12 21:07:34 +04:00
|
|
|
.start_throbber = gui_window_start_throbber,
|
|
|
|
.stop_throbber = gui_window_stop_throbber,
|
|
|
|
};
|
|
|
|
|
2014-01-15 23:37:05 +04:00
|
|
|
struct gui_window_table *monkey_window_table = &window_table;
|