diff options
| author | YAMAMOTO Mitsuharu | 2005-05-06 08:03:24 +0000 |
|---|---|---|
| committer | YAMAMOTO Mitsuharu | 2005-05-06 08:03:24 +0000 |
| commit | 5b8b73ff90054ffa201f7620741bf913401dfca6 (patch) | |
| tree | ca6a27c1df98f20e6e011155ae9f58976dac9700 | |
| parent | 956c0f10b5eb31886aaa0a2c69e209f02d4f249a (diff) | |
| download | emacs-5b8b73ff90054ffa201f7620741bf913401dfca6.tar.gz emacs-5b8b73ff90054ffa201f7620741bf913401dfca6.zip | |
(toolkit_scroll_bar_interaction): Remove unused
variable.
(mac_handle_tool_bar_click): Remove unused function and
declaration.
[USE_TOOLKIT_SCROLL_BARS] (scroll_bar_timer_callback)
(install_scroll_bar_timer, set_scroll_bar_timer)
(control_part_code_to_scroll_bar_part, construct_scroll_bar_click)
(get_control_part_bound, x_scroll_bar_handle_press)
(x_scroll_bar_handle_release, x_scroll_bar_handle_drag)
(x_set_toolkit_scroll_bar_thumb): New functions and declarations.
[USE_TOOLKIT_SCROLL_BARS] (last_scroll_bar_part, scroll_bar_timer)
(scroll_bar_timer_event_posted_p): New variables.
[USE_TOOLKIT_SCROLL_BARS] (SCROLL_BAR_FIRST_DELAY)
(SCROLL_BAR_CONTINUOUS_DELAY): New macros.
(x_scroll_bar_create): Set control reference with NewControl.
(x_scroll_bar_create) [USE_TOOLKIT_SCROLL_BARS]: Initialize
track_top and track_height to nil.
(x_scroll_bar_set_handle, x_scroll_bar_note_movement): Put
functions in #ifndef USE_TOOLKIT_SCROLL_BARS.
(XTset_vertical_scroll_bar): Don't make space between scroll bar
and associated window.
(XTset_vertical_scroll_bar) [MAC_OSX]: Get scroll bar area width
from window config.
(XTset_vertical_scroll_bar) [USE_TOOLKIT_SCROLL_BARS]: Set
track_top and track_height to nil when scroll bar size is changed.
Recalculate them if they are nil.
(XTread_socket) [MAC_OSX]: Use control kind to determine if the
clicked control is a scroll bar.
(XTread_socket) [USE_TOOLKIT_SCROLL_BARS]: Use toolkit scroll bar
event handler functions. Don't add modifiers to scroll bar click
events. Call scroll bar release handler when window is
deactivated.
(mac_initialize): Remove unused code for X toolkit.
(syms_of_macterm) [!USE_TOOLKIT_SCROLL_BARS]: Initialize
Vx_toolkit_scroll_bars to nil.
| -rw-r--r-- | src/macterm.c | 502 |
1 files changed, 423 insertions, 79 deletions
diff --git a/src/macterm.c b/src/macterm.c index ab2c46a8ad5..b83419ef6da 100644 --- a/src/macterm.c +++ b/src/macterm.c | |||
| @@ -154,10 +154,6 @@ extern int waiting_for_input; | |||
| 154 | 154 | ||
| 155 | struct frame *pending_autoraise_frame; | 155 | struct frame *pending_autoraise_frame; |
| 156 | 156 | ||
| 157 | /* Non-zero means user is interacting with a toolkit scroll bar. */ | ||
| 158 | |||
| 159 | static int toolkit_scroll_bar_interaction; | ||
| 160 | |||
| 161 | /* Mouse movement. | 157 | /* Mouse movement. |
| 162 | 158 | ||
| 163 | Formerly, we used PointerMotionHintMask (in standard_event_mask) | 159 | Formerly, we used PointerMotionHintMask (in standard_event_mask) |
| @@ -256,7 +252,6 @@ QDGlobals qd; /* QuickDraw global information structure. */ | |||
| 256 | struct frame * x_window_to_frame (struct mac_display_info *, WindowPtr); | 252 | struct frame * x_window_to_frame (struct mac_display_info *, WindowPtr); |
| 257 | struct mac_display_info *mac_display_info_for_display (Display *); | 253 | struct mac_display_info *mac_display_info_for_display (Display *); |
| 258 | static void x_update_window_end P_ ((struct window *, int, int)); | 254 | static void x_update_window_end P_ ((struct window *, int, int)); |
| 259 | static void mac_handle_tool_bar_click P_ ((struct frame *, EventRecord *)); | ||
| 260 | static int x_io_error_quitter P_ ((Display *)); | 255 | static int x_io_error_quitter P_ ((Display *)); |
| 261 | int x_catch_errors P_ ((Display *)); | 256 | int x_catch_errors P_ ((Display *)); |
| 262 | void x_uncatch_errors P_ ((Display *, int)); | 257 | void x_uncatch_errors P_ ((Display *, int)); |
| @@ -4131,30 +4126,316 @@ XTmouse_position (fp, insist, bar_window, part, x, y, time) | |||
| 4131 | } | 4126 | } |
| 4132 | 4127 | ||
| 4133 | 4128 | ||
| 4134 | /*********************************************************************** | 4129 | /************************************************************************ |
| 4135 | Tool-bars | 4130 | Toolkit scroll bars |
| 4136 | ***********************************************************************/ | 4131 | ************************************************************************/ |
| 4132 | |||
| 4133 | #ifdef USE_TOOLKIT_SCROLL_BARS | ||
| 4134 | |||
| 4135 | static pascal void scroll_bar_timer_callback P_ ((EventLoopTimerRef, void *)); | ||
| 4136 | static OSStatus install_scroll_bar_timer P_ ((void)); | ||
| 4137 | static OSStatus set_scroll_bar_timer P_ ((EventTimerInterval)); | ||
| 4138 | static int control_part_code_to_scroll_bar_part P_((ControlPartCode)); | ||
| 4139 | static void construct_scroll_bar_click P_ ((struct scroll_bar *, int, | ||
| 4140 | unsigned long, | ||
| 4141 | struct input_event *)); | ||
| 4142 | static OSErr get_control_part_bound P_((ControlHandle, ControlPartCode, | ||
| 4143 | Rect *)); | ||
| 4144 | static void x_scroll_bar_handle_press P_ ((struct scroll_bar *, | ||
| 4145 | ControlPartCode, | ||
| 4146 | unsigned long, | ||
| 4147 | struct input_event *)); | ||
| 4148 | static void x_scroll_bar_handle_release P_ ((struct scroll_bar *, | ||
| 4149 | unsigned long, | ||
| 4150 | struct input_event *)); | ||
| 4151 | static void x_scroll_bar_handle_drag P_ ((WindowPtr, struct scroll_bar *, | ||
| 4152 | Point, unsigned long, | ||
| 4153 | struct input_event *)); | ||
| 4154 | static void x_set_toolkit_scroll_bar_thumb P_ ((struct scroll_bar *, | ||
| 4155 | int, int, int)); | ||
| 4156 | |||
| 4157 | /* Last scroll bar part sent in x_scroll_bar_handle_*. */ | ||
| 4158 | |||
| 4159 | static int last_scroll_bar_part; | ||
| 4160 | |||
| 4161 | static EventLoopTimerRef scroll_bar_timer; | ||
| 4162 | |||
| 4163 | static int scroll_bar_timer_event_posted_p; | ||
| 4164 | |||
| 4165 | #define SCROLL_BAR_FIRST_DELAY 0.5 | ||
| 4166 | #define SCROLL_BAR_CONTINUOUS_DELAY (1.0 / 15) | ||
| 4167 | |||
| 4168 | static pascal void | ||
| 4169 | scroll_bar_timer_callback (timer, data) | ||
| 4170 | EventLoopTimerRef timer; | ||
| 4171 | void *data; | ||
| 4172 | { | ||
| 4173 | EventRef event = NULL; | ||
| 4174 | OSErr err; | ||
| 4175 | |||
| 4176 | err = CreateEvent (NULL, kEventClassMouse, kEventMouseMoved, 0, | ||
| 4177 | kEventAttributeNone, &event); | ||
| 4178 | if (err == noErr) | ||
| 4179 | { | ||
| 4180 | Point mouse_pos; | ||
| 4181 | |||
| 4182 | GetMouse (&mouse_pos); | ||
| 4183 | LocalToGlobal (&mouse_pos); | ||
| 4184 | err = SetEventParameter (event, kEventParamMouseLocation, typeQDPoint, | ||
| 4185 | sizeof (Point), &mouse_pos); | ||
| 4186 | } | ||
| 4187 | if (err == noErr) | ||
| 4188 | { | ||
| 4189 | UInt32 modifiers = GetCurrentKeyModifiers (); | ||
| 4190 | |||
| 4191 | err = SetEventParameter (event, kEventParamKeyModifiers, typeUInt32, | ||
| 4192 | sizeof (UInt32), &modifiers); | ||
| 4193 | } | ||
| 4194 | if (err == noErr) | ||
| 4195 | err = PostEventToQueue (GetCurrentEventQueue (), event, | ||
| 4196 | kEventPriorityStandard); | ||
| 4197 | if (err == noErr) | ||
| 4198 | scroll_bar_timer_event_posted_p = 1; | ||
| 4137 | 4199 | ||
| 4138 | /* Handle mouse button event on the tool-bar of frame F, at | 4200 | if (event) |
| 4139 | frame-relative coordinates X/Y. EVENT_TYPE is either ButtionPress | 4201 | ReleaseEvent (event); |
| 4140 | or ButtonRelase. */ | 4202 | } |
| 4203 | |||
| 4204 | static OSStatus | ||
| 4205 | install_scroll_bar_timer () | ||
| 4206 | { | ||
| 4207 | static EventLoopTimerUPP scroll_bar_timer_callbackUPP = NULL; | ||
| 4208 | |||
| 4209 | if (scroll_bar_timer_callbackUPP == NULL) | ||
| 4210 | scroll_bar_timer_callbackUPP = | ||
| 4211 | NewEventLoopTimerUPP (scroll_bar_timer_callback); | ||
| 4212 | |||
| 4213 | if (scroll_bar_timer == NULL) | ||
| 4214 | /* Mac OS X and CarbonLib 1.5 and later allow us to specify | ||
| 4215 | kEventDurationForever as delays. */ | ||
| 4216 | return | ||
| 4217 | InstallEventLoopTimer (GetCurrentEventLoop (), | ||
| 4218 | kEventDurationForever, kEventDurationForever, | ||
| 4219 | scroll_bar_timer_callbackUPP, NULL, | ||
| 4220 | &scroll_bar_timer); | ||
| 4221 | } | ||
| 4222 | |||
| 4223 | static OSStatus | ||
| 4224 | set_scroll_bar_timer (delay) | ||
| 4225 | EventTimerInterval delay; | ||
| 4226 | { | ||
| 4227 | if (scroll_bar_timer == NULL) | ||
| 4228 | install_scroll_bar_timer (); | ||
| 4229 | |||
| 4230 | scroll_bar_timer_event_posted_p = 0; | ||
| 4231 | |||
| 4232 | return SetEventLoopTimerNextFireTime (scroll_bar_timer, delay); | ||
| 4233 | } | ||
| 4234 | |||
| 4235 | static int | ||
| 4236 | control_part_code_to_scroll_bar_part (part_code) | ||
| 4237 | ControlPartCode part_code; | ||
| 4238 | { | ||
| 4239 | switch (part_code) | ||
| 4240 | { | ||
| 4241 | case kControlUpButtonPart: return scroll_bar_up_arrow; | ||
| 4242 | case kControlDownButtonPart: return scroll_bar_down_arrow; | ||
| 4243 | case kControlPageUpPart: return scroll_bar_above_handle; | ||
| 4244 | case kControlPageDownPart: return scroll_bar_below_handle; | ||
| 4245 | case kControlIndicatorPart: return scroll_bar_handle; | ||
| 4246 | } | ||
| 4247 | |||
| 4248 | return -1; | ||
| 4249 | } | ||
| 4141 | 4250 | ||
| 4142 | static void | 4251 | static void |
| 4143 | mac_handle_tool_bar_click (f, button_event) | 4252 | construct_scroll_bar_click (bar, part, timestamp, bufp) |
| 4144 | struct frame *f; | 4253 | struct scroll_bar *bar; |
| 4145 | EventRecord *button_event; | 4254 | int part; |
| 4255 | unsigned long timestamp; | ||
| 4256 | struct input_event *bufp; | ||
| 4257 | { | ||
| 4258 | bufp->kind = SCROLL_BAR_CLICK_EVENT; | ||
| 4259 | bufp->frame_or_window = bar->window; | ||
| 4260 | bufp->arg = Qnil; | ||
| 4261 | bufp->part = part; | ||
| 4262 | bufp->code = 0; | ||
| 4263 | bufp->timestamp = timestamp; | ||
| 4264 | XSETINT (bufp->x, 0); | ||
| 4265 | XSETINT (bufp->y, 0); | ||
| 4266 | bufp->modifiers = 0; | ||
| 4267 | } | ||
| 4268 | |||
| 4269 | static OSErr | ||
| 4270 | get_control_part_bound (ch, part_code, rect) | ||
| 4271 | ControlHandle ch; | ||
| 4272 | ControlPartCode part_code; | ||
| 4273 | Rect *rect; | ||
| 4274 | { | ||
| 4275 | RgnHandle region = NewRgn (); | ||
| 4276 | OSStatus err; | ||
| 4277 | |||
| 4278 | err = GetControlRegion (ch, part_code, region); | ||
| 4279 | if (err == noErr) | ||
| 4280 | GetRegionBounds (region, rect); | ||
| 4281 | DisposeRgn (region); | ||
| 4282 | |||
| 4283 | return err; | ||
| 4284 | } | ||
| 4285 | |||
| 4286 | static void | ||
| 4287 | x_scroll_bar_handle_press (bar, part_code, timestamp, bufp) | ||
| 4288 | struct scroll_bar *bar; | ||
| 4289 | ControlPartCode part_code; | ||
| 4290 | unsigned long timestamp; | ||
| 4291 | struct input_event *bufp; | ||
| 4292 | { | ||
| 4293 | int part = control_part_code_to_scroll_bar_part (part_code); | ||
| 4294 | |||
| 4295 | if (part < 0) | ||
| 4296 | return; | ||
| 4297 | |||
| 4298 | if (part != scroll_bar_handle) | ||
| 4299 | { | ||
| 4300 | construct_scroll_bar_click (bar, part, timestamp, bufp); | ||
| 4301 | HiliteControl (SCROLL_BAR_CONTROL_HANDLE (bar), part_code); | ||
| 4302 | set_scroll_bar_timer (SCROLL_BAR_FIRST_DELAY); | ||
| 4303 | } | ||
| 4304 | |||
| 4305 | last_scroll_bar_part = part; | ||
| 4306 | bar->dragging = Qnil; | ||
| 4307 | tracked_scroll_bar = bar; | ||
| 4308 | } | ||
| 4309 | |||
| 4310 | static void | ||
| 4311 | x_scroll_bar_handle_release (bar, timestamp, bufp) | ||
| 4312 | struct scroll_bar *bar; | ||
| 4313 | unsigned long timestamp; | ||
| 4314 | struct input_event *bufp; | ||
| 4315 | { | ||
| 4316 | if (last_scroll_bar_part != scroll_bar_handle | ||
| 4317 | || !GC_NILP (bar->dragging)) | ||
| 4318 | construct_scroll_bar_click (bar, scroll_bar_end_scroll, timestamp, bufp); | ||
| 4319 | |||
| 4320 | HiliteControl (SCROLL_BAR_CONTROL_HANDLE (bar), 0); | ||
| 4321 | set_scroll_bar_timer (kEventDurationForever); | ||
| 4322 | |||
| 4323 | last_scroll_bar_part = -1; | ||
| 4324 | bar->dragging = Qnil; | ||
| 4325 | tracked_scroll_bar = NULL; | ||
| 4326 | } | ||
| 4327 | |||
| 4328 | static void | ||
| 4329 | x_scroll_bar_handle_drag (win, bar, mouse_pos, timestamp, bufp) | ||
| 4330 | WindowPtr win; | ||
| 4331 | struct scroll_bar *bar; | ||
| 4332 | Point mouse_pos; | ||
| 4333 | unsigned long timestamp; | ||
| 4334 | struct input_event *bufp; | ||
| 4335 | { | ||
| 4336 | ControlHandle ch = SCROLL_BAR_CONTROL_HANDLE (bar); | ||
| 4337 | |||
| 4338 | if (last_scroll_bar_part == scroll_bar_handle) | ||
| 4339 | { | ||
| 4340 | int top, top_range; | ||
| 4341 | Rect r; | ||
| 4342 | |||
| 4343 | get_control_part_bound (SCROLL_BAR_CONTROL_HANDLE (bar), | ||
| 4344 | kControlIndicatorPart, &r); | ||
| 4345 | |||
| 4346 | if (GC_NILP (bar->dragging)) | ||
| 4347 | XSETINT (bar->dragging, mouse_pos.v - r.top); | ||
| 4348 | |||
| 4349 | top = mouse_pos.v - XINT (bar->dragging) - XINT (bar->track_top); | ||
| 4350 | top_range = (XINT (bar->track_height) - (r.bottom - r.top)) * | ||
| 4351 | (1.0 + (float) GetControlViewSize (ch) / GetControl32BitMaximum (ch)) | ||
| 4352 | + .5; | ||
| 4353 | |||
| 4354 | if (top < 0) | ||
| 4355 | top = 0; | ||
| 4356 | if (top > top_range) | ||
| 4357 | top = top_range; | ||
| 4358 | |||
| 4359 | construct_scroll_bar_click (bar, scroll_bar_handle, timestamp, bufp); | ||
| 4360 | XSETINT (bufp->x, top); | ||
| 4361 | XSETINT (bufp->y, top_range); | ||
| 4362 | } | ||
| 4363 | else | ||
| 4364 | { | ||
| 4365 | ControlPartCode part_code; | ||
| 4366 | int unhilite_p = 0, part; | ||
| 4367 | |||
| 4368 | if (ch != FindControlUnderMouse (mouse_pos, win, &part_code)) | ||
| 4369 | unhilite_p = 1; | ||
| 4370 | else | ||
| 4371 | { | ||
| 4372 | part = control_part_code_to_scroll_bar_part (part_code); | ||
| 4373 | |||
| 4374 | switch (last_scroll_bar_part) | ||
| 4375 | { | ||
| 4376 | case scroll_bar_above_handle: | ||
| 4377 | case scroll_bar_below_handle: | ||
| 4378 | if (part != scroll_bar_above_handle | ||
| 4379 | && part != scroll_bar_below_handle) | ||
| 4380 | unhilite_p = 1; | ||
| 4381 | break; | ||
| 4382 | |||
| 4383 | case scroll_bar_up_arrow: | ||
| 4384 | case scroll_bar_down_arrow: | ||
| 4385 | if (part != scroll_bar_up_arrow | ||
| 4386 | && part != scroll_bar_down_arrow) | ||
| 4387 | unhilite_p = 1; | ||
| 4388 | break; | ||
| 4389 | } | ||
| 4390 | } | ||
| 4391 | |||
| 4392 | if (unhilite_p) | ||
| 4393 | HiliteControl (SCROLL_BAR_CONTROL_HANDLE (bar), 0); | ||
| 4394 | else if (part != last_scroll_bar_part | ||
| 4395 | || scroll_bar_timer_event_posted_p) | ||
| 4396 | { | ||
| 4397 | construct_scroll_bar_click (bar, part, timestamp, bufp); | ||
| 4398 | last_scroll_bar_part = part; | ||
| 4399 | HiliteControl (SCROLL_BAR_CONTROL_HANDLE (bar), part_code); | ||
| 4400 | set_scroll_bar_timer (SCROLL_BAR_CONTINUOUS_DELAY); | ||
| 4401 | } | ||
| 4402 | } | ||
| 4403 | } | ||
| 4404 | |||
| 4405 | /* Set the thumb size and position of scroll bar BAR. We are currently | ||
| 4406 | displaying PORTION out of a whole WHOLE, and our position POSITION. */ | ||
| 4407 | |||
| 4408 | static void | ||
| 4409 | x_set_toolkit_scroll_bar_thumb (bar, portion, position, whole) | ||
| 4410 | struct scroll_bar *bar; | ||
| 4411 | int portion, position, whole; | ||
| 4146 | { | 4412 | { |
| 4147 | int x = button_event->where.h; | 4413 | ControlHandle ch = SCROLL_BAR_CONTROL_HANDLE (bar); |
| 4148 | int y = button_event->where.v; | ||
| 4149 | 4414 | ||
| 4150 | if (button_event->what == mouseDown) | 4415 | int value, viewsize, maximum; |
| 4151 | handle_tool_bar_click (f, x, y, 1, 0); | 4416 | |
| 4417 | if (whole == 0 || XINT (bar->track_height) == 0) | ||
| 4418 | value = 0, viewsize = 1, maximum = 0; | ||
| 4152 | else | 4419 | else |
| 4153 | handle_tool_bar_click (f, x, y, 0, | 4420 | { |
| 4154 | x_mac_to_emacs_modifiers (FRAME_MAC_DISPLAY_INFO (f), | 4421 | value = position; |
| 4155 | button_event->modifiers)); | 4422 | viewsize = portion; |
| 4423 | maximum = max (0, whole - portion); | ||
| 4424 | } | ||
| 4425 | |||
| 4426 | BLOCK_INPUT; | ||
| 4427 | |||
| 4428 | SetControl32BitMinimum (ch, 0); | ||
| 4429 | SetControl32BitMaximum (ch, maximum); | ||
| 4430 | SetControl32BitValue (ch, value); | ||
| 4431 | SetControlViewSize (ch, viewsize); | ||
| 4432 | |||
| 4433 | UNBLOCK_INPUT; | ||
| 4156 | } | 4434 | } |
| 4157 | 4435 | ||
| 4436 | #endif /* USE_TOOLKIT_SCROLL_BARS */ | ||
| 4437 | |||
| 4438 | |||
| 4158 | 4439 | ||
| 4159 | /************************************************************************ | 4440 | /************************************************************************ |
| 4160 | Scroll bars, general | 4441 | Scroll bars, general |
| @@ -4185,13 +4466,12 @@ x_scroll_bar_create (w, top, left, width, height, disp_top, disp_height) | |||
| 4185 | 4466 | ||
| 4186 | #if TARGET_API_MAC_CARBON | 4467 | #if TARGET_API_MAC_CARBON |
| 4187 | ch = NewControl (FRAME_MAC_WINDOW (f), &r, "\p", 1, 0, 0, 0, | 4468 | ch = NewControl (FRAME_MAC_WINDOW (f), &r, "\p", 1, 0, 0, 0, |
| 4188 | kControlScrollBarProc, 0L); | 4469 | kControlScrollBarProc, (long) bar); |
| 4189 | #else | 4470 | #else |
| 4190 | ch = NewControl (FRAME_MAC_WINDOW (f), &r, "\p", 1, 0, 0, 0, scrollBarProc, | 4471 | ch = NewControl (FRAME_MAC_WINDOW (f), &r, "\p", 1, 0, 0, 0, |
| 4191 | 0L); | 4472 | scrollBarProc, (long) bar); |
| 4192 | #endif | 4473 | #endif |
| 4193 | SET_SCROLL_BAR_CONTROL_HANDLE (bar, ch); | 4474 | SET_SCROLL_BAR_CONTROL_HANDLE (bar, ch); |
| 4194 | SetControlReference (ch, (long) bar); | ||
| 4195 | 4475 | ||
| 4196 | XSETWINDOW (bar->window, w); | 4476 | XSETWINDOW (bar->window, w); |
| 4197 | XSETINT (bar->top, top); | 4477 | XSETINT (bar->top, top); |
| @@ -4201,6 +4481,10 @@ x_scroll_bar_create (w, top, left, width, height, disp_top, disp_height) | |||
| 4201 | XSETINT (bar->start, 0); | 4481 | XSETINT (bar->start, 0); |
| 4202 | XSETINT (bar->end, 0); | 4482 | XSETINT (bar->end, 0); |
| 4203 | bar->dragging = Qnil; | 4483 | bar->dragging = Qnil; |
| 4484 | #ifdef USE_TOOLKIT_SCROLL_BARS | ||
| 4485 | bar->track_top = Qnil; | ||
| 4486 | bar->track_height = Qnil; | ||
| 4487 | #endif | ||
| 4204 | 4488 | ||
| 4205 | /* Add bar to its frame's list of scroll bars. */ | 4489 | /* Add bar to its frame's list of scroll bars. */ |
| 4206 | bar->next = FRAME_SCROLL_BARS (f); | 4490 | bar->next = FRAME_SCROLL_BARS (f); |
| @@ -4227,6 +4511,8 @@ x_scroll_bar_create (w, top, left, width, height, disp_top, disp_height) | |||
| 4227 | the bar's top is as far down as it goes; otherwise, there's no way | 4511 | the bar's top is as far down as it goes; otherwise, there's no way |
| 4228 | to move to the very end of the buffer. */ | 4512 | to move to the very end of the buffer. */ |
| 4229 | 4513 | ||
| 4514 | #ifndef USE_TOOLKIT_SCROLL_BARS | ||
| 4515 | |||
| 4230 | static void | 4516 | static void |
| 4231 | x_scroll_bar_set_handle (bar, start, end, rebuild) | 4517 | x_scroll_bar_set_handle (bar, start, end, rebuild) |
| 4232 | struct scroll_bar *bar; | 4518 | struct scroll_bar *bar; |
| @@ -4286,6 +4572,7 @@ x_scroll_bar_set_handle (bar, start, end, rebuild) | |||
| 4286 | UNBLOCK_INPUT; | 4572 | UNBLOCK_INPUT; |
| 4287 | } | 4573 | } |
| 4288 | 4574 | ||
| 4575 | #endif /* !USE_TOOLKIT_SCROLL_BARS */ | ||
| 4289 | 4576 | ||
| 4290 | /* Destroy scroll bar BAR, and set its Emacs window's scroll bar to | 4577 | /* Destroy scroll bar BAR, and set its Emacs window's scroll bar to |
| 4291 | nil. */ | 4578 | nil. */ |
| @@ -4324,11 +4611,7 @@ XTset_vertical_scroll_bar (w, portion, whole, position) | |||
| 4324 | /* Get window dimensions. */ | 4611 | /* Get window dimensions. */ |
| 4325 | window_box (w, -1, 0, &window_y, 0, &window_height); | 4612 | window_box (w, -1, 0, &window_y, 0, &window_height); |
| 4326 | top = window_y; | 4613 | top = window_y; |
| 4327 | #ifdef MAC_OSX | ||
| 4328 | width = 16; | ||
| 4329 | #else | ||
| 4330 | width = WINDOW_CONFIG_SCROLL_BAR_COLS (w) * FRAME_COLUMN_WIDTH (f); | 4614 | width = WINDOW_CONFIG_SCROLL_BAR_COLS (w) * FRAME_COLUMN_WIDTH (f); |
| 4331 | #endif | ||
| 4332 | height = window_height; | 4615 | height = window_height; |
| 4333 | 4616 | ||
| 4334 | /* Compute the left edge of the scroll bar area. */ | 4617 | /* Compute the left edge of the scroll bar area. */ |
| @@ -4343,9 +4626,9 @@ XTset_vertical_scroll_bar (w, portion, whole, position) | |||
| 4343 | 4626 | ||
| 4344 | /* Compute the left edge of the scroll bar. */ | 4627 | /* Compute the left edge of the scroll bar. */ |
| 4345 | if (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_RIGHT (w)) | 4628 | if (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_RIGHT (w)) |
| 4346 | sb_left = left + width - sb_width - (width - sb_width) / 2; | 4629 | sb_left = left; |
| 4347 | else | 4630 | else |
| 4348 | sb_left = left + (width - sb_width) / 2; | 4631 | sb_left = left + width - sb_width; |
| 4349 | 4632 | ||
| 4350 | /* Adjustments according to Inside Macintosh to make it look nice */ | 4633 | /* Adjustments according to Inside Macintosh to make it look nice */ |
| 4351 | disp_top = top; | 4634 | disp_top = top; |
| @@ -4418,11 +4701,44 @@ XTset_vertical_scroll_bar (w, portion, whole, position) | |||
| 4418 | XSETINT (bar->top, top); | 4701 | XSETINT (bar->top, top); |
| 4419 | XSETINT (bar->width, sb_width); | 4702 | XSETINT (bar->width, sb_width); |
| 4420 | XSETINT (bar->height, height); | 4703 | XSETINT (bar->height, height); |
| 4704 | #ifdef USE_TOOLKIT_SCROLL_BARS | ||
| 4705 | bar->track_top = Qnil; | ||
| 4706 | bar->track_height = Qnil; | ||
| 4707 | #endif | ||
| 4421 | } | 4708 | } |
| 4422 | 4709 | ||
| 4423 | UNBLOCK_INPUT; | 4710 | UNBLOCK_INPUT; |
| 4424 | } | 4711 | } |
| 4425 | 4712 | ||
| 4713 | #ifdef USE_TOOLKIT_SCROLL_BARS | ||
| 4714 | if (NILP (bar->track_top)) | ||
| 4715 | { | ||
| 4716 | ControlHandle ch = SCROLL_BAR_CONTROL_HANDLE (bar); | ||
| 4717 | Rect r0, r1; | ||
| 4718 | |||
| 4719 | BLOCK_INPUT; | ||
| 4720 | |||
| 4721 | SetControl32BitMinimum (ch, 0); | ||
| 4722 | SetControl32BitMaximum (ch, 1); | ||
| 4723 | SetControlViewSize (ch, 1); | ||
| 4724 | |||
| 4725 | /* Move the scroll bar thumb to the top. */ | ||
| 4726 | SetControl32BitValue (ch, 0); | ||
| 4727 | get_control_part_bound (ch, kControlIndicatorPart, &r0); | ||
| 4728 | |||
| 4729 | /* Move the scroll bar thumb to the bottom. */ | ||
| 4730 | SetControl32BitValue (ch, 1); | ||
| 4731 | get_control_part_bound (ch, kControlIndicatorPart, &r1); | ||
| 4732 | |||
| 4733 | UnionRect (&r0, &r1, &r0); | ||
| 4734 | XSETINT (bar->track_top, r0.top); | ||
| 4735 | XSETINT (bar->track_height, r0.bottom - r0.top); | ||
| 4736 | |||
| 4737 | UNBLOCK_INPUT; | ||
| 4738 | } | ||
| 4739 | |||
| 4740 | x_set_toolkit_scroll_bar_thumb (bar, portion, position, whole); | ||
| 4741 | #else /* not USE_TOOLKIT_SCROLL_BARS */ | ||
| 4426 | /* Set the scroll bar's current state, unless we're currently being | 4742 | /* Set the scroll bar's current state, unless we're currently being |
| 4427 | dragged. */ | 4743 | dragged. */ |
| 4428 | if (NILP (bar->dragging)) | 4744 | if (NILP (bar->dragging)) |
| @@ -4438,6 +4754,7 @@ XTset_vertical_scroll_bar (w, portion, whole, position) | |||
| 4438 | x_scroll_bar_set_handle (bar, start, end, 0); | 4754 | x_scroll_bar_set_handle (bar, start, end, 0); |
| 4439 | } | 4755 | } |
| 4440 | } | 4756 | } |
| 4757 | #endif /* not USE_TOOLKIT_SCROLL_BARS */ | ||
| 4441 | } | 4758 | } |
| 4442 | 4759 | ||
| 4443 | 4760 | ||
| @@ -4619,6 +4936,7 @@ x_scroll_bar_handle_click (bar, part_code, er, bufp) | |||
| 4619 | XSETINT (bufp->y, top_range); | 4936 | XSETINT (bufp->y, top_range); |
| 4620 | } | 4937 | } |
| 4621 | 4938 | ||
| 4939 | #ifndef USE_TOOLKIT_SCROLL_BARS | ||
| 4622 | 4940 | ||
| 4623 | /* Handle some mouse motion while someone is dragging the scroll bar. | 4941 | /* Handle some mouse motion while someone is dragging the scroll bar. |
| 4624 | 4942 | ||
| @@ -4653,6 +4971,7 @@ x_scroll_bar_note_movement (bar, y_pos, t) | |||
| 4653 | } | 4971 | } |
| 4654 | } | 4972 | } |
| 4655 | 4973 | ||
| 4974 | #endif /* !USE_TOOLKIT_SCROLL_BARS */ | ||
| 4656 | 4975 | ||
| 4657 | /* Return information to the user about the current position of the | 4976 | /* Return information to the user about the current position of the |
| 4658 | mouse on the scroll bar. */ | 4977 | mouse on the scroll bar. */ |
| @@ -8657,6 +8976,9 @@ XTread_socket (sd, expected, hold_quit) | |||
| 8657 | SInt16 control_part_code; | 8976 | SInt16 control_part_code; |
| 8658 | ControlHandle ch; | 8977 | ControlHandle ch; |
| 8659 | Point mouse_loc = er.where; | 8978 | Point mouse_loc = er.where; |
| 8979 | #ifdef MAC_OSX | ||
| 8980 | ControlKind control_kind; | ||
| 8981 | #endif | ||
| 8660 | 8982 | ||
| 8661 | f = mac_window_to_frame (window_ptr); | 8983 | f = mac_window_to_frame (window_ptr); |
| 8662 | /* convert to local coordinates of new window */ | 8984 | /* convert to local coordinates of new window */ |
| @@ -8666,6 +8988,10 @@ XTread_socket (sd, expected, hold_quit) | |||
| 8666 | #if TARGET_API_MAC_CARBON | 8988 | #if TARGET_API_MAC_CARBON |
| 8667 | ch = FindControlUnderMouse (mouse_loc, window_ptr, | 8989 | ch = FindControlUnderMouse (mouse_loc, window_ptr, |
| 8668 | &control_part_code); | 8990 | &control_part_code); |
| 8991 | #ifdef MAC_OSX | ||
| 8992 | if (ch) | ||
| 8993 | GetControlKind (ch, &control_kind); | ||
| 8994 | #endif | ||
| 8669 | #else | 8995 | #else |
| 8670 | control_part_code = FindControl (mouse_loc, window_ptr, | 8996 | control_part_code = FindControl (mouse_loc, window_ptr, |
| 8671 | &ch); | 8997 | &ch); |
| @@ -8684,19 +9010,42 @@ XTread_socket (sd, expected, hold_quit) | |||
| 8684 | /* ticks to milliseconds */ | 9010 | /* ticks to milliseconds */ |
| 8685 | 9011 | ||
| 8686 | if (dpyinfo->grabbed && tracked_scroll_bar | 9012 | if (dpyinfo->grabbed && tracked_scroll_bar |
| 9013 | || ch != 0 | ||
| 9014 | #ifndef USE_TOOLKIT_SCROLL_BARS | ||
| 8687 | /* control_part_code becomes kControlNoPart if | 9015 | /* control_part_code becomes kControlNoPart if |
| 8688 | a progress indicator is clicked. */ | 9016 | a progress indicator is clicked. */ |
| 8689 | || ch != 0 && control_part_code != kControlNoPart) | 9017 | && control_part_code != kControlNoPart |
| 9018 | #else /* USE_TOOLKIT_SCROLL_BARS */ | ||
| 9019 | #ifdef MAC_OSX | ||
| 9020 | && control_kind.kind == kControlKindScrollBar | ||
| 9021 | #endif /* MAC_OSX */ | ||
| 9022 | #endif /* USE_TOOLKIT_SCROLL_BARS */ | ||
| 9023 | ) | ||
| 8690 | { | 9024 | { |
| 8691 | struct scroll_bar *bar; | 9025 | struct scroll_bar *bar; |
| 8692 | 9026 | ||
| 8693 | if (dpyinfo->grabbed && tracked_scroll_bar) | 9027 | if (dpyinfo->grabbed && tracked_scroll_bar) |
| 8694 | { | 9028 | { |
| 8695 | bar = tracked_scroll_bar; | 9029 | bar = tracked_scroll_bar; |
| 9030 | #ifndef USE_TOOLKIT_SCROLL_BARS | ||
| 8696 | control_part_code = kControlIndicatorPart; | 9031 | control_part_code = kControlIndicatorPart; |
| 9032 | #endif | ||
| 8697 | } | 9033 | } |
| 8698 | else | 9034 | else |
| 8699 | bar = (struct scroll_bar *) GetControlReference (ch); | 9035 | bar = (struct scroll_bar *) GetControlReference (ch); |
| 9036 | #ifdef USE_TOOLKIT_SCROLL_BARS | ||
| 9037 | /* Make the "Ctrl-Mouse-2 splits window" work | ||
| 9038 | for toolkit scroll bars. */ | ||
| 9039 | if (er.modifiers & controlKey) | ||
| 9040 | x_scroll_bar_handle_click (bar, control_part_code, | ||
| 9041 | &er, &inev); | ||
| 9042 | else if (er.what == mouseDown) | ||
| 9043 | x_scroll_bar_handle_press (bar, control_part_code, | ||
| 9044 | inev.timestamp, &inev); | ||
| 9045 | else | ||
| 9046 | x_scroll_bar_handle_release (bar, inev.timestamp, | ||
| 9047 | &inev); | ||
| 9048 | #else /* not USE_TOOLKIT_SCROLL_BARS */ | ||
| 8700 | x_scroll_bar_handle_click (bar, control_part_code, | 9049 | x_scroll_bar_handle_click (bar, control_part_code, |
| 8701 | &er, &inev); | 9050 | &er, &inev); |
| 8702 | if (er.what == mouseDown | 9051 | if (er.what == mouseDown |
| @@ -8704,6 +9053,7 @@ XTread_socket (sd, expected, hold_quit) | |||
| 8704 | tracked_scroll_bar = bar; | 9053 | tracked_scroll_bar = bar; |
| 8705 | else | 9054 | else |
| 8706 | tracked_scroll_bar = NULL; | 9055 | tracked_scroll_bar = NULL; |
| 9056 | #endif /* not USE_TOOLKIT_SCROLL_BARS */ | ||
| 8707 | } | 9057 | } |
| 8708 | else | 9058 | else |
| 8709 | { | 9059 | { |
| @@ -8753,15 +9103,18 @@ XTread_socket (sd, expected, hold_quit) | |||
| 8753 | dpyinfo->grabbed &= ~(1 << inev.code); | 9103 | dpyinfo->grabbed &= ~(1 << inev.code); |
| 8754 | } | 9104 | } |
| 8755 | 9105 | ||
| 8756 | switch (er.what) | 9106 | #ifdef USE_TOOLKIT_SCROLL_BARS |
| 8757 | { | 9107 | if (inev.kind == MOUSE_CLICK_EVENT) |
| 8758 | case mouseDown: | 9108 | #endif |
| 8759 | inev.modifiers |= down_modifier; | 9109 | switch (er.what) |
| 8760 | break; | 9110 | { |
| 8761 | case mouseUp: | 9111 | case mouseDown: |
| 8762 | inev.modifiers |= up_modifier; | 9112 | inev.modifiers |= down_modifier; |
| 8763 | break; | 9113 | break; |
| 8764 | } | 9114 | case mouseUp: |
| 9115 | inev.modifiers |= up_modifier; | ||
| 9116 | break; | ||
| 9117 | } | ||
| 8765 | } | 9118 | } |
| 8766 | break; | 9119 | break; |
| 8767 | 9120 | ||
| @@ -8863,10 +9216,16 @@ XTread_socket (sd, expected, hold_quit) | |||
| 8863 | GlobalToLocal (&mouse_pos); | 9216 | GlobalToLocal (&mouse_pos); |
| 8864 | 9217 | ||
| 8865 | if (dpyinfo->grabbed && tracked_scroll_bar) | 9218 | if (dpyinfo->grabbed && tracked_scroll_bar) |
| 9219 | #ifdef USE_TOOLKIT_SCROLL_BARS | ||
| 9220 | x_scroll_bar_handle_drag (wp, tracked_scroll_bar, | ||
| 9221 | mouse_pos, er.when * (1000 / 60), | ||
| 9222 | &inev); | ||
| 9223 | #else /* not USE_TOOLKIT_SCROLL_BARS */ | ||
| 8866 | x_scroll_bar_note_movement (tracked_scroll_bar, | 9224 | x_scroll_bar_note_movement (tracked_scroll_bar, |
| 8867 | mouse_pos.v | 9225 | mouse_pos.v |
| 8868 | - XINT (tracked_scroll_bar->top), | 9226 | - XINT (tracked_scroll_bar->top), |
| 8869 | TickCount() * (1000 / 60)); | 9227 | er.when * (1000 / 60)); |
| 9228 | #endif /* not USE_TOOLKIT_SCROLL_BARS */ | ||
| 8870 | else | 9229 | else |
| 8871 | { | 9230 | { |
| 8872 | /* Generate SELECT_WINDOW_EVENTs when needed. */ | 9231 | /* Generate SELECT_WINDOW_EVENTs when needed. */ |
| @@ -8941,6 +9300,23 @@ XTread_socket (sd, expected, hold_quit) | |||
| 8941 | else | 9300 | else |
| 8942 | { | 9301 | { |
| 8943 | /* A window has been deactivated */ | 9302 | /* A window has been deactivated */ |
| 9303 | #if USE_TOOLKIT_SCROLL_BARS | ||
| 9304 | if (dpyinfo->grabbed && tracked_scroll_bar) | ||
| 9305 | { | ||
| 9306 | struct input_event event; | ||
| 9307 | |||
| 9308 | EVENT_INIT (event); | ||
| 9309 | event.kind = NO_EVENT; | ||
| 9310 | x_scroll_bar_handle_release (tracked_scroll_bar, | ||
| 9311 | er.when * (1000 / 60), | ||
| 9312 | &event); | ||
| 9313 | if (event.kind != NO_EVENT) | ||
| 9314 | { | ||
| 9315 | kbd_buffer_store_event_hold (&event, hold_quit); | ||
| 9316 | count++; | ||
| 9317 | } | ||
| 9318 | } | ||
| 9319 | #endif | ||
| 8944 | dpyinfo->grabbed = 0; | 9320 | dpyinfo->grabbed = 0; |
| 8945 | 9321 | ||
| 8946 | x_detect_focus_change (dpyinfo, &er, &inev); | 9322 | x_detect_focus_change (dpyinfo, &er, &inev); |
| @@ -9719,42 +10095,6 @@ mac_initialize () | |||
| 9719 | /* Try to use interrupt input; if we can't, then start polling. */ | 10095 | /* Try to use interrupt input; if we can't, then start polling. */ |
| 9720 | Fset_input_mode (Qt, Qnil, Qt, Qnil); | 10096 | Fset_input_mode (Qt, Qnil, Qt, Qnil); |
| 9721 | 10097 | ||
| 9722 | #ifdef USE_X_TOOLKIT | ||
| 9723 | XtToolkitInitialize (); | ||
| 9724 | Xt_app_con = XtCreateApplicationContext (); | ||
| 9725 | XtAppSetFallbackResources (Xt_app_con, Xt_default_resources); | ||
| 9726 | |||
| 9727 | /* Install an asynchronous timer that processes Xt timeout events | ||
| 9728 | every 0.1s. This is necessary because some widget sets use | ||
| 9729 | timeouts internally, for example the LessTif menu bar, or the | ||
| 9730 | Xaw3d scroll bar. When Xt timouts aren't processed, these | ||
| 9731 | widgets don't behave normally. */ | ||
| 9732 | { | ||
| 9733 | EMACS_TIME interval; | ||
| 9734 | EMACS_SET_SECS_USECS (interval, 0, 100000); | ||
| 9735 | start_atimer (ATIMER_CONTINUOUS, interval, x_process_timeouts, 0); | ||
| 9736 | } | ||
| 9737 | #endif | ||
| 9738 | |||
| 9739 | #if USE_TOOLKIT_SCROLL_BARS | ||
| 9740 | xaw3d_arrow_scroll = False; | ||
| 9741 | xaw3d_pick_top = True; | ||
| 9742 | #endif | ||
| 9743 | |||
| 9744 | #if 0 | ||
| 9745 | /* Note that there is no real way portable across R3/R4 to get the | ||
| 9746 | original error handler. */ | ||
| 9747 | XSetErrorHandler (x_error_handler); | ||
| 9748 | XSetIOErrorHandler (x_io_error_quitter); | ||
| 9749 | |||
| 9750 | /* Disable Window Change signals; they are handled by X events. */ | ||
| 9751 | #ifdef SIGWINCH | ||
| 9752 | signal (SIGWINCH, SIG_DFL); | ||
| 9753 | #endif /* ! defined (SIGWINCH) */ | ||
| 9754 | |||
| 9755 | signal (SIGPIPE, x_connection_signal); | ||
| 9756 | #endif | ||
| 9757 | |||
| 9758 | BLOCK_INPUT; | 10098 | BLOCK_INPUT; |
| 9759 | 10099 | ||
| 9760 | #if TARGET_API_MAC_CARBON | 10100 | #if TARGET_API_MAC_CARBON |
| @@ -9831,7 +10171,11 @@ syms_of_macterm () | |||
| 9831 | 10171 | ||
| 9832 | DEFVAR_LISP ("x-toolkit-scroll-bars", &Vx_toolkit_scroll_bars, | 10172 | DEFVAR_LISP ("x-toolkit-scroll-bars", &Vx_toolkit_scroll_bars, |
| 9833 | doc: /* If not nil, Emacs uses toolkit scroll bars. */); | 10173 | doc: /* If not nil, Emacs uses toolkit scroll bars. */); |
| 10174 | #ifdef USE_TOOLKIT_SCROLL_BARS | ||
| 9834 | Vx_toolkit_scroll_bars = Qt; | 10175 | Vx_toolkit_scroll_bars = Qt; |
| 10176 | #else | ||
| 10177 | Vx_toolkit_scroll_bars = Qnil; | ||
| 10178 | #endif | ||
| 9835 | 10179 | ||
| 9836 | DEFVAR_BOOL ("x-use-underline-position-properties", | 10180 | DEFVAR_BOOL ("x-use-underline-position-properties", |
| 9837 | &x_use_underline_position_properties, | 10181 | &x_use_underline_position_properties, |