Open select menu via content msg, instead of breaking encapsulation.

Fixes bw deref and browser_private.h #include in render/
This commit is contained in:
Michael Drake 2014-10-24 17:57:15 +01:00
parent 197f6e34f8
commit b27f3e5ac4
4 changed files with 19 additions and 11 deletions

View File

@ -84,6 +84,7 @@ typedef enum {
CONTENT_MSG_SELECTION, /**< A selection made or cleared */
CONTENT_MSG_CARET, /**< Caret movement / hiding */
CONTENT_MSG_DRAG, /**< A drag started or ended */
CONTENT_MSG_SELECTMENU,/**< Create a select menu */
CONTENT_MSG_GADGETCLICK/**< A gadget has been clicked on (mainly for file) */
} content_msg;
@ -197,6 +198,10 @@ union content_msg_data {
} type;
const struct rect *rect;
} drag;
/** CONTENT_MSG_SELECTMENU - Create select menu at pointer */
struct {
struct form_control *gadget;
} select_menu;
/** CONTENT_MSG_GADGETCLICK - User clicked on a form gadget */
struct {
struct form_control *gadget;

View File

@ -1600,6 +1600,16 @@ static nserror browser_window_callback(hlcache_handle *c,
event->data.selection.read_only);
break;
case CONTENT_MSG_SELECTMENU:
if (event->data.select_menu.gadget->type == GADGET_SELECT) {
struct browser_window *root =
browser_window_get_root(bw);
guit->browser->create_form_select_menu(root->window,
event->data.select_menu.gadget);
}
break;
case CONTENT_MSG_GADGETCLICK:
if (event->data.gadget_click.gadget->type == GADGET_FILE) {
guit->window->file_gadget_open(bw->window, c,

View File

@ -55,13 +55,6 @@
#include "render/imagemap.h"
#include "render/search.h"
/* TODO:
* This is currently needed here because the forms stuff (select menu
* specifically) is badly designed. But I'd rather it were here in the
* core than in all the front ends. We should fix this so we communicate
* with the browser window layer via the content message system. -- tlsa */
#include <desktop/browser_private.h>
/**
* Get pointer shape for given box
*
@ -665,10 +658,9 @@ void html_mouse_action(struct content *c, struct browser_window *bw,
c);
pointer = BROWSER_POINTER_DEFAULT;
} else if (mouse & BROWSER_MOUSE_CLICK_1) {
struct browser_window *rbw =
browser_window_get_root(bw);
guit->browser->create_form_select_menu(
rbw->window, gadget);
msg_data.select_menu.gadget = gadget;
content_broadcast(c, CONTENT_MSG_SELECTMENU,
msg_data);
}
break;
case GADGET_CHECKBOX:

View File

@ -375,6 +375,7 @@ html_object_callback(hlcache_handle *object,
case CONTENT_MSG_SAVELINK:
case CONTENT_MSG_POINTER:
case CONTENT_MSG_SELECTMENU:
case CONTENT_MSG_GADGETCLICK:
/* These messages are for browser window layer.
* we're not interested, so pass them on. */