diff options
| author | Jan Djärv | 2013-12-19 09:40:11 +0100 |
|---|---|---|
| committer | Jan Djärv | 2013-12-19 09:40:11 +0100 |
| commit | 680e6b8c5a28489733df544edb074fd29d0522a0 (patch) | |
| tree | a44d361ea9182445f147e0bd89381b106a4748a6 /src | |
| parent | 049638ad60ae21c89227148ac7235da3afbf221d (diff) | |
| download | emacs-680e6b8c5a28489733df544edb074fd29d0522a0.tar.gz emacs-680e6b8c5a28489733df544edb074fd29d0522a0.zip | |
Redo size constraint for NS so frames can span screens.
* nsterm.h (ns_output): Remove dont_constrain.
* nsterm.m (NSTRACE_SIZE, NSTRACE_RECT): New macros.
(ns_constrain_all_frames, x_set_offset): Remove assignment to
dont_constrain.
(updateFrameSize:, windowWillResize:toSize:): Add trace.
(constrainFrameRect): Remove special case nr_screens == 1.
Don't constrain size to size of view.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 11 | ||||
| -rw-r--r-- | src/nsterm.h | 3 | ||||
| -rw-r--r-- | src/nsterm.m | 74 |
3 files changed, 71 insertions, 17 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index d6db5b30e0c..e7f30f25800 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,5 +1,16 @@ | |||
| 1 | 2013-12-19 Anders Lindgren <andlind@gmail.com> | 1 | 2013-12-19 Anders Lindgren <andlind@gmail.com> |
| 2 | 2 | ||
| 3 | * nsterm.m (NSTRACE_SIZE, NSTRACE_RECT): New macros. | ||
| 4 | (ns_constrain_all_frames, x_set_offset): Remove assignment to | ||
| 5 | dont_constrain. | ||
| 6 | (updateFrameSize:, windowWillResize:toSize:): Add trace. | ||
| 7 | (constrainFrameRect): Remove special case nr_screens == 1. | ||
| 8 | Don't constrain size to size of view. | ||
| 9 | |||
| 10 | * nsterm.h (ns_output): Remove dont_constrain. | ||
| 11 | |||
| 12 | 2013-12-19 Anders Lindgren <andlind@gmail.com> | ||
| 13 | |||
| 3 | * nsterm.m (mouseDown:): Generate HORIZ_WHEEL_EVENT. | 14 | * nsterm.m (mouseDown:): Generate HORIZ_WHEEL_EVENT. |
| 4 | 15 | ||
| 5 | 2013-12-18 Paul Eggert <eggert@cs.ucla.edu> | 16 | 2013-12-18 Paul Eggert <eggert@cs.ucla.edu> |
diff --git a/src/nsterm.h b/src/nsterm.h index 0215f13dffd..faf8271bcc7 100644 --- a/src/nsterm.h +++ b/src/nsterm.h | |||
| @@ -687,9 +687,6 @@ struct ns_output | |||
| 687 | /* This is the Emacs structure for the NS display this frame is on. */ | 687 | /* This is the Emacs structure for the NS display this frame is on. */ |
| 688 | struct ns_display_info *display_info; | 688 | struct ns_display_info *display_info; |
| 689 | 689 | ||
| 690 | /* Non-zero if we want to constrain the frame to the screen. */ | ||
| 691 | int dont_constrain; | ||
| 692 | |||
| 693 | /* Non-zero if we are zooming (maximizing) the frame. */ | 690 | /* Non-zero if we are zooming (maximizing) the frame. */ |
| 694 | int zooming; | 691 | int zooming; |
| 695 | }; | 692 | }; |
diff --git a/src/nsterm.m b/src/nsterm.m index 99c061d16bc..d7c2f38135a 100644 --- a/src/nsterm.m +++ b/src/nsterm.m | |||
| @@ -79,6 +79,28 @@ int term_trace_num = 0; | |||
| 79 | #define NSTRACE(x) | 79 | #define NSTRACE(x) |
| 80 | #endif | 80 | #endif |
| 81 | 81 | ||
| 82 | /* Detailed tracing. "S" means "size" and "LL" stands for "lower left". */ | ||
| 83 | #if 1 | ||
| 84 | int term_trace_num = 0; | ||
| 85 | #define NSTRACE_SIZE(str,size) fprintf (stderr, \ | ||
| 86 | "%s:%d: [%d] " str \ | ||
| 87 | " (S:%.0f x %.0f)\n", \ | ||
| 88 | __FILE__, __LINE__, ++term_trace_num,\ | ||
| 89 | size.height, \ | ||
| 90 | size.width) | ||
| 91 | #define NSTRACE_RECT(s,r) fprintf (stderr, \ | ||
| 92 | "%s:%d: [%d] " s \ | ||
| 93 | " (LL:%.0f x %.0f -> S:%.0f x %.0f)\n", \ | ||
| 94 | __FILE__, __LINE__, ++term_trace_num,\ | ||
| 95 | r.origin.x, \ | ||
| 96 | r.origin.y, \ | ||
| 97 | r.size.height, \ | ||
| 98 | r.size.width) | ||
| 99 | #else | ||
| 100 | #define NSTRACE_SIZE(str,size) | ||
| 101 | #define NSTRACE_RECT(s,r) | ||
| 102 | #endif | ||
| 103 | |||
| 82 | extern NSString *NSMenuDidBeginTrackingNotification; | 104 | extern NSString *NSMenuDidBeginTrackingNotification; |
| 83 | 105 | ||
| 84 | /* ========================================================================== | 106 | /* ========================================================================== |
| @@ -605,7 +627,6 @@ ns_constrain_all_frames (void) | |||
| 605 | NSView *view = FRAME_NS_VIEW (f); | 627 | NSView *view = FRAME_NS_VIEW (f); |
| 606 | /* This no-op will trigger the default window placing | 628 | /* This no-op will trigger the default window placing |
| 607 | * constraint system. */ | 629 | * constraint system. */ |
| 608 | f->output_data.ns->dont_constrain = 0; | ||
| 609 | [[view window] setFrameOrigin:[[view window] frame].origin]; | 630 | [[view window] setFrameOrigin:[[view window] frame].origin]; |
| 610 | } | 631 | } |
| 611 | } | 632 | } |
| @@ -1225,7 +1246,6 @@ x_set_offset (struct frame *f, int xoff, int yoff, int change_grav) | |||
| 1225 | #endif | 1246 | #endif |
| 1226 | /* Constrain the setFrameTopLeftPoint so we don't move behind the | 1247 | /* Constrain the setFrameTopLeftPoint so we don't move behind the |
| 1227 | menu bar. */ | 1248 | menu bar. */ |
| 1228 | f->output_data.ns->dont_constrain = 0; | ||
| 1229 | [[view window] setFrameTopLeftPoint: | 1249 | [[view window] setFrameTopLeftPoint: |
| 1230 | NSMakePoint (SCREENMAXBOUND (f->left_pos), | 1250 | NSMakePoint (SCREENMAXBOUND (f->left_pos), |
| 1231 | SCREENMAXBOUND ([fscreen frame].size.height | 1251 | SCREENMAXBOUND ([fscreen frame].size.height |
| @@ -5684,10 +5704,13 @@ not_in_argv (NSString *arg) | |||
| 5684 | NSRect wr = [window frame]; | 5704 | NSRect wr = [window frame]; |
| 5685 | int extra = 0; | 5705 | int extra = 0; |
| 5686 | int oldc = cols, oldr = rows; | 5706 | int oldc = cols, oldr = rows; |
| 5687 | int oldw = FRAME_PIXEL_WIDTH (emacsframe), | 5707 | int oldw = FRAME_PIXEL_WIDTH (emacsframe); |
| 5688 | oldh = FRAME_PIXEL_HEIGHT (emacsframe); | 5708 | int oldh = FRAME_PIXEL_HEIGHT (emacsframe); |
| 5689 | int neww, newh; | 5709 | int neww, newh; |
| 5690 | 5710 | ||
| 5711 | NSTRACE (updateFrameSize); | ||
| 5712 | NSTRACE_SIZE ("Original size", NSMakeSize (oldw, oldh)); | ||
| 5713 | |||
| 5691 | if (! [self isFullscreen]) | 5714 | if (! [self isFullscreen]) |
| 5692 | { | 5715 | { |
| 5693 | #ifdef NS_IMPL_GNUSTEP | 5716 | #ifdef NS_IMPL_GNUSTEP |
| @@ -5731,6 +5754,8 @@ not_in_argv (NSString *arg) | |||
| 5731 | sz.width = FRAME_COLUMN_WIDTH (emacsframe); | 5754 | sz.width = FRAME_COLUMN_WIDTH (emacsframe); |
| 5732 | sz.height = FRAME_LINE_HEIGHT (emacsframe); | 5755 | sz.height = FRAME_LINE_HEIGHT (emacsframe); |
| 5733 | [win setResizeIncrements: sz]; | 5756 | [win setResizeIncrements: sz]; |
| 5757 | |||
| 5758 | NSTRACE_SIZE ("New size", NSMakeSize (neww, newh)); | ||
| 5734 | } | 5759 | } |
| 5735 | 5760 | ||
| 5736 | [view setFrame: NSMakeRect (0, 0, neww, newh)]; | 5761 | [view setFrame: NSMakeRect (0, 0, neww, newh)]; |
| @@ -5744,6 +5769,7 @@ not_in_argv (NSString *arg) | |||
| 5744 | int extra = 0; | 5769 | int extra = 0; |
| 5745 | 5770 | ||
| 5746 | NSTRACE (windowWillResize); | 5771 | NSTRACE (windowWillResize); |
| 5772 | NSTRACE_SIZE ("Original size", frameSize); | ||
| 5747 | /*fprintf (stderr,"Window will resize: %.0f x %.0f\n",frameSize.width,frameSize.height); */ | 5773 | /*fprintf (stderr,"Window will resize: %.0f x %.0f\n",frameSize.width,frameSize.height); */ |
| 5748 | 5774 | ||
| 5749 | if (fs_state == FULLSCREEN_MAXIMIZED | 5775 | if (fs_state == FULLSCREEN_MAXIMIZED |
| @@ -6903,19 +6929,39 @@ if (cols > 0 && rows > 0) | |||
| 6903 | NSUInteger nr_screens = [[NSScreen screens] count]; | 6929 | NSUInteger nr_screens = [[NSScreen screens] count]; |
| 6904 | struct frame *f = ((EmacsView *)[self delegate])->emacsframe; | 6930 | struct frame *f = ((EmacsView *)[self delegate])->emacsframe; |
| 6905 | NSTRACE (constrainFrameRect); | 6931 | NSTRACE (constrainFrameRect); |
| 6932 | NSTRACE_RECT ("input", frameRect); | ||
| 6906 | 6933 | ||
| 6907 | if (nr_screens == 1) | 6934 | if (ns_menu_bar_should_be_hidden ()) |
| 6908 | { | ||
| 6909 | NSRect r = [super constrainFrameRect:frameRect toScreen:screen]; | ||
| 6910 | return r; | ||
| 6911 | } | ||
| 6912 | |||
| 6913 | if (f->output_data.ns->dont_constrain | ||
| 6914 | || ns_menu_bar_should_be_hidden ()) | ||
| 6915 | return frameRect; | 6935 | return frameRect; |
| 6916 | 6936 | ||
| 6917 | f->output_data.ns->dont_constrain = 1; | 6937 | /* The default implementation does two things 1) ensure that the top |
| 6918 | return [super constrainFrameRect:frameRect toScreen:screen]; | 6938 | of the rectangle is below the menu bar (or below the top of the |
| 6939 | screen) and 2) resizes windows larger than the screen. As we | ||
| 6940 | don't want the latter, a smaller rectangle is used. */ | ||
| 6941 | #define FAKE_HEIGHT 64 | ||
| 6942 | float old_top = frameRect.origin.y + frameRect.size.height; | ||
| 6943 | NSRect r; | ||
| 6944 | r.size.height = FAKE_HEIGHT; | ||
| 6945 | r.size.width = frameRect.size.width; | ||
| 6946 | r.origin.x = frameRect.origin.x; | ||
| 6947 | r.origin.y = old_top - FAKE_HEIGHT; | ||
| 6948 | |||
| 6949 | NSTRACE_RECT ("input to super", r); | ||
| 6950 | |||
| 6951 | r = [super constrainFrameRect:r toScreen:screen]; | ||
| 6952 | |||
| 6953 | NSTRACE_RECT ("output from super", r); | ||
| 6954 | |||
| 6955 | float new_top = r.origin.y + FAKE_HEIGHT; | ||
| 6956 | if (new_top < old_top) | ||
| 6957 | { | ||
| 6958 | frameRect.origin.y = new_top - frameRect.size.height; | ||
| 6959 | } | ||
| 6960 | |||
| 6961 | NSTRACE_RECT ("output", frameRect); | ||
| 6962 | |||
| 6963 | return frameRect; | ||
| 6964 | #undef FAKE_HEIGHT | ||
| 6919 | } | 6965 | } |
| 6920 | 6966 | ||
| 6921 | @end /* EmacsWindow */ | 6967 | @end /* EmacsWindow */ |