class EmacsScrollBar : public BScrollBar
{
public:
- void *scroll_bar;
int dragging = 0;
bool horizontal;
enum haiku_scroll_bar_part current_part;
{
SetValue (old_value);
- part.scroll_bar = scroll_bar;
+ part.scroll_bar = this;
+ part.window = Window ();
part.part = current_part;
haiku_write (SCROLL_BAR_PART_EVENT, &part);
}
return;
}
- rq.scroll_bar = scroll_bar;
+ rq.scroll_bar = this;
+ rq.window = Window ();
rq.position = new_value;
haiku_write (SCROLL_BAR_VALUE_EVENT, &rq);
if (r.Contains (pt))
{
- part.scroll_bar = scroll_bar;
+ part.scroll_bar = this;
+ part.window = Window ();
part.part = HAIKU_SCROLL_BAR_UP_BUTTON;
dragging = 1;
current_part = HAIKU_SCROLL_BAR_UP_BUTTON;
if (r.Contains (pt))
{
- part.scroll_bar = scroll_bar;
+ part.scroll_bar = this;
+ part.window = Window ();
part.part = HAIKU_SCROLL_BAR_DOWN_BUTTON;
dragging = 1;
current_part = HAIKU_SCROLL_BAR_DOWN_BUTTON;
}
rq.dragging_p = 1;
- rq.scroll_bar = scroll_bar;
+ rq.window = Window ();
+ rq.scroll_bar = this;
haiku_write (SCROLL_BAR_DRAG_EVENT, &rq);
{
struct haiku_scroll_bar_drag_event rq;
rq.dragging_p = 0;
- rq.scroll_bar = scroll_bar;
+ rq.scroll_bar = this;
+ rq.window = Window ();
haiku_write (SCROLL_BAR_DRAG_EVENT, &rq);
dragging = false;
void *scroll_bar_ptr)
{
EmacsScrollBar *sb = new EmacsScrollBar (x, y, x1, y1, horizontal_p);
- sb->scroll_bar = scroll_bar_ptr;
-
BView *vw = (BView *) view;
BView *sv = (BView *) sb;
+
if (!vw->LockLooper ())
gui_abort ("Failed to lock scrollbar owner");
vw->AddChild ((BView *) sb);
struct haiku_scroll_bar_value_event
{
void *scroll_bar;
+ void *window;
int position;
};
struct haiku_scroll_bar_drag_event
{
void *scroll_bar;
+ void *window;
int dragging_p;
};
struct haiku_scroll_bar_part_event
{
void *scroll_bar;
+ void *window;
enum haiku_scroll_bar_part part;
};
}
}
+static struct scroll_bar *
+haiku_scroll_bar_from_widget (void *scroll_bar, void *window)
+{
+ Lisp_Object tem;
+ struct frame *frame = haiku_window_to_frame (window);
+
+ if (!frame)
+ return NULL;
+
+ if (!NILP (FRAME_SCROLL_BARS (frame)))
+ {
+ for (tem = FRAME_SCROLL_BARS (frame); !NILP (tem);
+ tem = XSCROLL_BAR (tem)->next)
+ {
+ if (XSCROLL_BAR (tem)->scroll_bar == scroll_bar)
+ return XSCROLL_BAR (tem);
+ }
+ }
+
+ return NULL;
+}
+
/* Unfortunately, NOACTIVATE is not implementable on Haiku. */
static void
haiku_focus_frame (struct frame *frame, bool noactivate)
case SCROLL_BAR_VALUE_EVENT:
{
struct haiku_scroll_bar_value_event *b = buf;
- struct scroll_bar *bar = b->scroll_bar;
+ struct scroll_bar *bar
+ = haiku_scroll_bar_from_widget (b->scroll_bar, b->window);
+
+ if (!bar)
+ continue;
struct window *w = XWINDOW (bar->window);
case SCROLL_BAR_PART_EVENT:
{
struct haiku_scroll_bar_part_event *b = buf;
- struct scroll_bar *bar = b->scroll_bar;
+ struct scroll_bar *bar
+ = haiku_scroll_bar_from_widget (b->scroll_bar, b->window);
+
+ if (!bar)
+ continue;
inev.kind = (bar->horizontal ? HORIZONTAL_SCROLL_BAR_CLICK_EVENT
: SCROLL_BAR_CLICK_EVENT);
case SCROLL_BAR_DRAG_EVENT:
{
struct haiku_scroll_bar_drag_event *b = buf;
- struct scroll_bar *bar = b->scroll_bar;
+ struct scroll_bar *bar
+ = haiku_scroll_bar_from_widget (b->scroll_bar, b->window);
+
+ if (!bar)
+ continue;
bar->dragging = b->dragging_p;
if (!b->dragging_p && bar->horizontal)