condemned = Qnil,
! GC_NILP (bar));
bar = XSCROLL_BAR (bar)->next)
- if (SCROLL_BAR_X_WINDOW (XSCROLL_BAR (bar)) == window_id &&
+ if (XSCROLL_BAR (bar)->x_window == window_id &&
FRAME_X_DISPLAY (XFRAME (frame)) == display)
return XSCROLL_BAR (bar);
}
}
}
+#elif defined USE_GTK
-#else /* !USE_MOTIF, i.e. Xaw or GTK */
-#ifdef USE_GTK
/* Scroll bar callback for GTK scroll bars. WIDGET is the scroll
bar widget. DATA is a pointer to the scroll_bar structure. */
}
}
-#else /* not USE_GTK */
+#else /* not USE_GTK and not USE_MOTIF */
/* Xaw scroll bar callback. Invoked when the thumb is dragged.
WIDGET is the scroll bar widget. CLIENT_DATA is a pointer to the
x_send_scroll_bar_event (bar->window, part, position, height);
}
-#endif /* not USE_GTK */
-#endif /* not USE_MOTIF */
+#endif /* not USE_GTK and not USE_MOTIF */
#define SCROLL_BAR_NAME "verticalScrollBar"
/* Remember X window and widget in the scroll bar vector. */
SET_SCROLL_BAR_X_WIDGET (bar, widget);
xwindow = XtWindow (widget);
- SET_SCROLL_BAR_X_WINDOW (bar, xwindow);
+ bar->x_window = xwindow;
UNBLOCK_INPUT;
}
{
struct frame *f = XFRAME (w->frame);
struct scroll_bar *bar
- = XSCROLL_BAR (Fmake_vector (make_number (SCROLL_BAR_VEC_SIZE), Qnil));
+ = ALLOCATE_PSEUDOVECTOR (struct scroll_bar, x_window, PVEC_OTHER);
BLOCK_INPUT;
CopyFromParent,
/* Attributes. */
mask, &a);
- SET_SCROLL_BAR_X_WINDOW (bar, window);
+ bar->x_window = window;
}
#endif /* not USE_TOOLKIT_SCROLL_BARS */
XSETWINDOW (bar->window, w);
- XSETINT (bar->top, top);
- XSETINT (bar->left, left);
- XSETINT (bar->width, width);
- XSETINT (bar->height, height);
- XSETINT (bar->start, 0);
- XSETINT (bar->end, 0);
+ bar->top = top;
+ bar->left = left;
+ bar->width = width;
+ bar->height = height;
+ bar->start = 0;
+ bar->end = 0;
bar->dragging = Qnil;
-#ifdef USE_TOOLKIT_SCROLL_BARS
- bar->fringe_extended_p = Qnil;
-#endif
+ bar->fringe_extended_p = 0;
/* Add bar to its frame's list of scroll bars. */
bar->next = FRAME_SCROLL_BARS (f);
{
#ifdef USE_GTK
xg_update_scrollbar_pos (f,
- SCROLL_BAR_X_WINDOW (bar),
+ bar->x_window,
top,
left + VERTICAL_SCROLL_BAR_WIDTH_TRIM,
width - VERTICAL_SCROLL_BAR_WIDTH_TRIM * 2,
max (height, 1));
- xg_show_scroll_bar (SCROLL_BAR_X_WINDOW (bar));
+ xg_show_scroll_bar (bar->x_window);
#else /* not USE_GTK */
Widget scroll_bar = SCROLL_BAR_X_WIDGET (FRAME_X_DISPLAY (f), bar);
XtConfigureWidget (scroll_bar,
#endif /* not USE_GTK */
}
#else /* not USE_TOOLKIT_SCROLL_BARS */
- XMapRaised (FRAME_X_DISPLAY (f), SCROLL_BAR_X_WINDOW (bar));
+ XMapRaised (FRAME_X_DISPLAY (f), bar->x_window);
#endif /* not USE_TOOLKIT_SCROLL_BARS */
UNBLOCK_INPUT;
}
+#ifndef USE_TOOLKIT_SCROLL_BARS
+
/* Draw BAR's handle in the proper position.
If the handle is already drawn from START to END, don't bother
the bar's top is as far down as it goes; otherwise, there's no way
to move to the very end of the buffer. */
-#ifndef USE_TOOLKIT_SCROLL_BARS
-
static void
x_scroll_bar_set_handle (bar, start, end, rebuild)
struct scroll_bar *bar;
int rebuild;
{
int dragging = ! NILP (bar->dragging);
- Window w = SCROLL_BAR_X_WINDOW (bar);
+ Window w = bar->x_window;
FRAME_PTR f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window)));
GC gc = f->output_data.x->normal_gc;
#ifdef USE_TOOLKIT_SCROLL_BARS
#ifdef USE_GTK
- xg_remove_scroll_bar (f, SCROLL_BAR_X_WINDOW (bar));
+ xg_remove_scroll_bar (f, bar->x_window);
#else /* not USE_GTK */
XtDestroyWidget (SCROLL_BAR_X_WIDGET (FRAME_X_DISPLAY (f), bar));
#endif /* not USE_GTK */
#else
- XDestroyWindow (FRAME_X_DISPLAY (f), SCROLL_BAR_X_WINDOW (bar));
+ XDestroyWindow (FRAME_X_DISPLAY (f), bar->x_window);
#endif
/* Disassociate this scroll bar from its window. */
BLOCK_INPUT;
- if (sb_left != XINT (bar->left))
+ if (sb_left != bar->left)
mask |= CWX;
- if (top != XINT (bar->top))
+ if (top != bar->top)
mask |= CWY;
- if (sb_width != XINT (bar->width))
+ if (sb_width != bar->width)
mask |= CWWidth;
- if (height != XINT (bar->height))
+ if (height != bar->height)
mask |= CWHeight;
#ifdef USE_TOOLKIT_SCROLL_BARS
/* Move/size the scroll bar widget. */
- if (mask || !NILP (bar->fringe_extended_p) != fringe_extended_p)
+ if (mask || bar->fringe_extended_p != fringe_extended_p)
{
/* Since toolkit scroll bars are smaller than the space reserved
for them on the frame, we have to clear "under" them. */
}
#ifdef USE_GTK
xg_update_scrollbar_pos (f,
- SCROLL_BAR_X_WINDOW (bar),
+ bar->x_window,
top,
sb_left + VERTICAL_SCROLL_BAR_WIDTH_TRIM,
sb_width - VERTICAL_SCROLL_BAR_WIDTH_TRIM *2,
wc.y = top;
wc.width = sb_width - VERTICAL_SCROLL_BAR_WIDTH_TRIM * 2;
wc.height = height;
- XConfigureWindow (FRAME_X_DISPLAY (f), SCROLL_BAR_X_WINDOW (bar),
+ XConfigureWindow (FRAME_X_DISPLAY (f), bar->x_window,
mask, &wc);
}
#endif /* not USE_TOOLKIT_SCROLL_BARS */
/* Remember new settings. */
- XSETINT (bar->left, sb_left);
- XSETINT (bar->top, top);
- XSETINT (bar->width, sb_width);
- XSETINT (bar->height, height);
+ bar->left = sb_left;
+ bar->top = top;
+ bar->width = sb_width;
+ bar->height = height;
UNBLOCK_INPUT;
}
#ifdef USE_TOOLKIT_SCROLL_BARS
- bar->fringe_extended_p = fringe_extended_p ? Qt : Qnil;
+ bar->fringe_extended_p = fringe_extended_p;
x_set_toolkit_scroll_bar_thumb (bar, portion, position, whole);
#else /* not USE_TOOLKIT_SCROLL_BARS */
struct scroll_bar *bar;
XEvent *event;
{
- Window w = SCROLL_BAR_X_WINDOW (bar);
+ Window w = bar->x_window;
FRAME_PTR f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window)));
GC gc = f->output_data.x->normal_gc;
int width_trim = VERTICAL_SCROLL_BAR_WIDTH_TRIM;
#if 0
FRAME_PTR f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window)));
int internal_height
- = VERTICAL_SCROLL_BAR_INSIDE_HEIGHT (f, XINT (bar->height));
+ = VERTICAL_SCROLL_BAR_INSIDE_HEIGHT (f, bar->height);
#endif
int top_range
- = VERTICAL_SCROLL_BAR_TOP_RANGE (f, XINT (bar->height));
+ = VERTICAL_SCROLL_BAR_TOP_RANGE (f, bar->height);
int y = event->xbutton.y - VERTICAL_SCROLL_BAR_TOP_BORDER;
if (y < 0) y = 0;
if (y > top_range) y = top_range;
- if (y < XINT (bar->start))
+ if (y < bar->start)
emacs_event->part = scroll_bar_above_handle;
- else if (y < XINT (bar->end) + VERTICAL_SCROLL_BAR_MIN_HANDLE)
+ else if (y < bar->end + VERTICAL_SCROLL_BAR_MIN_HANDLE)
emacs_event->part = scroll_bar_handle;
else
emacs_event->part = scroll_bar_below_handle;
unsigned long *time;
{
struct scroll_bar *bar = XSCROLL_BAR (last_mouse_scroll_bar);
- Window w = SCROLL_BAR_X_WINDOW (bar);
+ Window w = bar->x_window;
FRAME_PTR f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window)));
int win_x, win_y;
Window dummy_window;
{
#if 0
int inside_height
- = VERTICAL_SCROLL_BAR_INSIDE_HEIGHT (f, XINT (bar->height));
+ = VERTICAL_SCROLL_BAR_INSIDE_HEIGHT (f, bar->height);
#endif
int top_range
- = VERTICAL_SCROLL_BAR_TOP_RANGE (f, XINT (bar->height));
+ = VERTICAL_SCROLL_BAR_TOP_RANGE (f, bar->height);
win_y -= VERTICAL_SCROLL_BAR_TOP_BORDER;
if (! NILP (bar->dragging))
*part = scroll_bar_handle;
- else if (win_y < XINT (bar->start))
+ else if (win_y < bar->start)
*part = scroll_bar_above_handle;
- else if (win_y < XINT (bar->end) + VERTICAL_SCROLL_BAR_MIN_HANDLE)
+ else if (win_y < bar->end + VERTICAL_SCROLL_BAR_MIN_HANDLE)
*part = scroll_bar_handle;
else
*part = scroll_bar_below_handle;
for (bar = FRAME_SCROLL_BARS (f); VECTORP (bar);
bar = XSCROLL_BAR (bar)->next)
XClearArea (FRAME_X_DISPLAY (f),
- SCROLL_BAR_X_WINDOW (XSCROLL_BAR (bar)),
+ XSCROLL_BAR (bar)->x_window,
0, 0, 0, 0, True);
#endif /* not USE_TOOLKIT_SCROLL_BARS */
}
if (tool_bar_p && event.xbutton.button < 4)
{
- if (event.xbutton.type == ButtonPress)
- handle_tool_bar_click (f, x, y, 1, 0);
- else
- handle_tool_bar_click (f, x, y, 0,
- x_x_to_emacs_modifiers (dpyinfo,
- event.xbutton.state));
+ handle_tool_bar_click (f, x, y,
+ event.xbutton.type == ButtonPress,
+ x_x_to_emacs_modifiers (dpyinfo,
+ event.xbutton.state));
}
}
Closing the display is reported to lead to a bus error on
OpenWindows in certain situations. I suspect that is a bug
- in OpenWindows. I don't know how to cicumvent it here. */
+ in OpenWindows. I don't know how to circumvent it here. */
#ifdef USE_X_TOOLKIT
/* If DPYINFO is null, this means we didn't open the display
unbind_to (index, Qnil);
clear_waiting_for_input ();
+ /* FIXME: This is an asynchronous interrupt w.r.t elisp, so signalling an
+ error might not be the best thing to do. I'd vote for creating an
+ elisp event and stuffing it in the queue so people can bind to it via
+ the global map. --Stef */
error ("%s", error_msg);
}
/* Mac OS X 10.3's Xserver sometimes reports 0.0mm. */
dpyinfo->resy = (mm < 1) ? 100 : pixels * 25.4 / mm;
pixels = DisplayWidth (dpyinfo->display, screen_number);
- /* Mac OS X 10.3's Xserver sometimes reports 0.0mm. */
mm = DisplayWidthMM (dpyinfo->display, screen_number);
+ /* Mac OS X 10.3's Xserver sometimes reports 0.0mm. */
dpyinfo->resx = (mm < 1) ? 100 : pixels * 25.4 / mm;
}
Qnil, Qnil);
#ifdef USE_XIM
if (STRINGP (value)
- && (!strcmp (XSTRING (value)->data, "false")
- || !strcmp (XSTRING (value)->data, "off")))
+ && (!strcmp (SDATA (value), "false")
+ || !strcmp (SDATA (value), "off")))
use_xim = 0;
#else
if (STRINGP (value)
- && (!strcmp (XSTRING (value)->data, "true")
- || !strcmp (XSTRING (value)->data, "on")))
+ && (!strcmp (SDATA (value), "true")
+ || !strcmp (SDATA (value), "on")))
use_xim = 1;
#endif
}
/* The next and previous in the chain of scroll bars in this frame. */
Lisp_Object next, prev;
- /* The X window representing this scroll bar. Since this is a full
- 32-bit quantity, we store it split into two 32-bit values. */
- Lisp_Object x_window_low, x_window_high;
+ /* Fields from `x_window' down will not be traced by the GC. */
+
+ /* The X window representing this scroll bar. */
+ Window x_window;
/* The position and size of the scroll bar in pixels, relative to the
frame. */
- Lisp_Object top, left, width, height;
+ int top, left, width, height;
/* The starting and ending positions of the handle, relative to the
handle area (i.e. zero is the top position, not
drawing handle bottoms VERTICAL_SCROLL_BAR_MIN_HANDLE pixels below
where they would be normally; the bottom and top are in a
different co-ordinate system. */
- Lisp_Object start, end;
+ int start, end;
/* If the scroll bar handle is currently being dragged by the user,
this is the number of pixels from the top of the handle to the
being dragged, this is Qnil. */
Lisp_Object dragging;
-#ifdef USE_TOOLKIT_SCROLL_BARS
- /* t if the background of the fringe that is adjacent to a scroll
+ /* 1 if the background of the fringe that is adjacent to a scroll
bar is extended to the gap between the fringe and the bar. */
- Lisp_Object fringe_extended_p;
-#endif
+ unsigned int fringe_extended_p : 1;
};
/* The number of elements a vector holding a struct scroll_bar needs. */
#define XSCROLL_BAR(vec) ((struct scroll_bar *) XVECTOR (vec))
-/* Building a 32-bit C integer from two 16-bit lisp integers. */
-#define SCROLL_BAR_PACK(low, high) (XINT (high) << 16 | XINT (low))
-
-/* Setting two lisp integers to the low and high words of a 32-bit C int. */
-#define SCROLL_BAR_UNPACK(low, high, int32) \
- (XSETINT ((low), (int32) & 0xffff), \
- XSETINT ((high), ((int32) >> 16) & 0xffff))
-
-
-/* Extract the X window id of the scroll bar from a struct scroll_bar. */
-#define SCROLL_BAR_X_WINDOW(ptr) \
- ((Window) SCROLL_BAR_PACK ((ptr)->x_window_low, (ptr)->x_window_high))
-
-/* Store a window id in a struct scroll_bar. */
-#define SET_SCROLL_BAR_X_WINDOW(ptr, id) \
- (SCROLL_BAR_UNPACK ((ptr)->x_window_low, (ptr)->x_window_high, (int) id))
-
/* Extract the X widget of the scroll bar from a struct scroll_bar.
XtWindowToWidget should be fast enough since Xt uses a hash table
to map windows to widgets. */
#define SCROLL_BAR_X_WIDGET(dpy, ptr) \
- XtWindowToWidget (dpy, SCROLL_BAR_X_WINDOW (ptr))
+ XtWindowToWidget (dpy, ptr->x_window)
/* Store a widget id in a struct scroll_bar. */
#define SET_SCROLL_BAR_X_WIDGET(ptr, w) \
do { \
Window window = XtWindow (w); \
- SET_SCROLL_BAR_X_WINDOW (ptr, window); \
+ ptr->x_window = window; \
} while (0)