}
void
- MouseDown (BPoint point)
+ BasicMouseDown (BPoint point, BView *scroll_bar)
{
struct haiku_button_event rq;
- uint32 buttons;
+ uint32 mods, buttons;
this->GetMouse (&point, &buttons, false);
grab_view_locker.Unlock ();
rq.window = this->Window ();
+ rq.scroll_bar = scroll_bar;
if (!(previous_buttons & B_PRIMARY_MOUSE_BUTTON)
&& (buttons & B_PRIMARY_MOUSE_BUTTON))
rq.x = point.x;
rq.y = point.y;
- uint32_t mods = modifiers ();
+ mods = modifiers ();
rq.modifiers = 0;
if (mods & B_SHIFT_KEY)
if (mods & B_OPTION_KEY)
rq.modifiers |= HAIKU_MODIFIER_SUPER;
- SetMouseEventMask (B_POINTER_EVENTS, (B_LOCK_WINDOW_FOCUS
- | B_NO_POINTER_HISTORY));
+ if (!scroll_bar)
+ SetMouseEventMask (B_POINTER_EVENTS, (B_LOCK_WINDOW_FOCUS
+ | B_NO_POINTER_HISTORY));
rq.time = system_time ();
haiku_write (BUTTON_DOWN, &rq);
}
void
- MouseUp (BPoint point)
+ MouseDown (BPoint point)
+ {
+ BasicMouseDown (point, NULL);
+ }
+
+ void
+ BasicMouseUp (BPoint point, BView *scroll_bar)
{
struct haiku_button_event rq;
- uint32 buttons;
+ uint32 buttons, mods;
this->GetMouse (&point, &buttons, false);
}
rq.window = this->Window ();
+ rq.scroll_bar = scroll_bar;
if ((previous_buttons & B_PRIMARY_MOUSE_BUTTON)
&& !(buttons & B_PRIMARY_MOUSE_BUTTON))
rq.x = point.x;
rq.y = point.y;
- uint32_t mods = modifiers ();
+ mods = modifiers ();
rq.modifiers = 0;
if (mods & B_SHIFT_KEY)
if (mods & B_OPTION_KEY)
rq.modifiers |= HAIKU_MODIFIER_SUPER;
- if (!buttons)
- SetMouseEventMask (0, 0);
-
rq.time = system_time ();
haiku_write (BUTTON_UP, &rq);
}
+
+ void
+ MouseUp (BPoint point)
+ {
+ BasicMouseUp (point, NULL);
+ }
};
class EmacsScrollBar : public BScrollBar
int max_value, real_max_value;
int overscroll_start_value;
bigtime_t repeater_start;
+ EmacsView *parent;
- EmacsScrollBar (int x, int y, int x1, int y1, bool horizontal_p)
+ EmacsScrollBar (int x, int y, int x1, int y1, bool horizontal_p,
+ EmacsView *parent)
: BScrollBar (BRect (x, y, x1, y1), NULL, NULL, 0, 0, horizontal_p ?
B_HORIZONTAL : B_VERTICAL),
dragging (0),
handle_button (false),
in_overscroll (false),
can_overscroll (false),
- maybe_overscroll (false)
+ maybe_overscroll (false),
+ parent (parent)
{
BView *vw = (BView *) this;
vw->SetResizingMode (B_FOLLOW_NONE);
BLooper *looper;
BMessage *message;
int32 buttons, mods;
- BView *parent;
looper = Looper ();
message = NULL;
{
/* Allow C-mouse-3 to split the window on a scroll bar. */
handle_button = true;
- parent = Parent ();
- parent->MouseDown (ConvertToParent (pt));
+ SetMouseEventMask (B_POINTER_EVENTS, (B_SUSPEND_VIEW_FOCUS
+ | B_LOCK_WINDOW_FOCUS));
+ parent->BasicMouseDown (ConvertToParent (pt), this);
return;
}
MouseUp (BPoint pt)
{
struct haiku_scroll_bar_drag_event rq;
- BView *parent;
in_overscroll = false;
maybe_overscroll = false;
if (handle_button)
{
handle_button = false;
- parent = Parent ();
- parent->MouseUp (ConvertToParent (pt));
+ parent->BasicMouseUp (ConvertToParent (pt), this);
return;
}
/* Make a scrollbar, attach it to VIEW's window, and return it. */
void *
-BScrollBar_make_for_view (void *view, int horizontal_p,
- int x, int y, int x1, int y1,
- void *scroll_bar_ptr)
+be_make_scroll_bar_for_view (void *view, int horizontal_p,
+ int x, int y, int x1, int y1)
{
- EmacsScrollBar *sb = new EmacsScrollBar (x, y, x1, y1, horizontal_p);
+ EmacsScrollBar *scroll_bar;
BView *vw = (BView *) view;
- BView *sv = (BView *) sb;
if (!vw->LockLooper ())
gui_abort ("Failed to lock scrollbar owner");
- vw->AddChild ((BView *) sb);
- sv->WindowActivated (vw->Window ()->IsActive ());
+
+ scroll_bar = new EmacsScrollBar (x, y, x1, y1, horizontal_p,
+ (EmacsView *) vw);
+
+ vw->AddChild (scroll_bar);
vw->UnlockLooper ();
- return sb;
+
+ return scroll_bar;
}
void
if (!frame)
return NULL;
+ if (!scroll_bar)
+ return NULL;
+
if (!NILP (FRAME_SCROLL_BARS (frame)))
{
for (tem = FRAME_SCROLL_BARS (frame); !NILP (tem);
bar->update = -1;
bar->horizontal = horizontal_p;
- scroll_bar = BScrollBar_make_for_view (view, horizontal_p,
- left, top, left + width - 1,
- top + height - 1, bar);
+ scroll_bar = be_make_scroll_bar_for_view (view, horizontal_p,
+ left, top, left + width - 1,
+ top + height - 1);
BView_publish_scroll_bar (view, left, top, width, height);
bar->next = FRAME_SCROLL_BARS (f);
x_display_list->last_mouse_glyph_frame = f1;
*bar_window = Qnil;
- *part = scroll_bar_above_handle;
+ *part = scroll_bar_nowhere;
/* If track-mouse is `drag-source' and the mouse pointer is
certain to not be actually under the chosen frame, return
Lisp_Object tab_bar_arg = Qnil;
int tab_bar_p = 0, tool_bar_p = 0;
bool up_okay_p = false;
+ struct scroll_bar *bar;
if (popup_activated_p || !f)
continue;
- struct haiku_display_info *dpyinfo = FRAME_DISPLAY_INFO (f);
-
inev.modifiers = haiku_modifiers_to_emacs (b->modifiers);
+ bar = haiku_scroll_bar_from_widget (b->scroll_bar, b->window);
x_display_list->last_mouse_glyph_frame = 0;
x_display_list->last_mouse_movement_time = b->time / 1000;
if (type == BUTTON_UP)
{
inev.modifiers |= up_modifier;
- up_okay_p = (dpyinfo->grabbed & (1 << b->btn_no));
- dpyinfo->grabbed &= ~(1 << b->btn_no);
+ up_okay_p = (x_display_list->grabbed & (1 << b->btn_no));
+ x_display_list->grabbed &= ~(1 << b->btn_no);
}
else
{
up_okay_p = true;
inev.modifiers |= down_modifier;
- dpyinfo->last_mouse_frame = f;
- dpyinfo->grabbed |= (1 << b->btn_no);
+ x_display_list->last_mouse_frame = f;
+ x_display_list->grabbed |= (1 << b->btn_no);
if (f && !tab_bar_p)
f->last_tab_bar_item = -1;
if (f && !tool_bar_p)
f->last_tool_bar_item = -1;
}
- if (up_okay_p
- && !(tab_bar_p && NILP (tab_bar_arg))
- && !tool_bar_p)
+ if (bar)
+ {
+ inev.kind = (bar->horizontal
+ ? HORIZONTAL_SCROLL_BAR_CLICK_EVENT
+ : SCROLL_BAR_CLICK_EVENT);
+ inev.part = (bar->horizontal
+ ? scroll_bar_horizontal_handle
+ : scroll_bar_handle);
+ }
+ else if (up_okay_p
+ && !(tab_bar_p && NILP (tab_bar_arg))
+ && !tool_bar_p)
inev.kind = MOUSE_CLICK_EVENT;
+
inev.arg = tab_bar_arg;
inev.code = b->btn_no;
f->mouse_moved = false;
- XSETINT (inev.x, b->x);
- XSETINT (inev.y, b->y);
+ if (bar)
+ {
+ if (bar->horizontal)
+ {
+ XSETINT (inev.x, min (max (0, b->x - bar->left),
+ bar->width));
+ XSETINT (inev.y, bar->width);
+ }
+ else
+ {
+ XSETINT (inev.x, min (max (0, b->y - bar->top),
+ bar->height));
+ XSETINT (inev.y, bar->height);
+ }
+
+ inev.frame_or_window = bar->window;
+ }
+ else
+ {
+ XSETINT (inev.x, b->x);
+ XSETINT (inev.y, b->y);
+ XSETFRAME (inev.frame_or_window, f);
+ }
- XSETFRAME (inev.frame_or_window, f);
break;
}
case ICONIFICATION:
inev.kind = (bar->horizontal
? HORIZONTAL_SCROLL_BAR_CLICK_EVENT :
SCROLL_BAR_CLICK_EVENT);
- inev.part = bar->horizontal ?
- scroll_bar_horizontal_handle : scroll_bar_handle;
+ inev.part = (bar->horizontal
+ ? scroll_bar_horizontal_handle
+ : scroll_bar_handle);
if (bar->horizontal)
{