src/video/cocoa/SDL_cocoawindow.m
changeset 8935 9d2f0236322b
parent 8931 44d8a2f4b431
child 8953 dc80dc0bd22e
     1.1 --- a/src/video/cocoa/SDL_cocoawindow.m	Tue May 27 15:47:25 2014 -0400
     1.2 +++ b/src/video/cocoa/SDL_cocoawindow.m	Wed May 28 01:22:47 2014 -0400
     1.3 @@ -657,26 +657,20 @@
     1.4      /*NSLog(@"doCommandBySelector: %@\n", NSStringFromSelector(aSelector));*/
     1.5  }
     1.6  
     1.7 -- (BOOL)processDragArea:(NSEvent *)theEvent
     1.8 +- (BOOL)processHitTest:(NSEvent *)theEvent
     1.9  {
    1.10 -    const int num_areas = _data->window->num_drag_areas;
    1.11 +    SDL_assert(isDragAreaRunning == [_data->nswindow isMovableByWindowBackground]);
    1.12  
    1.13 -    SDL_assert(isDragAreaRunning == [_data->nswindow isMovableByWindowBackground]);
    1.14 -    SDL_assert((num_areas > 0) || !isDragAreaRunning);
    1.15 -
    1.16 -    if (num_areas > 0) {  /* if no drag areas, skip this. */
    1.17 -        int i;
    1.18 +    if (_data->window->hit_test) {  /* if no hit-test, skip this. */
    1.19          const NSPoint location = [theEvent locationInWindow];
    1.20          const SDL_Point point = { (int) location.x, _data->window->h - (((int) location.y)-1) };
    1.21 -        const SDL_Rect *areas = _data->window->drag_areas;
    1.22 -        for (i = 0; i < num_areas; i++) {
    1.23 -            if (SDL_PointInRect(&point, &areas[i])) {
    1.24 -                if (!isDragAreaRunning) {
    1.25 -                    isDragAreaRunning = YES;
    1.26 -                    [_data->nswindow setMovableByWindowBackground:YES];
    1.27 -                }
    1.28 -                return YES;  /* started a new drag! */
    1.29 +        const SDL_HitTestResult rc = _data->window->hit_test(_data->window, &point, _data->window->hit_test_data);
    1.30 +        if (rc == SDL_HITTEST_DRAGGABLE) {
    1.31 +            if (!isDragAreaRunning) {
    1.32 +                isDragAreaRunning = YES;
    1.33 +                [_data->nswindow setMovableByWindowBackground:YES];
    1.34              }
    1.35 +            return YES;  /* dragging! */
    1.36          }
    1.37      }
    1.38  
    1.39 @@ -686,14 +680,14 @@
    1.40          return YES;  /* was dragging, drop event. */
    1.41      }
    1.42  
    1.43 -    return NO;  /* not a drag area, carry on. */
    1.44 +    return NO;  /* not a special area, carry on. */
    1.45  }
    1.46  
    1.47  - (void)mouseDown:(NSEvent *)theEvent
    1.48  {
    1.49      int button;
    1.50  
    1.51 -    if ([self processDragArea:theEvent]) {
    1.52 +    if ([self processHitTest:theEvent]) {
    1.53          return;  /* dragging, drop event. */
    1.54      }
    1.55  
    1.56 @@ -735,7 +729,7 @@
    1.57  {
    1.58      int button;
    1.59  
    1.60 -    if ([self processDragArea:theEvent]) {
    1.61 +    if ([self processHitTest:theEvent]) {
    1.62          return;  /* stopped dragging, drop event. */
    1.63      }
    1.64  
    1.65 @@ -778,7 +772,7 @@
    1.66      NSPoint point;
    1.67      int x, y;
    1.68  
    1.69 -    if ([self processDragArea:theEvent]) {
    1.70 +    if ([self processHitTest:theEvent]) {
    1.71          return;  /* dragging, drop event. */
    1.72      }
    1.73  
    1.74 @@ -1599,7 +1593,7 @@
    1.75  }
    1.76  
    1.77  int
    1.78 -Cocoa_SetWindowDragAreas(SDL_Window * window, const SDL_Rect *areas, int num_areas)
    1.79 +Cocoa_SetWindowHitTest(SDL_Window * window, SDL_bool enabled)
    1.80  {
    1.81      return 0;  /* just succeed, the real work is done elsewhere. */
    1.82  }