aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorYAMAMOTO Mitsuharu2006-09-08 08:18:18 +0000
committerYAMAMOTO Mitsuharu2006-09-08 08:18:18 +0000
commitbed0bf953c6c08d287558d9d7ba7ffd790c2fa2a (patch)
tree8c79f5e009f53ba5aa0f98274c0e0155987d5314 /src
parentfa4ba14c911f49c86aa5c2b2ec2ddbdbfe8fe615 (diff)
downloademacs-bed0bf953c6c08d287558d9d7ba7ffd790c2fa2a.tar.gz
emacs-bed0bf953c6c08d287558d9d7ba7ffd790c2fa2a.zip
(mac_handle_origin_change, mac_handle_size_change)
(mac_get_ideal_size): New functions. (x_set_offset, x_set_window_size, x_make_frame_visible) (do_zoom_window, mac_handle_window_event, XTread_socket): Use them. (install_window_handler, mac_handle_window_event) [USE_CARBON_EVENTS]: Handle kEventWindowGetIdealSize and kEventWindowBoundsChanged. (XTread_socket) [MAC_OS_X_VERSION_MAX_ALLOWED >= 1030]: Don't call DragWindow.
Diffstat (limited to 'src')
-rw-r--r--src/macterm.c251
1 files changed, 164 insertions, 87 deletions
diff --git a/src/macterm.c b/src/macterm.c
index 90ef7a2774a..dcfa61e0ac3 100644
--- a/src/macterm.c
+++ b/src/macterm.c
@@ -5805,6 +5805,57 @@ mac_get_window_bounds (f, inner, outer)
5805#endif /* not TARGET_API_MAC_CARBON */ 5805#endif /* not TARGET_API_MAC_CARBON */
5806} 5806}
5807 5807
5808static void
5809mac_handle_origin_change (f)
5810 struct frame *f;
5811{
5812 x_real_positions (f, &f->left_pos, &f->top_pos);
5813}
5814
5815static void
5816mac_handle_size_change (f, pixelwidth, pixelheight)
5817 struct frame *f;
5818 int pixelwidth, pixelheight;
5819{
5820 int cols, rows;
5821
5822 cols = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, pixelwidth);
5823 rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, pixelheight);
5824
5825 if (cols != FRAME_COLS (f)
5826 || rows != FRAME_LINES (f)
5827 || pixelwidth != FRAME_PIXEL_WIDTH (f)
5828 || pixelheight != FRAME_PIXEL_HEIGHT (f))
5829 {
5830 /* We pass 1 for DELAY since we can't run Lisp code inside of
5831 a BLOCK_INPUT. */
5832 change_frame_size (f, rows, cols, 0, 1, 0);
5833 FRAME_PIXEL_WIDTH (f) = pixelwidth;
5834 FRAME_PIXEL_HEIGHT (f) = pixelheight;
5835 SET_FRAME_GARBAGED (f);
5836
5837 /* If cursor was outside the new size, mark it as off. */
5838 mark_window_cursors_off (XWINDOW (f->root_window));
5839
5840 /* Clear out any recollection of where the mouse highlighting
5841 was, since it might be in a place that's outside the new
5842 frame size. Actually checking whether it is outside is a
5843 pain in the neck, so don't try--just let the highlighting be
5844 done afresh with new size. */
5845 cancel_mouse_face (f);
5846
5847#if TARGET_API_MAC_CARBON
5848 if (f->output_data.mac->hourglass_control)
5849 {
5850#if USE_CG_DRAWING
5851 mac_prepare_for_quickdraw (f);
5852#endif
5853 MoveControl (f->output_data.mac->hourglass_control,
5854 pixelwidth - HOURGLASS_WIDTH, 0);
5855 }
5856#endif
5857 }
5858}
5808 5859
5809 5860
5810/* Calculate the absolute position in frame F 5861/* Calculate the absolute position in frame F
@@ -5885,7 +5936,10 @@ x_set_offset (f, xoff, yoff, change_gravity)
5885 ConstrainWindowToScreen (FRAME_MAC_WINDOW (f), kWindowTitleBarRgn, 5936 ConstrainWindowToScreen (FRAME_MAC_WINDOW (f), kWindowTitleBarRgn,
5886 kWindowConstrainMoveRegardlessOfFit 5937 kWindowConstrainMoveRegardlessOfFit
5887 | kWindowConstrainAllowPartial, NULL, NULL); 5938 | kWindowConstrainAllowPartial, NULL, NULL);
5888 x_real_positions (f, &f->left_pos, &f->top_pos); 5939#if USE_CARBON_EVENTS
5940 if (!NILP (tip_frame) && XFRAME (tip_frame) == f)
5941#endif
5942 mac_handle_origin_change (f);
5889#else 5943#else
5890 { 5944 {
5891 Rect inner, outer, screen_rect, dummy; 5945 Rect inner, outer, screen_rect, dummy;
@@ -5959,50 +6013,11 @@ x_set_window_size (f, change_gravity, cols, rows)
5959 x_wm_set_size_hint (f, (long) 0, 0); 6013 x_wm_set_size_hint (f, (long) 0, 0);
5960 6014
5961 SizeWindow (FRAME_MAC_WINDOW (f), pixelwidth, pixelheight, 0); 6015 SizeWindow (FRAME_MAC_WINDOW (f), pixelwidth, pixelheight, 0);
5962#if TARGET_API_MAC_CARBON
5963 if (f->output_data.mac->hourglass_control)
5964 {
5965#if USE_CG_DRAWING
5966 mac_prepare_for_quickdraw (f);
5967#endif
5968 MoveControl (f->output_data.mac->hourglass_control,
5969 pixelwidth - HOURGLASS_WIDTH, 0);
5970 }
5971#endif
5972
5973 /* Now, strictly speaking, we can't be sure that this is accurate,
5974 but the window manager will get around to dealing with the size
5975 change request eventually, and we'll hear how it went when the
5976 ConfigureNotify event gets here.
5977
5978 We could just not bother storing any of this information here,
5979 and let the ConfigureNotify event set everything up, but that
5980 might be kind of confusing to the Lisp code, since size changes
5981 wouldn't be reported in the frame parameters until some random
5982 point in the future when the ConfigureNotify event arrives.
5983 6016
5984 We pass 1 for DELAY since we can't run Lisp code inside of 6017#if USE_CARBON_EVENTS
5985 a BLOCK_INPUT. */ 6018 if (!NILP (tip_frame) && f == XFRAME (tip_frame))
5986 change_frame_size (f, rows, cols, 0, 1, 0); 6019#endif
5987 FRAME_PIXEL_WIDTH (f) = pixelwidth; 6020 mac_handle_size_change (f, pixelwidth, pixelheight);
5988 FRAME_PIXEL_HEIGHT (f) = pixelheight;
5989
5990 /* We've set {FRAME,PIXEL}_{WIDTH,HEIGHT} to the values we hope to
5991 receive in the ConfigureNotify event; if we get what we asked
5992 for, then the event won't cause the screen to become garbaged, so
5993 we have to make sure to do it here. */
5994 SET_FRAME_GARBAGED (f);
5995
5996 XFlush (FRAME_X_DISPLAY (f));
5997
5998 /* If cursor was outside the new size, mark it as off. */
5999 mark_window_cursors_off (XWINDOW (f->root_window));
6000
6001 /* Clear out any recollection of where the mouse highlighting was,
6002 since it might be in a place that's outside the new frame size.
6003 Actually checking whether it is outside is a pain in the neck,
6004 so don't try--just let the highlighting be done afresh with new size. */
6005 cancel_mouse_face (f);
6006 6021
6007 UNBLOCK_INPUT; 6022 UNBLOCK_INPUT;
6008} 6023}
@@ -6213,7 +6228,10 @@ x_make_frame_visible (f)
6213 kWindowCascadeOnParentWindowScreen 6228 kWindowCascadeOnParentWindowScreen
6214#endif 6229#endif
6215 ); 6230 );
6216 x_real_positions (f, &f->left_pos, &f->top_pos); 6231#if USE_CARBON_EVENTS
6232 if (!NILP (tip_frame) && f == XFRAME (tip_frame))
6233#endif
6234 mac_handle_origin_change (f);
6217 } 6235 }
6218 else 6236 else
6219#endif 6237#endif
@@ -9165,6 +9183,32 @@ do_grow_window (WindowPtr w, EventRecord *e)
9165} 9183}
9166 9184
9167 9185
9186#if TARGET_API_MAC_CARBON
9187static Point
9188mac_get_ideal_size (f)
9189 struct frame *f;
9190{
9191 struct mac_display_info *dpyinfo = FRAME_MAC_DISPLAY_INFO (f);
9192 WindowPtr w = FRAME_MAC_WINDOW (f);
9193 Point ideal_size;
9194 Rect standard_rect;
9195 int height, width, columns, rows;
9196
9197 ideal_size.h = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, DEFAULT_NUM_COLS);
9198 ideal_size.v = dpyinfo->height;
9199 IsWindowInStandardState (w, &ideal_size, &standard_rect);
9200 /* Adjust the standard size according to character boundaries. */
9201 width = standard_rect.right - standard_rect.left;
9202 height = standard_rect.bottom - standard_rect.top;
9203 columns = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, width);
9204 rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, height);
9205 ideal_size.h = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, columns);
9206 ideal_size.v = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, rows);
9207
9208 return ideal_size;
9209}
9210#endif
9211
9168/* Handle clicks in zoom box. Calculation of "standard state" based 9212/* Handle clicks in zoom box. Calculation of "standard state" based
9169 on code in IM - Window Manager A and code contributed by Ben 9213 on code in IM - Window Manager A and code contributed by Ben
9170 Mesander. The standard state of an Emacs window is 80-characters 9214 Mesander. The standard state of an Emacs window is 80-characters
@@ -9174,39 +9218,28 @@ static void
9174do_zoom_window (WindowPtr w, int zoom_in_or_out) 9218do_zoom_window (WindowPtr w, int zoom_in_or_out)
9175{ 9219{
9176 Rect zoom_rect, port_rect; 9220 Rect zoom_rect, port_rect;
9177 int columns, rows, width, height; 9221 int width, height;
9178 struct frame *f = mac_window_to_frame (w); 9222 struct frame *f = mac_window_to_frame (w);
9179 struct mac_display_info *dpyinfo = FRAME_MAC_DISPLAY_INFO (f);
9180#if TARGET_API_MAC_CARBON 9223#if TARGET_API_MAC_CARBON
9181 Point standard_size; 9224 Point ideal_size = mac_get_ideal_size (f);
9182
9183 standard_size.h = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, DEFAULT_NUM_COLS);
9184 standard_size.v = dpyinfo->height;
9185 9225
9186 if (IsWindowInStandardState (w, &standard_size, &zoom_rect)) 9226 GetWindowBounds (w, kWindowContentRgn, &port_rect);
9227 if (IsWindowInStandardState (w, &ideal_size, &zoom_rect)
9228 && port_rect.left == zoom_rect.left
9229 && port_rect.top == zoom_rect.top)
9187 zoom_in_or_out = inZoomIn; 9230 zoom_in_or_out = inZoomIn;
9188 else 9231 else
9189 { 9232 zoom_in_or_out = inZoomOut;
9190 /* Adjust the standard size according to character boundaries. */
9191
9192 columns = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, zoom_rect.right - zoom_rect.left);
9193 rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, zoom_rect.bottom - zoom_rect.top);
9194 standard_size.h = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, columns);
9195 standard_size.v = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, rows);
9196 GetWindowBounds (w, kWindowContentRgn, &port_rect);
9197 if (IsWindowInStandardState (w, &standard_size, &zoom_rect)
9198 && port_rect.left == zoom_rect.left
9199 && port_rect.top == zoom_rect.top)
9200 zoom_in_or_out = inZoomIn;
9201 else
9202 zoom_in_or_out = inZoomOut;
9203 }
9204 9233
9205 ZoomWindowIdeal (w, zoom_in_or_out, &standard_size); 9234#ifdef MAC_OS8
9235 mac_clear_window (f);
9236#endif
9237 ZoomWindowIdeal (w, zoom_in_or_out, &ideal_size);
9206#else /* not TARGET_API_MAC_CARBON */ 9238#else /* not TARGET_API_MAC_CARBON */
9207 GrafPtr save_port; 9239 GrafPtr save_port;
9208 Point top_left; 9240 Point top_left;
9209 int w_title_height; 9241 int w_title_height, rows;
9242 struct mac_display_info *dpyinfo = FRAME_MAC_DISPLAY_INFO (f);
9210 9243
9211 GetPort (&save_port); 9244 GetPort (&save_port);
9212 9245
@@ -9245,6 +9278,7 @@ do_zoom_window (WindowPtr w, int zoom_in_or_out)
9245 SetPort (save_port); 9278 SetPort (save_port);
9246#endif /* not TARGET_API_MAC_CARBON */ 9279#endif /* not TARGET_API_MAC_CARBON */
9247 9280
9281#if !USE_CARBON_EVENTS
9248 /* retrieve window size and update application values */ 9282 /* retrieve window size and update application values */
9249#if TARGET_API_MAC_CARBON 9283#if TARGET_API_MAC_CARBON
9250 GetWindowPortBounds (w, &port_rect); 9284 GetWindowPortBounds (w, &port_rect);
@@ -9254,20 +9288,9 @@ do_zoom_window (WindowPtr w, int zoom_in_or_out)
9254 height = port_rect.bottom - port_rect.top; 9288 height = port_rect.bottom - port_rect.top;
9255 width = port_rect.right - port_rect.left; 9289 width = port_rect.right - port_rect.left;
9256 9290
9257 if (width != FRAME_PIXEL_WIDTH (f) 9291 mac_handle_size_change (f, width, height);
9258 || height != FRAME_PIXEL_HEIGHT (f)) 9292 mac_handle_origin_change (f);
9259 { 9293#endif
9260 rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, height);
9261 columns = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, width);
9262
9263 change_frame_size (f, rows, columns, 0, 1, 0);
9264 SET_FRAME_GARBAGED (f);
9265 cancel_mouse_face (f);
9266
9267 FRAME_PIXEL_WIDTH (f) = width;
9268 FRAME_PIXEL_HEIGHT (f) = height;
9269 }
9270 x_real_positions (f, &f->left_pos, &f->top_pos);
9271} 9294}
9272 9295
9273void 9296void
@@ -9406,6 +9429,7 @@ mac_handle_window_event (next_handler, event, data)
9406{ 9429{
9407 WindowPtr wp; 9430 WindowPtr wp;
9408 OSStatus result, err; 9431 OSStatus result, err;
9432 struct frame *f;
9409 UInt32 attributes; 9433 UInt32 attributes;
9410 XSizeHints *size_hints; 9434 XSizeHints *size_hints;
9411 9435
@@ -9414,6 +9438,7 @@ mac_handle_window_event (next_handler, event, data)
9414 if (err != noErr) 9438 if (err != noErr)
9415 return eventNotHandledErr; 9439 return eventNotHandledErr;
9416 9440
9441 f = mac_window_to_frame (wp);
9417 switch (GetEventKind (event)) 9442 switch (GetEventKind (event))
9418 { 9443 {
9419 case kEventWindowUpdate: 9444 case kEventWindowUpdate:
@@ -9424,6 +9449,21 @@ mac_handle_window_event (next_handler, event, data)
9424 do_window_update (wp); 9449 do_window_update (wp);
9425 return noErr; 9450 return noErr;
9426 9451
9452 case kEventWindowGetIdealSize:
9453 result = CallNextEventHandler (next_handler, event);
9454 if (result != eventNotHandledErr)
9455 return result;
9456
9457 {
9458 Point ideal_size = mac_get_ideal_size (f);
9459
9460 err = SetEventParameter (event, kEventParamDimensions,
9461 typeQDPoint, sizeof (Point), &ideal_size);
9462 if (err == noErr)
9463 return noErr;
9464 }
9465 break;
9466
9427 case kEventWindowBoundsChanging: 9467 case kEventWindowBoundsChanging:
9428 result = CallNextEventHandler (next_handler, event); 9468 result = CallNextEventHandler (next_handler, event);
9429 if (result != eventNotHandledErr) 9469 if (result != eventNotHandledErr)
@@ -9434,7 +9474,7 @@ mac_handle_window_event (next_handler, event, data)
9434 if (err != noErr) 9474 if (err != noErr)
9435 break; 9475 break;
9436 9476
9437 size_hints = FRAME_SIZE_HINTS (mac_window_to_frame (wp)); 9477 size_hints = FRAME_SIZE_HINTS (f);
9438 if ((attributes & kWindowBoundsChangeUserResize) 9478 if ((attributes & kWindowBoundsChangeUserResize)
9439 && ((size_hints->flags & (PResizeInc | PBaseSize | PMinSize)) 9479 && ((size_hints->flags & (PResizeInc | PBaseSize | PMinSize))
9440 == (PResizeInc | PBaseSize | PMinSize))) 9480 == (PResizeInc | PBaseSize | PMinSize)))
@@ -9475,24 +9515,53 @@ mac_handle_window_event (next_handler, event, data)
9475 } 9515 }
9476 break; 9516 break;
9477 9517
9518 case kEventWindowBoundsChanged:
9519 err = GetEventParameter (event, kEventParamAttributes, typeUInt32,
9520 NULL, sizeof (UInt32), NULL, &attributes);
9521 if (err != noErr)
9522 break;
9523
9524 if (attributes & kWindowBoundsChangeSizeChanged)
9525 {
9526 Rect bounds;
9527
9528 err = GetEventParameter (event, kEventParamCurrentBounds,
9529 typeQDRectangle, NULL, sizeof (Rect),
9530 NULL, &bounds);
9531 if (err == noErr)
9532 {
9533 int width, height;
9534
9535 width = bounds.right - bounds.left;
9536 height = bounds.bottom - bounds.top;
9537 mac_handle_size_change (f, width, height);
9538 }
9539 }
9540
9541 if (attributes & kWindowBoundsChangeOriginChanged)
9542 mac_handle_origin_change (f);
9543
9544 return noErr;
9545
9478 case kEventWindowShown: 9546 case kEventWindowShown:
9479 case kEventWindowHidden: 9547 case kEventWindowHidden:
9480 case kEventWindowExpanded: 9548 case kEventWindowExpanded:
9481 case kEventWindowCollapsed: 9549 case kEventWindowCollapsed:
9482 result = CallNextEventHandler (next_handler, event); 9550 result = CallNextEventHandler (next_handler, event);
9483 9551
9484 mac_handle_visibility_change (mac_window_to_frame (wp)); 9552 mac_handle_visibility_change (f);
9485 return noErr; 9553 return noErr;
9486 9554
9487 break; 9555 break;
9488 9556
9489 case kEventWindowClose: 9557 case kEventWindowClose:
9558 result = CallNextEventHandler (next_handler, event);
9490 { 9559 {
9491 struct input_event buf; 9560 struct input_event buf;
9492 9561
9493 EVENT_INIT (buf); 9562 EVENT_INIT (buf);
9494 buf.kind = DELETE_WINDOW_EVENT; 9563 buf.kind = DELETE_WINDOW_EVENT;
9495 XSETFRAME (buf.frame_or_window, mac_window_to_frame (wp)); 9564 XSETFRAME (buf.frame_or_window, f);
9496 buf.arg = Qnil; 9565 buf.arg = Qnil;
9497 kbd_buffer_store_event (&buf); 9566 kbd_buffer_store_event (&buf);
9498 } 9567 }
@@ -9908,7 +9977,9 @@ install_window_handler (window)
9908#if USE_CARBON_EVENTS 9977#if USE_CARBON_EVENTS
9909 EventTypeSpec specs_window[] = 9978 EventTypeSpec specs_window[] =
9910 {{kEventClassWindow, kEventWindowUpdate}, 9979 {{kEventClassWindow, kEventWindowUpdate},
9980 {kEventClassWindow, kEventWindowGetIdealSize},
9911 {kEventClassWindow, kEventWindowBoundsChanging}, 9981 {kEventClassWindow, kEventWindowBoundsChanging},
9982 {kEventClassWindow, kEventWindowBoundsChanged},
9912 {kEventClassWindow, kEventWindowShown}, 9983 {kEventClassWindow, kEventWindowShown},
9913 {kEventClassWindow, kEventWindowHidden}, 9984 {kEventClassWindow, kEventWindowHidden},
9914 {kEventClassWindow, kEventWindowExpanded}, 9985 {kEventClassWindow, kEventWindowExpanded},
@@ -10467,17 +10538,23 @@ XTread_socket (sd, expected, hold_quit)
10467 && (TrackWindowProxyDrag (window_ptr, er.where) 10538 && (TrackWindowProxyDrag (window_ptr, er.where)
10468 != errUserWantsToDragWindow)) 10539 != errUserWantsToDragWindow))
10469 break; 10540 break;
10541 /* kWindowAsyncDragAttribute is specified on Mac OS X
10542 10.3 and later.*/
10543#if MAC_OS_X_VERSION_MAX_ALLOWED < 1030
10470 DragWindow (window_ptr, er.where, NULL); 10544 DragWindow (window_ptr, er.where, NULL);
10545#endif
10471#else /* not TARGET_API_MAC_CARBON */ 10546#else /* not TARGET_API_MAC_CARBON */
10472 DragWindow (window_ptr, er.where, &qd.screenBits.bounds); 10547 DragWindow (window_ptr, er.where, &qd.screenBits.bounds);
10473#endif /* not TARGET_API_MAC_CARBON */ 10548#endif /* not TARGET_API_MAC_CARBON */
10474 /* Update the frame parameters. */ 10549 /* Update the frame parameters. */
10550#if !USE_CARBON_EVENTS
10475 { 10551 {
10476 struct frame *f = mac_window_to_frame (window_ptr); 10552 struct frame *f = mac_window_to_frame (window_ptr);
10477 10553
10478 if (f && !f->async_iconified) 10554 if (f && !f->async_iconified)
10479 x_real_positions (f, &f->left_pos, &f->top_pos); 10555 mac_handle_origin_change (f);
10480 } 10556 }
10557#endif
10481 break; 10558 break;
10482 10559
10483 case inGoAway: 10560 case inGoAway: