summaryrefslogtreecommitdiff
path: root/frontends/beos/window.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'frontends/beos/window.cpp')
-rw-r--r--frontends/beos/window.cpp216
1 files changed, 114 insertions, 102 deletions
diff --git a/frontends/beos/window.cpp b/frontends/beos/window.cpp
index f4229207b..b97be0f07 100644
--- a/frontends/beos/window.cpp
+++ b/frontends/beos/window.cpp
@@ -92,8 +92,6 @@ struct gui_window {
/* Keep gui_windows in a list for cleanup later */
struct gui_window *next, *prev;
-
- float scale;
};
@@ -336,11 +334,6 @@ struct browser_window *nsbeos_get_browser_for_gui(struct gui_window *g)
return g->bw;
}
-float nsbeos_get_scale_for_gui(struct gui_window *g)
-{
- return g->scale;
-}
-
/* Create a gui_window */
static struct gui_window *gui_window_create(struct browser_window *bw,
struct gui_window *existing,
@@ -360,7 +353,6 @@ static struct gui_window *gui_window_create(struct browser_window *bw,
g->bw = bw;
g->mouse.state = 0;
g->current_pointer = GUI_POINTER_DEFAULT;
- g->scale = browser_window_get_scale(bw);
g->careth = 0;
g->pending_resizes = 0;
@@ -518,9 +510,10 @@ void nsbeos_dispatch_event(BMessage *message)
if (gui->mouse.state & BROWSER_MOUSE_MOD_2 && !ctrl)
gui->mouse.state ^= BROWSER_MOUSE_MOD_2;
- browser_window_mouse_track(gui->bw, (browser_mouse_state)gui->mouse.state,
- (int)(where.x / gui->scale),
- (int)(where.y / gui->scale));
+ browser_window_mouse_track(gui->bw,
+ (browser_mouse_state)gui->mouse.state,
+ (int)(where.x),
+ (int)(where.y));
gui->last_x = (int)where.x;
gui->last_y = (int)where.y;
@@ -562,8 +555,8 @@ void nsbeos_dispatch_event(BMessage *message)
if (mods & B_CONTROL_KEY)
gui->mouse.state |= BROWSER_MOUSE_MOD_2;
- gui->mouse.pressed_x = where.x / gui->scale;
- gui->mouse.pressed_y = where.y / gui->scale;
+ gui->mouse.pressed_x = where.x;
+ gui->mouse.pressed_y = where.y;
// make sure the view is in focus
if (view && view->LockLooper()) {
@@ -624,8 +617,8 @@ void nsbeos_dispatch_event(BMessage *message)
if (gui->mouse.state & (BROWSER_MOUSE_CLICK_1|BROWSER_MOUSE_CLICK_2))
browser_window_mouse_click(gui->bw,
(browser_mouse_state)gui->mouse.state,
- where.x / gui->scale,
- where.y / gui->scale);
+ where.x,
+ where.y);
else
browser_window_mouse_track(gui->bw, (browser_mouse_state)0,
where.x, where.y);
@@ -655,23 +648,26 @@ void nsbeos_dispatch_event(BMessage *message)
{
nsurl* url;
BString realm;
- BString auth;
+ BString username;
+ BString password;
void* cbpw;
- nserror (*cb)(bool proceed, void* pw);
+ nserror (*cb)(const char *username,
+ const char *password,
+ void *pw);
if (message->FindPointer("URL", (void**)&url) < B_OK)
break;
if (message->FindString("Realm", &realm) < B_OK)
break;
- if (message->FindString("Auth", &auth) < B_OK)
+ if (message->FindString("User", &username) < B_OK)
+ break;
+ if (message->FindString("Pass", &password) < B_OK)
break;
if (message->FindPointer("callback", (void**)&cb) < B_OK)
break;
if (message->FindPointer("callback_pw", (void**)&cbpw) < B_OK)
break;
- //printf("login to '%s' with '%s'\n", url.String(), auth.String());
- urldb_set_auth_details(url, realm.String(), auth.String());
- cb(true, cbpw);
+ cb(username.String(), password.String(), cbpw);
break;
}
default:
@@ -683,7 +679,6 @@ void nsbeos_dispatch_event(BMessage *message)
void nsbeos_window_expose_event(BView *view, gui_window *g, BMessage *message)
{
BRect updateRect;
- //float scale = g->scale;
struct rect clip;
struct redraw_context ctx = { true, true, &nsbeos_plotters };
@@ -1113,93 +1108,79 @@ static void gui_window_update_extent(struct gui_window *g)
g->view->UnlockLooper();
}
-/* some cursors like those in Firefox */
-// XXX: move to separate file or resource ?
+static BCursorID gui_haiku_pointer(gui_pointer_shape shape)
+{
+ switch (shape) {
+ case GUI_POINTER_POINT: /* link */
+ return B_CURSOR_ID_FOLLOW_LINK;
-const uint8 kLinkCursorBits[] = {
- 16, /* cursor size */
- 1, /* bits per pixel */
- 2, /* vertical hot spot */
- 2, /* horizontal hot spot */
+ case GUI_POINTER_CARET: /* input */
+ return B_CURSOR_ID_I_BEAM;
- /* data */
- 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x24, 0x00, 0x24, 0x00, 0x13, 0xe0, 0x12, 0x5c, 0x09, 0x2a,
- 0x08, 0x01, 0x3c, 0x21, 0x4c, 0x71, 0x42, 0x71, 0x30, 0xf9, 0x0c, 0xf9, 0x02, 0x02, 0x01, 0x00,
+ case GUI_POINTER_MENU:
+ return B_CURSOR_ID_CONTEXT_MENU;
- /* mask */
- 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x3c, 0x00, 0x3c, 0x00, 0x1f, 0xe0, 0x1f, 0xfc, 0x0f, 0xfe,
- 0x0f, 0xff, 0x3f, 0xff, 0x7f, 0xff, 0x7f, 0xff, 0x3f, 0xff, 0x0f, 0xff, 0x03, 0xfc, 0x01, 0xe0
-};
+ case GUI_POINTER_UP:
+ return B_CURSOR_ID_RESIZE_NORTH;
-const uint8 kWatchCursorBits[] = {
- 16, /* cursor size */
- 1, /* bits per pixel */
- 0, /* vertical hot spot */
- 1, /* horizontal hot spot */
+ case GUI_POINTER_DOWN:
+ return B_CURSOR_ID_RESIZE_SOUTH;
- /* data */
- 0x70, 0x00, 0x48, 0x00, 0x48, 0x00, 0x27, 0xc0, 0x24, 0xb8, 0x12, 0x54, 0x10, 0x02, 0x78, 0x02,
- 0x98, 0x02, 0x84, 0x02, 0x60, 0x3a, 0x18, 0x46, 0x04, 0x8a, 0x02, 0x92, 0x01, 0x82, 0x00, 0x45,
+ case GUI_POINTER_LEFT:
+ return B_CURSOR_ID_RESIZE_WEST;
- /* mask */
- 0x70, 0x00, 0x78, 0x00, 0x78, 0x00, 0x3f, 0xc0, 0x3f, 0xf8, 0x1f, 0xfc, 0x1f, 0xfe, 0x7f, 0xfe,
- 0xff, 0xfe, 0xff, 0xfe, 0x7f, 0xfe, 0x1f, 0xfe, 0x07, 0xfe, 0x03, 0xfe, 0x01, 0xfe, 0x00, 0x7f
-};
+ case GUI_POINTER_RIGHT:
+ return B_CURSOR_ID_RESIZE_EAST;
-const uint8 kWatch2CursorBits[] = {
- 16, /* cursor size */
- 1, /* bits per pixel */
- 0, /* vertical hot spot */
- 1, /* horizontal hot spot */
+ case GUI_POINTER_RU:
+ return B_CURSOR_ID_RESIZE_NORTH_EAST;
- /* data */
- 0x70, 0x00, 0x48, 0x00, 0x48, 0x00, 0x27, 0xc0, 0x24, 0xb8, 0x12, 0x54, 0x10, 0x02, 0x78, 0x02,
- 0x98, 0x02, 0x84, 0x02, 0x60, 0x3a, 0x18, 0x46, 0x04, 0xa2, 0x02, 0x92, 0x01, 0xa2, 0x00, 0x45,
+ case GUI_POINTER_LD:
+ return B_CURSOR_ID_RESIZE_SOUTH_WEST;
- /* mask */
- 0x70, 0x00, 0x78, 0x00, 0x78, 0x00, 0x3f, 0xc0, 0x3f, 0xf8, 0x1f, 0xfc, 0x1f, 0xfe, 0x7f, 0xfe,
- 0xff, 0xfe, 0xff, 0xfe, 0x7f, 0xfe, 0x1f, 0xfe, 0x07, 0xfe, 0x03, 0xfe, 0x01, 0xfe, 0x00, 0x7f
-};
+ case GUI_POINTER_LU:
+ return B_CURSOR_ID_RESIZE_NORTH_WEST;
+
+ case GUI_POINTER_RD:
+ return B_CURSOR_ID_RESIZE_SOUTH_EAST;
+
+ case GUI_POINTER_CROSS:
+ return B_CURSOR_ID_CROSS_HAIR;
+
+ case GUI_POINTER_MOVE:
+ return B_CURSOR_ID_MOVE;
+
+ case GUI_POINTER_WAIT:
+ case GUI_POINTER_PROGRESS:
+ return B_CURSOR_ID_PROGRESS;
+
+ case GUI_POINTER_NO_DROP:
+ case GUI_POINTER_NOT_ALLOWED:
+ return B_CURSOR_ID_NOT_ALLOWED;
+ case GUI_POINTER_HELP:
+ return B_CURSOR_ID_HELP;
+
+ case GUI_POINTER_DEFAULT:
+ default:
+ break;
+ }
+ return B_CURSOR_ID_SYSTEM_DEFAULT;
+}
static void gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape)
{
- BCursor *cursor = NULL;
- bool allocated = false;
-
if (g->current_pointer == shape)
return;
g->current_pointer = shape;
- switch (shape) {
- case GUI_POINTER_POINT:
- cursor = new BCursor(kLinkCursorBits);
- allocated = true;
- break;
- case GUI_POINTER_CARET:
- cursor = (BCursor *)B_CURSOR_I_BEAM;
- break;
- case GUI_POINTER_WAIT:
- cursor = new BCursor(kWatchCursorBits);
- allocated = true;
- break;
- case GUI_POINTER_PROGRESS:
- cursor = new BCursor(kWatch2CursorBits);
- allocated = true;
- break;
- default:
- cursor = (BCursor *)B_CURSOR_SYSTEM_DEFAULT;
- allocated = false;
- }
+ BCursor cursor(gui_haiku_pointer(shape));
if (g->view && g->view->LockLooper()) {
- g->view->SetViewCursor(cursor);
+ g->view->SetViewCursor(&cursor);
g->view->UnlockLooper();
}
-
- if (allocated)
- delete cursor;
}
static void gui_window_place_caret(struct gui_window *g, int x, int y, int height,
@@ -1338,28 +1319,64 @@ struct gui_clipboard_table *beos_clipboard_table = &clipboard_table;
* \param g The gui window to measure content area of.
* \param width receives width of window
* \param height receives height of window
- * \param scaled whether to return scaled values
* \return NSERROR_OK on sucess and width and height updated
* else error code.
*/
static nserror
-gui_window_get_dimensions(struct gui_window *g, int *width, int *height,
- bool scaled)
+gui_window_get_dimensions(struct gui_window *g, int *width, int *height)
{
if (g->view &&
g->view->LockLooper()) {
*width = g->view->Bounds().Width() + 1;
*height = g->view->Bounds().Height() + 1;
g->view->UnlockLooper();
-
- if (scaled) {
- *width /= g->scale;
- *height /= g->scale;
- }
}
return NSERROR_OK;
}
+
+/**
+ * process miscellaneous window events
+ *
+ * \param gw The window receiving the event.
+ * \param event The event code.
+ * \return NSERROR_OK when processed ok
+ */
+static nserror
+gui_window_event(struct gui_window *gw, enum gui_window_event event)
+{
+ switch (event) {
+ case GW_EVENT_UPDATE_EXTENT:
+ gui_window_update_extent(gw);
+ break;
+
+ case GW_EVENT_REMOVE_CARET:
+ gui_window_remove_caret(gw);
+ break;
+
+ case GW_EVENT_NEW_CONTENT:
+ gui_window_new_content(gw);
+ break;
+
+ case GW_EVENT_START_SELECTION:
+ gui_start_selection(gw);
+ break;
+
+ case GW_EVENT_START_THROBBER:
+ gui_window_start_throbber(gw);
+ break;
+
+ case GW_EVENT_STOP_THROBBER:
+ gui_window_stop_throbber(gw);
+ break;
+
+ default:
+ break;
+ }
+ return NSERROR_OK;
+}
+
+
static struct gui_window_table window_table = {
gui_window_create,
gui_window_destroy,
@@ -1367,7 +1384,7 @@ static struct gui_window_table window_table = {
gui_window_get_scroll,
gui_window_set_scroll,
gui_window_get_dimensions,
- gui_window_update_extent,
+ gui_window_event,
/* from scaffold */
gui_window_set_title,
@@ -1376,18 +1393,13 @@ static struct gui_window_table window_table = {
gui_window_set_status,
gui_window_set_pointer,
gui_window_place_caret,
- gui_window_remove_caret,
- gui_window_start_throbber,
- gui_window_stop_throbber,
NULL, //drag_start
NULL, //save_link
- NULL, //scroll_start
- gui_window_new_content,
NULL, //create_form_select_menu
NULL, //file_gadget_open
NULL, //drag_save_object
NULL, //drag_save_selection
- gui_start_selection
+ NULL //console_log
};
struct gui_window_table *beos_window_table = &window_table;