Mercurial > emacs
comparison src/macterm.c @ 83213:d83f49cefda3
Merged in changes from CVS trunk.
Patches applied:
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-593
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-594
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-595
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-596
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-597
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-598
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-599
Merge from gnus--rel--5.10
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-600
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-601
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-602
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-603
Merge from gnus--rel--5.10
* miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-42
Update from CVS
* miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-43
Merge from emacs--cvs-trunk--0
* miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-44
Update from CVS
git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-253
author | Karoly Lorentey <lorentey@elte.hu> |
---|---|
date | Thu, 07 Oct 2004 16:52:19 +0000 |
parents | 8a6fd1c164cd 05fe2d3ca439 |
children | 4f2f1522636c |
comparison
equal
deleted
inserted
replaced
83212:f70dc61a797f | 83213:d83f49cefda3 |
---|---|
48 #include <Resources.h> | 48 #include <Resources.h> |
49 #include <Fonts.h> | 49 #include <Fonts.h> |
50 #include <TextUtils.h> | 50 #include <TextUtils.h> |
51 #include <LowMem.h> | 51 #include <LowMem.h> |
52 #include <Controls.h> | 52 #include <Controls.h> |
53 #include <Windows.h> | |
53 #if defined (__MRC__) || (__MSL__ >= 0x6000) | 54 #if defined (__MRC__) || (__MSL__ >= 0x6000) |
54 #include <ControlDefinitions.h> | 55 #include <ControlDefinitions.h> |
55 #endif | 56 #endif |
56 | 57 |
57 #if __profile__ | 58 #if __profile__ |
3885 } | 3886 } |
3886 } | 3887 } |
3887 | 3888 |
3888 | 3889 |
3889 static WindowPtr | 3890 static WindowPtr |
3890 mac_front_window () | 3891 front_emacs_window () |
3891 { | 3892 { |
3892 #if TARGET_API_MAC_CARBON | 3893 #if TARGET_API_MAC_CARBON |
3893 return GetFrontWindowOfClass (kDocumentWindowClass, true); | 3894 WindowPtr wp = GetFrontWindowOfClass (kDocumentWindowClass, true); |
3895 | |
3896 while (wp && !is_emacs_window (wp)) | |
3897 wp = GetNextWindowOfClass (wp, kDocumentWindowClass, true); | |
3894 #else | 3898 #else |
3895 WindowPtr front_window = FrontWindow (); | 3899 WindowPtr wp = FrontWindow (); |
3896 | 3900 |
3897 if (tip_window && front_window == tip_window) | 3901 while (wp && (wp == tip_window || !is_emacs_window (wp))) |
3898 return GetNextWindow (front_window); | 3902 wp = GetNextWindow (wp); |
3899 else | 3903 #endif |
3900 return front_window; | 3904 |
3901 #endif | 3905 return wp; |
3902 } | 3906 } |
3903 | 3907 |
3904 #define mac_window_to_frame(wp) (((mac_output *) GetWRefCon (wp))->mFP) | 3908 #define mac_window_to_frame(wp) (((mac_output *) GetWRefCon (wp))->mFP) |
3905 | 3909 |
3906 /* Return the current position of the mouse. | 3910 /* Return the current position of the mouse. |
3932 Lisp_Object *x, *y; | 3936 Lisp_Object *x, *y; |
3933 unsigned long *time; | 3937 unsigned long *time; |
3934 { | 3938 { |
3935 Point mouse_pos; | 3939 Point mouse_pos; |
3936 int ignore1, ignore2; | 3940 int ignore1, ignore2; |
3937 WindowPtr wp = mac_front_window (); | 3941 WindowPtr wp = front_emacs_window (); |
3938 struct frame *f; | 3942 struct frame *f; |
3939 Lisp_Object frame, tail; | 3943 Lisp_Object frame, tail; |
3940 | 3944 |
3941 if (is_emacs_window(wp)) | 3945 if (is_emacs_window(wp)) |
3942 f = mac_window_to_frame (wp); | 3946 f = mac_window_to_frame (wp); |
4549 enum scroll_bar_part *part; | 4553 enum scroll_bar_part *part; |
4550 Lisp_Object *x, *y; | 4554 Lisp_Object *x, *y; |
4551 unsigned long *time; | 4555 unsigned long *time; |
4552 { | 4556 { |
4553 struct scroll_bar *bar = XSCROLL_BAR (last_mouse_scroll_bar); | 4557 struct scroll_bar *bar = XSCROLL_BAR (last_mouse_scroll_bar); |
4554 WindowPtr wp = mac_front_window (); | 4558 WindowPtr wp = front_emacs_window (); |
4555 Point mouse_pos; | 4559 Point mouse_pos; |
4556 struct frame *f = mac_window_to_frame (wp); | 4560 struct frame *f = mac_window_to_frame (wp); |
4557 int win_y, top_range; | 4561 int win_y, top_range; |
4558 | 4562 |
4559 SetPortWindowPort (wp); | 4563 SetPortWindowPort (wp); |
5034 xim_close_dpy (dpyinfo) | 5038 xim_close_dpy (dpyinfo) |
5035 | 5039 |
5036 */ | 5040 */ |
5037 | 5041 |
5038 | 5042 |
5043 void | |
5044 mac_get_window_bounds (f, inner, outer) | |
5045 struct frame *f; | |
5046 Rect *inner, *outer; | |
5047 { | |
5048 #if TARGET_API_MAC_CARBON | |
5049 GetWindowBounds (FRAME_MAC_WINDOW (f), kWindowContentRgn, inner); | |
5050 GetWindowBounds (FRAME_MAC_WINDOW (f), kWindowStructureRgn, outer); | |
5051 #else /* not TARGET_API_MAC_CARBON */ | |
5052 RgnHandle region = NewRgn (); | |
5053 | |
5054 GetWindowRegion (FRAME_MAC_WINDOW (f), kWindowContentRgn, region); | |
5055 *inner = (*region)->rgnBBox; | |
5056 GetWindowRegion (FRAME_MAC_WINDOW (f), kWindowStructureRgn, region); | |
5057 *outer = (*region)->rgnBBox; | |
5058 DisposeRgn (region); | |
5059 #endif /* not TARGET_API_MAC_CARBON */ | |
5060 } | |
5061 | |
5062 | |
5039 /* Calculate the absolute position in frame F | 5063 /* Calculate the absolute position in frame F |
5040 from its current recorded position values and gravity. */ | 5064 from its current recorded position values and gravity. */ |
5041 | 5065 |
5042 void | 5066 void |
5043 x_calc_absolute_position (f) | 5067 x_calc_absolute_position (f) |
5044 struct frame *f; | 5068 struct frame *f; |
5045 { | 5069 { |
5046 Point pt; | 5070 int width_diff = 0, height_diff = 0; |
5047 int flags = f->size_hint_flags; | 5071 int flags = f->size_hint_flags; |
5048 | 5072 Rect inner, outer; |
5049 pt.h = pt.v = 0; | 5073 |
5050 | 5074 /* We have nothing to do if the current position |
5051 /* Find the position of the outside upper-left corner of | 5075 is already for the top-left corner. */ |
5076 if (! ((flags & XNegative) || (flags & YNegative))) | |
5077 return; | |
5078 | |
5079 /* Find the offsets of the outside upper-left corner of | |
5052 the inner window, with respect to the outer window. */ | 5080 the inner window, with respect to the outer window. */ |
5053 if (f->output_data.mac->parent_desc != FRAME_MAC_DISPLAY_INFO (f)->root_window) | 5081 mac_get_window_bounds (f, &inner, &outer); |
5054 { | 5082 |
5055 GrafPtr savePort; | 5083 width_diff = (outer.right - outer.left) - (inner.right - inner.left); |
5056 GetPort (&savePort); | 5084 height_diff = (outer.bottom - outer.top) - (inner.bottom - inner.top); |
5057 | |
5058 SetPortWindowPort (FRAME_MAC_WINDOW (f)); | |
5059 | |
5060 #if TARGET_API_MAC_CARBON | |
5061 { | |
5062 Rect r; | |
5063 | |
5064 GetWindowPortBounds (FRAME_MAC_WINDOW (f), &r); | |
5065 SetPt(&pt, r.left, r.top); | |
5066 } | |
5067 #else /* not TARGET_API_MAC_CARBON */ | |
5068 SetPt(&pt, FRAME_MAC_WINDOW (f)->portRect.left, FRAME_MAC_WINDOW (f)->portRect.top); | |
5069 #endif /* not TARGET_API_MAC_CARBON */ | |
5070 LocalToGlobal (&pt); | |
5071 SetPort (savePort); | |
5072 } | |
5073 | 5085 |
5074 /* Treat negative positions as relative to the leftmost bottommost | 5086 /* Treat negative positions as relative to the leftmost bottommost |
5075 position that fits on the screen. */ | 5087 position that fits on the screen. */ |
5076 if (flags & XNegative) | 5088 if (flags & XNegative) |
5077 f->left_pos = (FRAME_MAC_DISPLAY_INFO (f)->width | 5089 f->left_pos = (FRAME_MAC_DISPLAY_INFO (f)->width |
5078 - 2 * f->border_width - pt.h | 5090 - width_diff |
5079 - FRAME_PIXEL_WIDTH (f) | 5091 - FRAME_PIXEL_WIDTH (f) |
5080 + f->left_pos); | 5092 + f->left_pos); |
5081 /* NTEMACS_TODO: Subtract menubar height? */ | 5093 |
5082 if (flags & YNegative) | 5094 if (flags & YNegative) |
5083 f->top_pos = (FRAME_MAC_DISPLAY_INFO (f)->height | 5095 f->top_pos = (FRAME_MAC_DISPLAY_INFO (f)->height |
5084 - 2 * f->border_width - pt.v | 5096 - height_diff |
5085 - FRAME_PIXEL_HEIGHT (f) | 5097 - FRAME_PIXEL_HEIGHT (f) |
5086 + f->top_pos); | 5098 + f->top_pos); |
5099 | |
5087 /* The left_pos and top_pos | 5100 /* The left_pos and top_pos |
5088 are now relative to the top and left screen edges, | 5101 are now relative to the top and left screen edges, |
5089 so the flags should correspond. */ | 5102 so the flags should correspond. */ |
5090 f->size_hint_flags &= ~ (XNegative | YNegative); | 5103 f->size_hint_flags &= ~ (XNegative | YNegative); |
5091 } | 5104 } |
5100 x_set_offset (f, xoff, yoff, change_gravity) | 5113 x_set_offset (f, xoff, yoff, change_gravity) |
5101 struct frame *f; | 5114 struct frame *f; |
5102 register int xoff, yoff; | 5115 register int xoff, yoff; |
5103 int change_gravity; | 5116 int change_gravity; |
5104 { | 5117 { |
5105 int modified_top, modified_left; | |
5106 | |
5107 if (change_gravity > 0) | 5118 if (change_gravity > 0) |
5108 { | 5119 { |
5109 f->top_pos = yoff; | 5120 f->top_pos = yoff; |
5110 f->left_pos = xoff; | 5121 f->left_pos = xoff; |
5111 f->size_hint_flags &= ~ (XNegative | YNegative); | 5122 f->size_hint_flags &= ~ (XNegative | YNegative); |
5118 x_calc_absolute_position (f); | 5129 x_calc_absolute_position (f); |
5119 | 5130 |
5120 BLOCK_INPUT; | 5131 BLOCK_INPUT; |
5121 x_wm_set_size_hint (f, (long) 0, 0); | 5132 x_wm_set_size_hint (f, (long) 0, 0); |
5122 | 5133 |
5123 modified_left = f->left_pos; | 5134 #if TARGET_API_MAC_CARBON |
5124 modified_top = f->top_pos; | 5135 MoveWindowStructure (FRAME_MAC_WINDOW (f), f->left_pos, f->top_pos); |
5125 | 5136 /* If the title bar is completely outside the screen, adjust the |
5126 MoveWindow (FRAME_MAC_WINDOW (f), modified_left + 6, | 5137 position. */ |
5127 modified_top + 42, false); | 5138 ConstrainWindowToScreen (FRAME_MAC_WINDOW (f), kWindowTitleBarRgn, |
5139 kWindowConstrainMoveRegardlessOfFit | |
5140 | kWindowConstrainAllowPartial, NULL, NULL); | |
5141 x_real_positions (f, &f->left_pos, &f->top_pos); | |
5142 #else | |
5143 { | |
5144 Rect inner, outer, screen_rect, dummy; | |
5145 RgnHandle region = NewRgn (); | |
5146 | |
5147 mac_get_window_bounds (f, &inner, &outer); | |
5148 f->x_pixels_diff = inner.left - outer.left; | |
5149 f->y_pixels_diff = inner.top - outer.top; | |
5150 MoveWindow (FRAME_MAC_WINDOW (f), f->left_pos + f->x_pixels_diff, | |
5151 f->top_pos + f->y_pixels_diff, false); | |
5152 | |
5153 /* If the title bar is completely outside the screen, adjust the | |
5154 position. The variable `outer' holds the title bar rectangle. | |
5155 The variable `inner' holds slightly smaller one than `outer', | |
5156 so that the calculation of overlapping may not become too | |
5157 strict. */ | |
5158 GetWindowRegion (FRAME_MAC_WINDOW (f), kWindowTitleBarRgn, region); | |
5159 outer = (*region)->rgnBBox; | |
5160 DisposeRgn (region); | |
5161 inner = outer; | |
5162 InsetRect (&inner, 8, 8); | |
5163 screen_rect = qd.screenBits.bounds; | |
5164 screen_rect.top += GetMBarHeight (); | |
5165 | |
5166 if (!SectRect (&inner, &screen_rect, &dummy)) | |
5167 { | |
5168 if (inner.right <= screen_rect.left) | |
5169 f->left_pos = screen_rect.left; | |
5170 else if (inner.left >= screen_rect.right) | |
5171 f->left_pos = screen_rect.right - (outer.right - outer.left); | |
5172 | |
5173 if (inner.bottom <= screen_rect.top) | |
5174 f->top_pos = screen_rect.top; | |
5175 else if (inner.top >= screen_rect.bottom) | |
5176 f->top_pos = screen_rect.bottom - (outer.bottom - outer.top); | |
5177 | |
5178 MoveWindow (FRAME_MAC_WINDOW (f), f->left_pos + f->x_pixels_diff, | |
5179 f->top_pos + f->y_pixels_diff, false); | |
5180 } | |
5181 } | |
5182 #endif | |
5128 | 5183 |
5129 UNBLOCK_INPUT; | 5184 UNBLOCK_INPUT; |
5130 } | 5185 } |
5131 | 5186 |
5132 /* Call this to change the size of frame F's x-window. | 5187 /* Call this to change the size of frame F's x-window. |
6898 #define WNE_SLEEP_AT_RESUME 1 | 6953 #define WNE_SLEEP_AT_RESUME 1 |
6899 | 6954 |
6900 /* true when cannot handle any Mac OS events */ | 6955 /* true when cannot handle any Mac OS events */ |
6901 static int handling_window_update = 0; | 6956 static int handling_window_update = 0; |
6902 | 6957 |
6958 #if 0 | |
6903 /* the flag appl_is_suspended is used both for determining the sleep | 6959 /* the flag appl_is_suspended is used both for determining the sleep |
6904 time to be passed to WaitNextEvent and whether the cursor should be | 6960 time to be passed to WaitNextEvent and whether the cursor should be |
6905 drawn when updating the display. The cursor is turned off when | 6961 drawn when updating the display. The cursor is turned off when |
6906 Emacs is suspended. Redrawing it is unnecessary and what needs to | 6962 Emacs is suspended. Redrawing it is unnecessary and what needs to |
6907 be done depends on whether the cursor lies inside or outside the | 6963 be done depends on whether the cursor lies inside or outside the |
6908 redraw region. So we might as well skip drawing it when Emacs is | 6964 redraw region. So we might as well skip drawing it when Emacs is |
6909 suspended. */ | 6965 suspended. */ |
6910 static Boolean app_is_suspended = false; | 6966 static Boolean app_is_suspended = false; |
6911 static long app_sleep_time = WNE_SLEEP_AT_RESUME; | 6967 static long app_sleep_time = WNE_SLEEP_AT_RESUME; |
6968 #endif | |
6912 | 6969 |
6913 #define EXTRA_STACK_ALLOC (256 * 1024) | 6970 #define EXTRA_STACK_ALLOC (256 * 1024) |
6914 | 6971 |
6915 #define ARGV_STRING_LIST_ID 129 | 6972 #define ARGV_STRING_LIST_ID 129 |
6916 #define ABOUT_ALERT_ID 128 | 6973 #define ABOUT_ALERT_ID 128 |
7233 } | 7290 } |
7234 | 7291 |
7235 static void | 7292 static void |
7236 do_app_resume () | 7293 do_app_resume () |
7237 { | 7294 { |
7295 /* Window-activate events will do the job. */ | |
7296 #if 0 | |
7238 WindowPtr wp; | 7297 WindowPtr wp; |
7239 struct frame *f; | 7298 struct frame *f; |
7240 | 7299 |
7241 wp = mac_front_window (); | 7300 wp = front_emacs_window (); |
7242 if (is_emacs_window (wp)) | 7301 if (wp) |
7243 { | 7302 { |
7244 f = mac_window_to_frame (wp); | 7303 f = mac_window_to_frame (wp); |
7245 | 7304 |
7246 if (f) | 7305 if (f) |
7247 { | 7306 { |
7250 } | 7309 } |
7251 } | 7310 } |
7252 | 7311 |
7253 app_is_suspended = false; | 7312 app_is_suspended = false; |
7254 app_sleep_time = WNE_SLEEP_AT_RESUME; | 7313 app_sleep_time = WNE_SLEEP_AT_RESUME; |
7314 #endif | |
7255 } | 7315 } |
7256 | 7316 |
7257 static void | 7317 static void |
7258 do_app_suspend () | 7318 do_app_suspend () |
7259 { | 7319 { |
7320 /* Window-deactivate events will do the job. */ | |
7321 #if 0 | |
7260 WindowPtr wp; | 7322 WindowPtr wp; |
7261 struct frame *f; | 7323 struct frame *f; |
7262 | 7324 |
7263 wp = mac_front_window (); | 7325 wp = front_emacs_window (); |
7264 if (is_emacs_window (wp)) | 7326 if (wp) |
7265 { | 7327 { |
7266 f = mac_window_to_frame (wp); | 7328 f = mac_window_to_frame (wp); |
7267 | 7329 |
7268 if (f == FRAME_MAC_DISPLAY_INFO (f)->x_focus_frame) | 7330 if (f == FRAME_MAC_DISPLAY_INFO (f)->x_focus_frame) |
7269 { | 7331 { |
7272 } | 7334 } |
7273 } | 7335 } |
7274 | 7336 |
7275 app_is_suspended = true; | 7337 app_is_suspended = true; |
7276 app_sleep_time = WNE_SLEEP_AT_SUSPEND; | 7338 app_sleep_time = WNE_SLEEP_AT_SUSPEND; |
7339 #endif | |
7277 } | 7340 } |
7278 | 7341 |
7279 | 7342 |
7280 static void | 7343 static void |
7281 do_mouse_moved (mouse_pos, f) | 7344 do_mouse_moved (mouse_pos, f) |
7282 Point mouse_pos; | 7345 Point mouse_pos; |
7283 FRAME_PTR *f; | 7346 FRAME_PTR *f; |
7284 { | 7347 { |
7285 WindowPtr wp = mac_front_window (); | 7348 WindowPtr wp = front_emacs_window (); |
7286 struct x_display_info *dpyinfo; | 7349 struct x_display_info *dpyinfo; |
7287 | 7350 |
7288 if (is_emacs_window (wp)) | 7351 if (wp) |
7289 { | 7352 { |
7290 *f = mac_window_to_frame (wp); | 7353 *f = mac_window_to_frame (wp); |
7291 dpyinfo = FRAME_MAC_DISPLAY_INFO (*f); | 7354 dpyinfo = FRAME_MAC_DISPLAY_INFO (*f); |
7292 | 7355 |
7293 if (dpyinfo->mouse_face_hidden) | 7356 if (dpyinfo->mouse_face_hidden) |
7345 do_apple_menu (menu_item); | 7408 do_apple_menu (menu_item); |
7346 break; | 7409 break; |
7347 | 7410 |
7348 default: | 7411 default: |
7349 { | 7412 { |
7350 struct frame *f = mac_window_to_frame (mac_front_window ()); | 7413 struct frame *f = mac_window_to_frame (front_emacs_window ()); |
7351 MenuHandle menu = GetMenuHandle (menu_id); | 7414 MenuHandle menu = GetMenuHandle (menu_id); |
7352 if (menu) | 7415 if (menu) |
7353 { | 7416 { |
7354 UInt32 refcon; | 7417 UInt32 refcon; |
7355 | 7418 |
7398 do_zoom_window (WindowPtr w, int zoom_in_or_out) | 7461 do_zoom_window (WindowPtr w, int zoom_in_or_out) |
7399 { | 7462 { |
7400 GrafPtr save_port; | 7463 GrafPtr save_port; |
7401 Rect zoom_rect, port_rect; | 7464 Rect zoom_rect, port_rect; |
7402 Point top_left; | 7465 Point top_left; |
7403 int w_title_height, columns, rows, width, height, dummy, x, y; | 7466 int w_title_height, columns, rows; |
7404 struct frame *f = mac_window_to_frame (w); | 7467 struct frame *f = mac_window_to_frame (w); |
7405 | 7468 |
7406 GetPort (&save_port); | |
7407 | |
7408 SetPortWindowPort (w); | |
7409 | |
7410 /* Clear window to avoid flicker. */ | |
7411 #if TARGET_API_MAC_CARBON | 7469 #if TARGET_API_MAC_CARBON |
7412 { | 7470 { |
7413 Rect r; | 7471 Point standard_size; |
7414 BitMap bm; | 7472 |
7415 | 7473 standard_size.h = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, DEFAULT_NUM_COLS); |
7416 GetWindowPortBounds (w, &r); | 7474 standard_size.v = FRAME_MAC_DISPLAY_INFO (f)->height; |
7417 EraseRect (&r); | 7475 |
7418 | 7476 if (IsWindowInStandardState (w, &standard_size, &zoom_rect)) |
7419 if (zoom_in_or_out == inZoomOut) | 7477 zoom_in_or_out = inZoomIn; |
7478 else | |
7420 { | 7479 { |
7421 /* calculate height of window's title bar (hard card it for now). */ | 7480 /* Adjust the standard size according to character boundaries. */ |
7422 w_title_height = 20 + GetMBarHeight (); | 7481 |
7423 | 7482 columns = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, zoom_rect.right - zoom_rect.left); |
7424 /* get maximum height of window into zoom_rect.bottom - | 7483 rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, zoom_rect.bottom - zoom_rect.top); |
7425 zoom_rect.top */ | 7484 standard_size.h = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, columns); |
7426 GetQDGlobalsScreenBits (&bm); | 7485 standard_size.v = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, rows); |
7427 zoom_rect = bm.bounds; | 7486 GetWindowBounds (w, kWindowContentRgn, &port_rect); |
7428 zoom_rect.top += w_title_height; | 7487 if (IsWindowInStandardState (w, &standard_size, &zoom_rect) |
7429 InsetRect (&zoom_rect, 8, 4); /* not too tight */ | 7488 && port_rect.left == zoom_rect.left |
7430 | 7489 && port_rect.top == zoom_rect.top) |
7431 zoom_rect.right = zoom_rect.left | 7490 zoom_in_or_out = inZoomIn; |
7432 + FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, DEFAULT_NUM_COLS); | 7491 else |
7433 | 7492 zoom_in_or_out = inZoomOut; |
7434 SetWindowStandardState (w, &zoom_rect); | |
7435 } | 7493 } |
7494 | |
7495 ZoomWindowIdeal (w, zoom_in_or_out, &standard_size); | |
7436 } | 7496 } |
7437 #else /* not TARGET_API_MAC_CARBON */ | 7497 #else /* not TARGET_API_MAC_CARBON */ |
7498 GetPort (&save_port); | |
7499 | |
7500 SetPortWindowPort (w); | |
7501 | |
7502 /* Clear window to avoid flicker. */ | |
7438 EraseRect (&(w->portRect)); | 7503 EraseRect (&(w->portRect)); |
7439 if (zoom_in_or_out == inZoomOut) | 7504 if (zoom_in_or_out == inZoomOut) |
7440 { | 7505 { |
7441 SetPt (&top_left, w->portRect.left, w->portRect.top); | 7506 SetPt (&top_left, w->portRect.left, w->portRect.top); |
7442 LocalToGlobal (&top_left); | 7507 LocalToGlobal (&top_left); |
7451 InsetRect (&zoom_rect, 8, 4); /* not too tight */ | 7516 InsetRect (&zoom_rect, 8, 4); /* not too tight */ |
7452 | 7517 |
7453 zoom_rect.right = zoom_rect.left | 7518 zoom_rect.right = zoom_rect.left |
7454 + FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, DEFAULT_NUM_COLS); | 7519 + FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, DEFAULT_NUM_COLS); |
7455 | 7520 |
7521 /* Adjust the standard size according to character boundaries. */ | |
7522 rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, zoom_rect.bottom - zoom_rect.top); | |
7523 zoom_rect.bottom = | |
7524 zoom_rect.top + FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, rows); | |
7525 | |
7456 (**((WStateDataHandle) ((WindowPeek) w)->dataHandle)).stdState | 7526 (**((WStateDataHandle) ((WindowPeek) w)->dataHandle)).stdState |
7457 = zoom_rect; | 7527 = zoom_rect; |
7458 } | 7528 } |
7529 | |
7530 ZoomWindow (w, zoom_in_or_out, w == front_emacs_window ()); | |
7531 | |
7532 SetPort (save_port); | |
7459 #endif /* not TARGET_API_MAC_CARBON */ | 7533 #endif /* not TARGET_API_MAC_CARBON */ |
7460 | |
7461 ZoomWindow (w, zoom_in_or_out, w == mac_front_window ()); | |
7462 | 7534 |
7463 /* retrieve window size and update application values */ | 7535 /* retrieve window size and update application values */ |
7464 #if TARGET_API_MAC_CARBON | 7536 #if TARGET_API_MAC_CARBON |
7465 GetWindowPortBounds (w, &port_rect); | 7537 GetWindowPortBounds (w, &port_rect); |
7466 #else | 7538 #else |
7467 port_rect = w->portRect; | 7539 port_rect = w->portRect; |
7468 #endif | 7540 #endif |
7469 rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, port_rect.bottom - port_rect.top); | 7541 rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, port_rect.bottom - port_rect.top); |
7470 columns = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, port_rect.right - port_rect.left); | 7542 columns = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, port_rect.right - port_rect.left); |
7471 x_set_window_size (f, 0, columns, rows); | 7543 x_set_window_size (f, 0, columns, rows); |
7472 | 7544 x_real_positions (f, &f->left_pos, &f->top_pos); |
7473 SetPort (save_port); | |
7474 } | 7545 } |
7475 | 7546 |
7476 /* Initialize Drag And Drop to allow files to be dropped onto emacs frames */ | 7547 /* Initialize Drag And Drop to allow files to be dropped onto emacs frames */ |
7477 static OSErr | 7548 static OSErr |
7478 init_mac_drag_n_drop () | 7549 init_mac_drag_n_drop () |
8018 #if !USE_CARBON_EVENTS | 8089 #if !USE_CARBON_EVENTS |
8019 event_mask = everyEvent; | 8090 event_mask = everyEvent; |
8020 if (NILP (Fboundp (Qmac_ready_for_drag_n_drop))) | 8091 if (NILP (Fboundp (Qmac_ready_for_drag_n_drop))) |
8021 event_mask -= highLevelEventMask; | 8092 event_mask -= highLevelEventMask; |
8022 | 8093 |
8023 while (WaitNextEvent (event_mask, &er, | 8094 while (WaitNextEvent (event_mask, &er, 0L, NULL)) |
8024 (expected ? app_sleep_time : 0L), NULL)) | 8095 #else /* USE_CARBON_EVENTS */ |
8025 #else | 8096 while (!ReceiveNextEvent (0, NULL, kEventDurationNoWait, |
8026 while (!ReceiveNextEvent (0, NULL, | |
8027 (expected ? TicksToEventTime (app_sleep_time) : 0), | |
8028 kEventRemoveFromQueue, &eventRef)) | 8097 kEventRemoveFromQueue, &eventRef)) |
8029 #endif /* !USE_CARBON_EVENTS */ | 8098 #endif /* USE_CARBON_EVENTS */ |
8030 { | 8099 { |
8031 int do_help = 0; | 8100 int do_help = 0; |
8032 struct frame *f; | 8101 struct frame *f; |
8033 | |
8034 expected = 0; | |
8035 | 8102 |
8036 /* It is necessary to set this (additional) argument slot of an | 8103 /* It is necessary to set this (additional) argument slot of an |
8037 event to nil because keyboard.c protects incompletely | 8104 event to nil because keyboard.c protects incompletely |
8038 processed event from being garbage collected by placing them | 8105 processed event from being garbage collected by placing them |
8039 in the kbd_buffer_gcpro vector. */ | 8106 in the kbd_buffer_gcpro vector. */ |
8053 GetEventParameter(eventRef, kEventParamDirectObject, | 8120 GetEventParameter(eventRef, kEventParamDirectObject, |
8054 typeWindowRef, NULL, sizeof(WindowPtr), | 8121 typeWindowRef, NULL, sizeof(WindowPtr), |
8055 NULL, &window_ptr); | 8122 NULL, &window_ptr); |
8056 f = mac_window_to_frame (window_ptr); | 8123 f = mac_window_to_frame (window_ptr); |
8057 if (f && !f->async_iconified) | 8124 if (f && !f->async_iconified) |
8058 { | 8125 x_real_positions (f, &f->left_pos, &f->top_pos); |
8059 int x, y; | |
8060 | |
8061 x_real_positions (f, &x, &y); | |
8062 f->left_pos = x; | |
8063 f->top_pos = y; | |
8064 } | |
8065 SendEventToEventTarget (eventRef, toolbox_dispatcher); | 8126 SendEventToEventTarget (eventRef, toolbox_dispatcher); |
8066 } | 8127 } |
8067 break; | 8128 break; |
8068 case kEventClassMouse: | 8129 case kEventClassMouse: |
8069 if (GetEventKind (eventRef) == kEventMouseWheelMoved) | 8130 if (GetEventKind (eventRef) == kEventMouseWheelMoved) |
8070 { | 8131 { |
8071 SInt32 delta; | 8132 SInt32 delta; |
8072 Point point; | 8133 Point point; |
8073 WindowPtr window_ptr = mac_front_window (); | 8134 WindowPtr window_ptr = front_emacs_window (); |
8074 | 8135 |
8075 if (!IsValidWindowPtr (window_ptr)) | 8136 if (!IsValidWindowPtr (window_ptr)) |
8076 { | 8137 { |
8077 SysBeep(1); | 8138 SysBeep(1); |
8078 break; | 8139 break; |
8130 window_ptr = FRAME_MAC_WINDOW (last_mouse_frame); | 8191 window_ptr = FRAME_MAC_WINDOW (last_mouse_frame); |
8131 part_code = inContent; | 8192 part_code = inContent; |
8132 } | 8193 } |
8133 else | 8194 else |
8134 { | 8195 { |
8135 window_ptr = FrontWindow (); | 8196 part_code = FindWindow (er.where, &window_ptr); |
8136 if (tip_window && window_ptr == tip_window) | 8197 if (tip_window && window_ptr == tip_window) |
8137 { | 8198 { |
8138 HideWindow (tip_window); | 8199 HideWindow (tip_window); |
8139 window_ptr = FrontWindow (); | 8200 part_code = FindWindow (er.where, &window_ptr); |
8140 } | 8201 } |
8141 | |
8142 if (!is_emacs_window (window_ptr)) | |
8143 break; | |
8144 | |
8145 part_code = FindWindow (er.where, &window_ptr); | |
8146 } | 8202 } |
8203 | |
8204 if (er.what != mouseDown && part_code != inContent) | |
8205 break; | |
8147 | 8206 |
8148 switch (part_code) | 8207 switch (part_code) |
8149 { | 8208 { |
8150 case inMenuBar: | 8209 case inMenuBar: |
8151 if (er.what == mouseDown) | 8210 f = mac_window_to_frame (front_emacs_window ()); |
8152 { | 8211 saved_menu_event_location = er.where; |
8153 f = mac_window_to_frame (mac_front_window ()); | 8212 inev.kind = MENU_BAR_ACTIVATE_EVENT; |
8154 saved_menu_event_location = er.where; | 8213 XSETFRAME (inev.frame_or_window, f); |
8155 inev.kind = MENU_BAR_ACTIVATE_EVENT; | |
8156 XSETFRAME (inev.frame_or_window, f); | |
8157 } | |
8158 break; | 8214 break; |
8159 | 8215 |
8160 case inContent: | 8216 case inContent: |
8161 if (window_ptr != mac_front_window ()) | 8217 if (window_ptr != front_emacs_window ()) |
8162 SelectWindow (window_ptr); | 8218 SelectWindow (window_ptr); |
8163 else | 8219 else |
8164 { | 8220 { |
8165 SInt16 control_part_code; | 8221 SInt16 control_part_code; |
8166 ControlHandle ch; | 8222 ControlHandle ch; |
8253 if (!tool_bar_p) | 8309 if (!tool_bar_p) |
8254 last_tool_bar_item = -1; | 8310 last_tool_bar_item = -1; |
8255 } | 8311 } |
8256 else | 8312 else |
8257 { | 8313 { |
8258 if (dpyinfo->grabbed & (1 << inev.code) == 0) | 8314 if ((dpyinfo->grabbed & (1 << inev.code)) == 0) |
8259 /* If a button is released though it was not | 8315 /* If a button is released though it was not |
8260 previously pressed, that would be because | 8316 previously pressed, that would be because |
8261 of multi-button emulation. */ | 8317 of multi-button emulation. */ |
8262 dpyinfo->grabbed = 0; | 8318 dpyinfo->grabbed = 0; |
8263 else | 8319 else |
8276 } | 8332 } |
8277 break; | 8333 break; |
8278 | 8334 |
8279 case inDrag: | 8335 case inDrag: |
8280 #if TARGET_API_MAC_CARBON | 8336 #if TARGET_API_MAC_CARBON |
8281 if (er.what == mouseDown) | 8337 DragWindow (window_ptr, er.where, NULL); |
8282 { | |
8283 BitMap bm; | |
8284 | |
8285 GetQDGlobalsScreenBits (&bm); | |
8286 DragWindow (window_ptr, er.where, &bm.bounds); | |
8287 } | |
8288 #else /* not TARGET_API_MAC_CARBON */ | 8338 #else /* not TARGET_API_MAC_CARBON */ |
8289 DragWindow (window_ptr, er.where, &qd.screenBits.bounds); | 8339 DragWindow (window_ptr, er.where, &qd.screenBits.bounds); |
8290 #endif /* not TARGET_API_MAC_CARBON */ | 8340 #endif /* not TARGET_API_MAC_CARBON */ |
8291 /* Update the frame parameters. */ | 8341 /* Update the frame parameters. */ |
8292 { | 8342 { |
8293 struct frame *f = mac_window_to_frame (window_ptr); | 8343 struct frame *f = mac_window_to_frame (window_ptr); |
8344 | |
8294 if (f && !f->async_iconified) | 8345 if (f && !f->async_iconified) |
8295 { | 8346 x_real_positions (f, &f->left_pos, &f->top_pos); |
8296 int x, y; | |
8297 | |
8298 x_real_positions (f, &x, &y); | |
8299 f->left_pos = x; | |
8300 f->top_pos = y; | |
8301 } | |
8302 } | 8347 } |
8303 break; | 8348 break; |
8304 | 8349 |
8305 case inGoAway: | 8350 case inGoAway: |
8306 if (TrackGoAway (window_ptr, er.where)) | 8351 if (TrackGoAway (window_ptr, er.where)) |
8311 } | 8356 } |
8312 break; | 8357 break; |
8313 | 8358 |
8314 /* window resize handling added --ben */ | 8359 /* window resize handling added --ben */ |
8315 case inGrow: | 8360 case inGrow: |
8316 if (er.what == mouseDown) | 8361 do_grow_window (window_ptr, &er); |
8317 { | 8362 break; |
8318 do_grow_window(window_ptr, &er); | |
8319 break; | |
8320 } | |
8321 | 8363 |
8322 /* window zoom handling added --ben */ | 8364 /* window zoom handling added --ben */ |
8323 case inZoomIn: | 8365 case inZoomIn: |
8324 case inZoomOut: | 8366 case inZoomOut: |
8325 if (TrackBox (window_ptr, er.where, part_code)) | 8367 if (TrackBox (window_ptr, er.where, part_code)) |
8458 != eventNotHandledErr) | 8500 != eventNotHandledErr) |
8459 break; | 8501 break; |
8460 #endif | 8502 #endif |
8461 | 8503 |
8462 #if TARGET_API_MAC_CARBON | 8504 #if TARGET_API_MAC_CARBON |
8463 if (!IsValidWindowPtr (mac_front_window ())) | 8505 if (!IsValidWindowPtr (front_emacs_window ())) |
8464 { | 8506 { |
8465 SysBeep (1); | 8507 SysBeep (1); |
8466 break; | 8508 break; |
8467 } | 8509 } |
8468 #endif | 8510 #endif |
8562 inev.modifiers = mac_event_to_emacs_modifiers (eventRef); | 8604 inev.modifiers = mac_event_to_emacs_modifiers (eventRef); |
8563 #else | 8605 #else |
8564 inev.modifiers = mac_to_emacs_modifiers (er.modifiers); | 8606 inev.modifiers = mac_to_emacs_modifiers (er.modifiers); |
8565 #endif | 8607 #endif |
8566 XSETFRAME (inev.frame_or_window, | 8608 XSETFRAME (inev.frame_or_window, |
8567 mac_window_to_frame (mac_front_window ())); | 8609 mac_window_to_frame (front_emacs_window ())); |
8568 inev.timestamp = er.when * (1000 / 60); /* ticks to milliseconds */ | 8610 inev.timestamp = er.when * (1000 / 60); /* ticks to milliseconds */ |
8569 break; | 8611 break; |
8570 | 8612 |
8571 case kHighLevelEvent: | 8613 case kHighLevelEvent: |
8572 drag_and_drop_file_list = Qnil; | 8614 drag_and_drop_file_list = Qnil; |
8579 { | 8621 { |
8580 struct frame *f = NULL; | 8622 struct frame *f = NULL; |
8581 WindowPtr wp; | 8623 WindowPtr wp; |
8582 Lisp_Object frame; | 8624 Lisp_Object frame; |
8583 | 8625 |
8584 wp = mac_front_window (); | 8626 wp = front_emacs_window (); |
8585 | 8627 |
8586 if (!wp) | 8628 if (!wp) |
8587 { | 8629 { |
8588 struct frame *f = XFRAME (XCAR (Vframe_list)); | 8630 struct frame *f = XFRAME (XCAR (Vframe_list)); |
8589 CollapseWindow (FRAME_MAC_WINDOW (f), false); | 8631 CollapseWindow (FRAME_MAC_WINDOW (f), false); |
8590 wp = mac_front_window (); | 8632 wp = front_emacs_window (); |
8591 } | 8633 } |
8592 | 8634 |
8593 if (wp && is_emacs_window (wp)) | 8635 if (wp) |
8594 f = mac_window_to_frame (wp); | 8636 f = mac_window_to_frame (wp); |
8595 | 8637 |
8596 inev.kind = DRAG_N_DROP_EVENT; | 8638 inev.kind = DRAG_N_DROP_EVENT; |
8597 inev.code = 0; | 8639 inev.code = 0; |
8598 inev.timestamp = er.when * (1000 / 60); | 8640 inev.timestamp = er.when * (1000 / 60); |
9045 e.kind = ASCII_KEYSTROKE_EVENT; | 9087 e.kind = ASCII_KEYSTROKE_EVENT; |
9046 e.code = quit_char; | 9088 e.code = quit_char; |
9047 e.arg = Qnil; | 9089 e.arg = Qnil; |
9048 e.modifiers = NULL; | 9090 e.modifiers = NULL; |
9049 e.timestamp = EventTimeToTicks (GetEventTime (event)) * (1000/60); | 9091 e.timestamp = EventTimeToTicks (GetEventTime (event)) * (1000/60); |
9050 XSETFRAME (e.frame_or_window, mac_window_to_frame (mac_front_window ())); | 9092 XSETFRAME (e.frame_or_window, mac_window_to_frame (front_emacs_window ())); |
9051 /* Remove event from queue to prevent looping. */ | 9093 /* Remove event from queue to prevent looping. */ |
9052 RemoveEventFromQueue (GetMainEventQueue (), event); | 9094 RemoveEventFromQueue (GetMainEventQueue (), event); |
9053 ReleaseEvent (event); | 9095 ReleaseEvent (event); |
9054 kbd_buffer_store_event (&e); | 9096 kbd_buffer_store_event (&e); |
9055 } | 9097 } |