diff options
| author | Alan Third | 2016-05-01 13:04:07 +0200 |
|---|---|---|
| committer | Martin Rudalics | 2016-05-01 13:04:07 +0200 |
| commit | e683a2570be6f2e4f8defa4e7ee35a7d87f18918 (patch) | |
| tree | 0b749572bb70a6222d333d932bda7a29b18e5729 /src | |
| parent | 80a1e3b9b58aaeb71913737e07bb305d9eb54437 (diff) | |
| download | emacs-e683a2570be6f2e4f8defa4e7ee35a7d87f18918.tar.gz emacs-e683a2570be6f2e4f8defa4e7ee35a7d87f18918.zip | |
Implement horizontal scroll bars on NS
* lisp/scroll-bar.el (horizontal-scroll-bars-available-p): Remove NS
check.
* lisp/term/ns-win.el: Remove custom NS scroll-bar handlers and bind
scroll-bar mouse clicks to standard handlers.
* src/nsterm.h (EmacsScroller): Add 'horizontal' property and rename
pixel_height to pixel_length.
* src/nsterm.m (x_set_window_size): Remove left-hand scroll-bar code. It
caused scroll-bars to be over-drawn and the best working solution
appears to be complete removal.
(ns_set_horizontal_scroll_bar): Rewrite to handle horizontal scrollers
correctly.
(ns_set_vertical_scroll_bar): Set width to actual scroller width.
(setFrame): Handle horizontal case.
(dealloc): Handle horizontal case.
(judge): Handle horizontal case.
(setPosition): Rename pixel_height to pixel_length.
(sendScrollEventAtLoc): Handle horizontal case.
(mouseDown): Handle horizontal case and general tidy up of code.
(mouseDragged): Handle horizontal case. Call sendScrollEventAtLoc with
absolute pixel size instead of ratio.
* src/window.h: Remove NS check.
Diffstat (limited to 'src')
| -rw-r--r-- | src/nsterm.h | 4 | ||||
| -rw-r--r-- | src/nsterm.m | 201 | ||||
| -rw-r--r-- | src/window.h | 2 |
3 files changed, 118 insertions, 89 deletions
diff --git a/src/nsterm.h b/src/nsterm.h index 0aea9cca112..6cad337f3f8 100644 --- a/src/nsterm.h +++ b/src/nsterm.h | |||
| @@ -676,11 +676,13 @@ char const * nstrace_fullscreen_type_name (int); | |||
| 676 | /* offset to the bottom of knob of last mouse down */ | 676 | /* offset to the bottom of knob of last mouse down */ |
| 677 | CGFloat last_mouse_offset; | 677 | CGFloat last_mouse_offset; |
| 678 | float min_portion; | 678 | float min_portion; |
| 679 | int pixel_height; | 679 | int pixel_length; |
| 680 | enum scroll_bar_part last_hit_part; | 680 | enum scroll_bar_part last_hit_part; |
| 681 | 681 | ||
| 682 | BOOL condemned; | 682 | BOOL condemned; |
| 683 | 683 | ||
| 684 | BOOL horizontal; | ||
| 685 | |||
| 684 | /* optimize against excessive positioning calls generated by emacs */ | 686 | /* optimize against excessive positioning calls generated by emacs */ |
| 685 | int em_position; | 687 | int em_position; |
| 686 | int em_portion; | 688 | int em_portion; |
diff --git a/src/nsterm.m b/src/nsterm.m index 34c5395b630..1d48c041bad 100644 --- a/src/nsterm.m +++ b/src/nsterm.m | |||
| @@ -1801,23 +1801,6 @@ x_set_window_size (struct frame *f, | |||
| 1801 | 1801 | ||
| 1802 | [window setFrame: wr display: YES]; | 1802 | [window setFrame: wr display: YES]; |
| 1803 | 1803 | ||
| 1804 | /* This is a trick to compensate for Emacs' managing the scrollbar area | ||
| 1805 | as a fixed number of standard character columns. Instead of leaving | ||
| 1806 | blank space for the extra, we chopped it off above. Now for | ||
| 1807 | left-hand scrollbars, we shift all rendering to the left by the | ||
| 1808 | difference between the real width and Emacs' imagined one. For | ||
| 1809 | right-hand bars, don't worry about it since the extra is never used. | ||
| 1810 | (Obviously doesn't work for vertically split windows tho..) */ | ||
| 1811 | { | ||
| 1812 | NSPoint origin = FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f) | ||
| 1813 | ? NSMakePoint (FRAME_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f) | ||
| 1814 | - NS_SCROLL_BAR_WIDTH (f), 0) | ||
| 1815 | : NSMakePoint (0, 0); | ||
| 1816 | |||
| 1817 | [view setFrame: NSMakeRect (0, 0, pixelwidth, pixelheight)]; | ||
| 1818 | [view setBoundsOrigin: origin]; | ||
| 1819 | } | ||
| 1820 | |||
| 1821 | [view updateFrameSize: NO]; | 1804 | [view updateFrameSize: NO]; |
| 1822 | unblock_input (); | 1805 | unblock_input (); |
| 1823 | } | 1806 | } |
| @@ -4351,7 +4334,7 @@ ns_set_vertical_scroll_bar (struct window *window, | |||
| 4351 | window_box (window, ANY_AREA, 0, &window_y, 0, &window_height); | 4334 | window_box (window, ANY_AREA, 0, &window_y, 0, &window_height); |
| 4352 | top = window_y; | 4335 | top = window_y; |
| 4353 | height = window_height; | 4336 | height = window_height; |
| 4354 | width = WINDOW_CONFIG_SCROLL_BAR_COLS (window) * FRAME_COLUMN_WIDTH (f); | 4337 | width = NS_SCROLL_BAR_WIDTH (f); |
| 4355 | left = WINDOW_SCROLL_BAR_AREA_X (window); | 4338 | left = WINDOW_SCROLL_BAR_AREA_X (window); |
| 4356 | 4339 | ||
| 4357 | r = NSMakeRect (left, top, width, height); | 4340 | r = NSMakeRect (left, top, width, height); |
| @@ -4442,34 +4425,20 @@ ns_set_horizontal_scroll_bar (struct window *window, | |||
| 4442 | NSTRACE ("ns_set_horizontal_scroll_bar"); | 4425 | NSTRACE ("ns_set_horizontal_scroll_bar"); |
| 4443 | 4426 | ||
| 4444 | /* Get dimensions. */ | 4427 | /* Get dimensions. */ |
| 4445 | window_box (window, ANY_AREA, 0, &window_x, &window_width, 0); | 4428 | window_box (window, ANY_AREA, &window_x, 0, &window_width, 0); |
| 4446 | left = window_x; | 4429 | left = window_x; |
| 4447 | width = window_width; | 4430 | width = window_width; |
| 4448 | height = WINDOW_CONFIG_SCROLL_BAR_LINES (window) * FRAME_LINE_HEIGHT (f); | 4431 | height = NS_SCROLL_BAR_HEIGHT (f); |
| 4449 | top = WINDOW_SCROLL_BAR_AREA_Y (window); | 4432 | top = WINDOW_SCROLL_BAR_AREA_Y (window); |
| 4450 | 4433 | ||
| 4451 | r = NSMakeRect (left, top, width, height); | 4434 | r = NSMakeRect (left, top, width, height); |
| 4452 | /* the parent view is flipped, so we need to flip y value */ | 4435 | /* the parent view is flipped, so we need to flip y value */ |
| 4453 | v = [view frame]; | 4436 | v = [view frame]; |
| 4454 | /* ??????? PXW/scrollbars !!!!!!!!!!!!!!!!!!!! */ | ||
| 4455 | r.origin.y = (v.size.height - r.size.height - r.origin.y); | 4437 | r.origin.y = (v.size.height - r.size.height - r.origin.y); |
| 4456 | 4438 | ||
| 4457 | XSETWINDOW (win, window); | 4439 | XSETWINDOW (win, window); |
| 4458 | block_input (); | 4440 | block_input (); |
| 4459 | 4441 | ||
| 4460 | if (WINDOW_TOTAL_COLS (window) < 5) | ||
| 4461 | { | ||
| 4462 | if (!NILP (window->horizontal_scroll_bar)) | ||
| 4463 | { | ||
| 4464 | bar = XNS_SCROLL_BAR (window->horizontal_scroll_bar); | ||
| 4465 | [bar removeFromSuperview]; | ||
| 4466 | wset_horizontal_scroll_bar (window, Qnil); | ||
| 4467 | } | ||
| 4468 | ns_clear_frame_area (f, left, top, width, height); | ||
| 4469 | unblock_input (); | ||
| 4470 | return; | ||
| 4471 | } | ||
| 4472 | |||
| 4473 | if (NILP (window->horizontal_scroll_bar)) | 4442 | if (NILP (window->horizontal_scroll_bar)) |
| 4474 | { | 4443 | { |
| 4475 | if (width > 0 && height > 0) | 4444 | if (width > 0 && height > 0) |
| @@ -4484,16 +4453,22 @@ ns_set_horizontal_scroll_bar (struct window *window, | |||
| 4484 | NSRect oldRect; | 4453 | NSRect oldRect; |
| 4485 | bar = XNS_SCROLL_BAR (window->horizontal_scroll_bar); | 4454 | bar = XNS_SCROLL_BAR (window->horizontal_scroll_bar); |
| 4486 | oldRect = [bar frame]; | 4455 | oldRect = [bar frame]; |
| 4487 | r.size.width = oldRect.size.width; | ||
| 4488 | if (FRAME_LIVE_P (f) && !NSEqualRects (oldRect, r)) | 4456 | if (FRAME_LIVE_P (f) && !NSEqualRects (oldRect, r)) |
| 4489 | { | 4457 | { |
| 4490 | if (oldRect.origin.x != r.origin.x) | 4458 | if (oldRect.origin.y != r.origin.y) |
| 4491 | ns_clear_frame_area (f, left, top, width, height); | 4459 | ns_clear_frame_area (f, left, top, width, height); |
| 4492 | [bar setFrame: r]; | 4460 | [bar setFrame: r]; |
| 4493 | update_p = YES; | 4461 | update_p = YES; |
| 4494 | } | 4462 | } |
| 4495 | } | 4463 | } |
| 4496 | 4464 | ||
| 4465 | /* If there are both horizontal and vertical scroll-bars they leave | ||
| 4466 | a square that belongs to neither. We need to clear it otherwise | ||
| 4467 | it fills with junk. */ | ||
| 4468 | if (!NILP (window->vertical_scroll_bar)) | ||
| 4469 | ns_clear_frame_area (f, WINDOW_SCROLL_BAR_AREA_X (window), top, | ||
| 4470 | NS_SCROLL_BAR_HEIGHT (f), height); | ||
| 4471 | |||
| 4497 | if (update_p) | 4472 | if (update_p) |
| 4498 | [bar setPosition: position portion: portion whole: whole]; | 4473 | [bar setPosition: position portion: portion whole: whole]; |
| 4499 | unblock_input (); | 4474 | unblock_input (); |
| @@ -4531,13 +4506,15 @@ ns_redeem_scroll_bar (struct window *window) | |||
| 4531 | { | 4506 | { |
| 4532 | id bar; | 4507 | id bar; |
| 4533 | NSTRACE ("ns_redeem_scroll_bar"); | 4508 | NSTRACE ("ns_redeem_scroll_bar"); |
| 4534 | if (!NILP (window->vertical_scroll_bar)) | 4509 | if (!NILP (window->vertical_scroll_bar) |
| 4510 | && WINDOW_HAS_VERTICAL_SCROLL_BAR (window)) | ||
| 4535 | { | 4511 | { |
| 4536 | bar = XNS_SCROLL_BAR (window->vertical_scroll_bar); | 4512 | bar = XNS_SCROLL_BAR (window->vertical_scroll_bar); |
| 4537 | [bar reprieve]; | 4513 | [bar reprieve]; |
| 4538 | } | 4514 | } |
| 4539 | 4515 | ||
| 4540 | if (!NILP (window->horizontal_scroll_bar)) | 4516 | if (!NILP (window->horizontal_scroll_bar) |
| 4517 | && WINDOW_HAS_HORIZONTAL_SCROLL_BAR (window)) | ||
| 4541 | { | 4518 | { |
| 4542 | bar = XNS_SCROLL_BAR (window->horizontal_scroll_bar); | 4519 | bar = XNS_SCROLL_BAR (window->horizontal_scroll_bar); |
| 4543 | [bar reprieve]; | 4520 | [bar reprieve]; |
| @@ -8110,12 +8087,15 @@ not_in_argv (NSString *arg) | |||
| 8110 | return r; | 8087 | return r; |
| 8111 | } | 8088 | } |
| 8112 | 8089 | ||
| 8113 | |||
| 8114 | - initFrame: (NSRect )r window: (Lisp_Object)nwin | 8090 | - initFrame: (NSRect )r window: (Lisp_Object)nwin |
| 8115 | { | 8091 | { |
| 8116 | NSTRACE ("[EmacsScroller initFrame: window:]"); | 8092 | NSTRACE ("[EmacsScroller initFrame: window:]"); |
| 8117 | 8093 | ||
| 8118 | r.size.width = [EmacsScroller scrollerWidth]; | 8094 | if (r.size.width > r.size.height) |
| 8095 | horizontal = YES; | ||
| 8096 | else | ||
| 8097 | horizontal = NO; | ||
| 8098 | |||
| 8119 | [super initWithFrame: r/*NSMakeRect (0, 0, 0, 0)*/]; | 8099 | [super initWithFrame: r/*NSMakeRect (0, 0, 0, 0)*/]; |
| 8120 | [self setContinuous: YES]; | 8100 | [self setContinuous: YES]; |
| 8121 | [self setEnabled: YES]; | 8101 | [self setEnabled: YES]; |
| @@ -8131,9 +8111,12 @@ not_in_argv (NSString *arg) | |||
| 8131 | 8111 | ||
| 8132 | window = XWINDOW (nwin); | 8112 | window = XWINDOW (nwin); |
| 8133 | condemned = NO; | 8113 | condemned = NO; |
| 8134 | pixel_height = NSHeight (r); | 8114 | if (horizontal) |
| 8135 | if (pixel_height == 0) pixel_height = 1; | 8115 | pixel_length = NSWidth (r); |
| 8136 | min_portion = 20 / pixel_height; | 8116 | else |
| 8117 | pixel_length = NSHeight (r); | ||
| 8118 | if (pixel_length == 0) pixel_length = 1; | ||
| 8119 | min_portion = 20 / pixel_length; | ||
| 8137 | 8120 | ||
| 8138 | frame = XFRAME (window->frame); | 8121 | frame = XFRAME (window->frame); |
| 8139 | if (FRAME_LIVE_P (frame)) | 8122 | if (FRAME_LIVE_P (frame)) |
| @@ -8162,9 +8145,12 @@ not_in_argv (NSString *arg) | |||
| 8162 | NSTRACE ("[EmacsScroller setFrame:]"); | 8145 | NSTRACE ("[EmacsScroller setFrame:]"); |
| 8163 | 8146 | ||
| 8164 | /* block_input (); */ | 8147 | /* block_input (); */ |
| 8165 | pixel_height = NSHeight (newRect); | 8148 | if (horizontal) |
| 8166 | if (pixel_height == 0) pixel_height = 1; | 8149 | pixel_length = NSWidth (newRect); |
| 8167 | min_portion = 20 / pixel_height; | 8150 | else |
| 8151 | pixel_length = NSHeight (newRect); | ||
| 8152 | if (pixel_length == 0) pixel_length = 1; | ||
| 8153 | min_portion = 20 / pixel_length; | ||
| 8168 | [super setFrame: newRect]; | 8154 | [super setFrame: newRect]; |
| 8169 | /* unblock_input (); */ | 8155 | /* unblock_input (); */ |
| 8170 | } | 8156 | } |
| @@ -8174,7 +8160,12 @@ not_in_argv (NSString *arg) | |||
| 8174 | { | 8160 | { |
| 8175 | NSTRACE ("[EmacsScroller dealloc]"); | 8161 | NSTRACE ("[EmacsScroller dealloc]"); |
| 8176 | if (window) | 8162 | if (window) |
| 8177 | wset_vertical_scroll_bar (window, Qnil); | 8163 | { |
| 8164 | if (horizontal) | ||
| 8165 | wset_horizontal_scroll_bar (window, Qnil); | ||
| 8166 | else | ||
| 8167 | wset_vertical_scroll_bar (window, Qnil); | ||
| 8168 | } | ||
| 8178 | window = 0; | 8169 | window = 0; |
| 8179 | [super dealloc]; | 8170 | [super dealloc]; |
| 8180 | } | 8171 | } |
| @@ -8209,7 +8200,12 @@ not_in_argv (NSString *arg) | |||
| 8209 | if (view != nil) | 8200 | if (view != nil) |
| 8210 | view->scrollbarsNeedingUpdate++; | 8201 | view->scrollbarsNeedingUpdate++; |
| 8211 | if (window) | 8202 | if (window) |
| 8212 | wset_vertical_scroll_bar (window, Qnil); | 8203 | { |
| 8204 | if (horizontal) | ||
| 8205 | wset_horizontal_scroll_bar (window, Qnil); | ||
| 8206 | else | ||
| 8207 | wset_vertical_scroll_bar (window, Qnil); | ||
| 8208 | } | ||
| 8213 | window = 0; | 8209 | window = 0; |
| 8214 | [self removeFromSuperview]; | 8210 | [self removeFromSuperview]; |
| 8215 | [self release]; | 8211 | [self release]; |
| @@ -8259,7 +8255,7 @@ not_in_argv (NSString *arg) | |||
| 8259 | { | 8255 | { |
| 8260 | float pos; | 8256 | float pos; |
| 8261 | CGFloat por; | 8257 | CGFloat por; |
| 8262 | portion = max ((float)whole*min_portion/pixel_height, portion); | 8258 | portion = max ((float)whole*min_portion/pixel_length, portion); |
| 8263 | pos = (float)position / (whole - portion); | 8259 | pos = (float)position / (whole - portion); |
| 8264 | por = (CGFloat)portion/whole; | 8260 | por = (CGFloat)portion/whole; |
| 8265 | #ifdef NS_IMPL_COCOA | 8261 | #ifdef NS_IMPL_COCOA |
| @@ -8289,10 +8285,20 @@ not_in_argv (NSString *arg) | |||
| 8289 | XSETWINDOW (win, window); | 8285 | XSETWINDOW (win, window); |
| 8290 | emacs_event->frame_or_window = win; | 8286 | emacs_event->frame_or_window = win; |
| 8291 | emacs_event->timestamp = EV_TIMESTAMP (e); | 8287 | emacs_event->timestamp = EV_TIMESTAMP (e); |
| 8292 | emacs_event->kind = SCROLL_BAR_CLICK_EVENT; | ||
| 8293 | emacs_event->arg = Qnil; | 8288 | emacs_event->arg = Qnil; |
| 8294 | XSETINT (emacs_event->x, loc * pixel_height); | 8289 | |
| 8295 | XSETINT (emacs_event->y, pixel_height-20); | 8290 | if (horizontal) |
| 8291 | { | ||
| 8292 | emacs_event->kind = HORIZONTAL_SCROLL_BAR_CLICK_EVENT; | ||
| 8293 | XSETINT (emacs_event->x, em_whole * loc / pixel_length); | ||
| 8294 | XSETINT (emacs_event->y, em_whole); | ||
| 8295 | } | ||
| 8296 | else | ||
| 8297 | { | ||
| 8298 | emacs_event->kind = SCROLL_BAR_CLICK_EVENT; | ||
| 8299 | XSETINT (emacs_event->x, loc); | ||
| 8300 | XSETINT (emacs_event->y, pixel_length-20); | ||
| 8301 | } | ||
| 8296 | 8302 | ||
| 8297 | if (q_event_ptr) | 8303 | if (q_event_ptr) |
| 8298 | { | 8304 | { |
| @@ -8355,15 +8361,15 @@ not_in_argv (NSString *arg) | |||
| 8355 | switch (part) | 8361 | switch (part) |
| 8356 | { | 8362 | { |
| 8357 | case NSScrollerDecrementPage: | 8363 | case NSScrollerDecrementPage: |
| 8358 | last_hit_part = scroll_bar_above_handle; inc = -1.0; break; | 8364 | last_hit_part = horizontal ? scroll_bar_before_handle : scroll_bar_above_handle; break; |
| 8359 | case NSScrollerIncrementPage: | 8365 | case NSScrollerIncrementPage: |
| 8360 | last_hit_part = scroll_bar_below_handle; inc = 1.0; break; | 8366 | last_hit_part = horizontal ? scroll_bar_after_handle : scroll_bar_below_handle; break; |
| 8361 | case NSScrollerDecrementLine: | 8367 | case NSScrollerDecrementLine: |
| 8362 | last_hit_part = scroll_bar_up_arrow; inc = -0.1; break; | 8368 | last_hit_part = horizontal ? scroll_bar_left_arrow : scroll_bar_up_arrow; break; |
| 8363 | case NSScrollerIncrementLine: | 8369 | case NSScrollerIncrementLine: |
| 8364 | last_hit_part = scroll_bar_down_arrow; inc = 0.1; break; | 8370 | last_hit_part = horizontal ? scroll_bar_right_arrow : scroll_bar_down_arrow; break; |
| 8365 | case NSScrollerKnob: | 8371 | case NSScrollerKnob: |
| 8366 | last_hit_part = scroll_bar_handle; break; | 8372 | last_hit_part = horizontal ? scroll_bar_horizontal_handle : scroll_bar_handle; break; |
| 8367 | case NSScrollerKnobSlot: /* GNUstep-only */ | 8373 | case NSScrollerKnobSlot: /* GNUstep-only */ |
| 8368 | last_hit_part = scroll_bar_move_ratio; break; | 8374 | last_hit_part = scroll_bar_move_ratio; break; |
| 8369 | default: /* NSScrollerNoPart? */ | 8375 | default: /* NSScrollerNoPart? */ |
| @@ -8372,36 +8378,34 @@ not_in_argv (NSString *arg) | |||
| 8372 | return; | 8378 | return; |
| 8373 | } | 8379 | } |
| 8374 | 8380 | ||
| 8375 | if (inc != 0.0) | 8381 | if (part == NSScrollerKnob || part == NSScrollerKnobSlot) |
| 8376 | { | ||
| 8377 | pos = 0; /* ignored */ | ||
| 8378 | |||
| 8379 | /* set a timer to repeat, as we can't let superclass do this modally */ | ||
| 8380 | scroll_repeat_entry | ||
| 8381 | = [[NSTimer scheduledTimerWithTimeInterval: SCROLL_BAR_FIRST_DELAY | ||
| 8382 | target: self | ||
| 8383 | selector: @selector (repeatScroll:) | ||
| 8384 | userInfo: 0 | ||
| 8385 | repeats: YES] | ||
| 8386 | retain]; | ||
| 8387 | } | ||
| 8388 | else | ||
| 8389 | { | 8382 | { |
| 8390 | /* handle, or on GNUstep possibly slot */ | 8383 | /* handle, or on GNUstep possibly slot */ |
| 8391 | NSEvent *fake_event; | 8384 | NSEvent *fake_event; |
| 8385 | int length; | ||
| 8392 | 8386 | ||
| 8393 | /* compute float loc in slot and mouse offset on knob */ | 8387 | /* compute float loc in slot and mouse offset on knob */ |
| 8394 | sr = [self convertRect: [self rectForPart: NSScrollerKnobSlot] | 8388 | sr = [self convertRect: [self rectForPart: NSScrollerKnobSlot] |
| 8395 | toView: nil]; | 8389 | toView: nil]; |
| 8396 | loc = NSHeight (sr) - ([e locationInWindow].y - NSMinY (sr)); | 8390 | if (horizontal) |
| 8391 | { | ||
| 8392 | length = NSWidth (sr); | ||
| 8393 | loc = ([e locationInWindow].x - NSMinX (sr)); | ||
| 8394 | } | ||
| 8395 | else | ||
| 8396 | { | ||
| 8397 | length = NSHeight (sr); | ||
| 8398 | loc = length - ([e locationInWindow].y - NSMinY (sr)); | ||
| 8399 | } | ||
| 8400 | |||
| 8397 | if (loc <= 0.0) | 8401 | if (loc <= 0.0) |
| 8398 | { | 8402 | { |
| 8399 | loc = 0.0; | 8403 | loc = 0.0; |
| 8400 | edge = -1; | 8404 | edge = -1; |
| 8401 | } | 8405 | } |
| 8402 | else if (loc >= NSHeight (sr)) | 8406 | else if (loc >= length) |
| 8403 | { | 8407 | { |
| 8404 | loc = NSHeight (sr); | 8408 | loc = length; |
| 8405 | edge = 1; | 8409 | edge = 1; |
| 8406 | } | 8410 | } |
| 8407 | 8411 | ||
| @@ -8411,17 +8415,16 @@ not_in_argv (NSString *arg) | |||
| 8411 | { | 8415 | { |
| 8412 | kr = [self convertRect: [self rectForPart: NSScrollerKnob] | 8416 | kr = [self convertRect: [self rectForPart: NSScrollerKnob] |
| 8413 | toView: nil]; | 8417 | toView: nil]; |
| 8414 | kloc = NSHeight (kr) - ([e locationInWindow].y - NSMinY (kr)); | 8418 | if (horizontal) |
| 8419 | kloc = ([e locationInWindow].x - NSMinX (kr)); | ||
| 8420 | else | ||
| 8421 | kloc = NSHeight (kr) - ([e locationInWindow].y - NSMinY (kr)); | ||
| 8415 | } | 8422 | } |
| 8416 | last_mouse_offset = kloc; | 8423 | last_mouse_offset = kloc; |
| 8417 | 8424 | ||
| 8418 | /* if knob, tell emacs a location offset by knob pos | 8425 | if (part != NSScrollerKnob) |
| 8419 | (to indicate top of handle) */ | 8426 | /* this is a slot click on GNUstep: go straight there */ |
| 8420 | if (part == NSScrollerKnob) | 8427 | pos = loc; |
| 8421 | pos = (loc - last_mouse_offset) / NSHeight (sr); | ||
| 8422 | else | ||
| 8423 | /* else this is a slot click on GNUstep: go straight there */ | ||
| 8424 | pos = loc / NSHeight (sr); | ||
| 8425 | 8428 | ||
| 8426 | /* send a fake mouse-up to super to preempt modal -trackKnob: mode */ | 8429 | /* send a fake mouse-up to super to preempt modal -trackKnob: mode */ |
| 8427 | fake_event = [NSEvent mouseEventWithType: NSLeftMouseUp | 8430 | fake_event = [NSEvent mouseEventWithType: NSLeftMouseUp |
| @@ -8435,6 +8438,19 @@ not_in_argv (NSString *arg) | |||
| 8435 | pressure: [e pressure]]; | 8438 | pressure: [e pressure]]; |
| 8436 | [super mouseUp: fake_event]; | 8439 | [super mouseUp: fake_event]; |
| 8437 | } | 8440 | } |
| 8441 | else | ||
| 8442 | { | ||
| 8443 | pos = 0; /* ignored */ | ||
| 8444 | |||
| 8445 | /* set a timer to repeat, as we can't let superclass do this modally */ | ||
| 8446 | scroll_repeat_entry | ||
| 8447 | = [[NSTimer scheduledTimerWithTimeInterval: SCROLL_BAR_FIRST_DELAY | ||
| 8448 | target: self | ||
| 8449 | selector: @selector (repeatScroll:) | ||
| 8450 | userInfo: 0 | ||
| 8451 | repeats: YES] | ||
| 8452 | retain]; | ||
| 8453 | } | ||
| 8438 | 8454 | ||
| 8439 | if (part != NSScrollerKnob) | 8455 | if (part != NSScrollerKnob) |
| 8440 | [self sendScrollEventAtLoc: pos fromEvent: e]; | 8456 | [self sendScrollEventAtLoc: pos fromEvent: e]; |
| @@ -8446,23 +8462,34 @@ not_in_argv (NSString *arg) | |||
| 8446 | { | 8462 | { |
| 8447 | NSRect sr; | 8463 | NSRect sr; |
| 8448 | double loc, pos; | 8464 | double loc, pos; |
| 8465 | int length; | ||
| 8449 | 8466 | ||
| 8450 | NSTRACE ("[EmacsScroller mouseDragged:]"); | 8467 | NSTRACE ("[EmacsScroller mouseDragged:]"); |
| 8451 | 8468 | ||
| 8452 | sr = [self convertRect: [self rectForPart: NSScrollerKnobSlot] | 8469 | sr = [self convertRect: [self rectForPart: NSScrollerKnobSlot] |
| 8453 | toView: nil]; | 8470 | toView: nil]; |
| 8454 | loc = NSHeight (sr) - ([e locationInWindow].y - NSMinY (sr)); | 8471 | |
| 8472 | if (horizontal) | ||
| 8473 | { | ||
| 8474 | length = NSWidth (sr); | ||
| 8475 | loc = ([e locationInWindow].x - NSMinX (sr)); | ||
| 8476 | } | ||
| 8477 | else | ||
| 8478 | { | ||
| 8479 | length = NSHeight (sr); | ||
| 8480 | loc = length - ([e locationInWindow].y - NSMinY (sr)); | ||
| 8481 | } | ||
| 8455 | 8482 | ||
| 8456 | if (loc <= 0.0) | 8483 | if (loc <= 0.0) |
| 8457 | { | 8484 | { |
| 8458 | loc = 0.0; | 8485 | loc = 0.0; |
| 8459 | } | 8486 | } |
| 8460 | else if (loc >= NSHeight (sr) + last_mouse_offset) | 8487 | else if (loc >= length + last_mouse_offset) |
| 8461 | { | 8488 | { |
| 8462 | loc = NSHeight (sr) + last_mouse_offset; | 8489 | loc = length + last_mouse_offset; |
| 8463 | } | 8490 | } |
| 8464 | 8491 | ||
| 8465 | pos = (loc - last_mouse_offset) / NSHeight (sr); | 8492 | pos = (loc - last_mouse_offset); |
| 8466 | [self sendScrollEventAtLoc: pos fromEvent: e]; | 8493 | [self sendScrollEventAtLoc: pos fromEvent: e]; |
| 8467 | } | 8494 | } |
| 8468 | 8495 | ||
diff --git a/src/window.h b/src/window.h index 84180c96a7d..1fd19369c33 100644 --- a/src/window.h +++ b/src/window.h | |||
| @@ -793,7 +793,7 @@ wset_next_buffers (struct window *w, Lisp_Object val) | |||
| 793 | || WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_RIGHT (W)) | 793 | || WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_RIGHT (W)) |
| 794 | 794 | ||
| 795 | #if (defined (HAVE_WINDOW_SYSTEM) \ | 795 | #if (defined (HAVE_WINDOW_SYSTEM) \ |
| 796 | && ((defined (USE_TOOLKIT_SCROLL_BARS) && !defined (HAVE_NS)) \ | 796 | && ((defined (USE_TOOLKIT_SCROLL_BARS)) \ |
| 797 | || defined (HAVE_NTGUI))) | 797 | || defined (HAVE_NTGUI))) |
| 798 | # define USE_HORIZONTAL_SCROLL_BARS true | 798 | # define USE_HORIZONTAL_SCROLL_BARS true |
| 799 | #else | 799 | #else |