aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorYAMAMOTO Mitsuharu2005-08-25 08:20:43 +0000
committerYAMAMOTO Mitsuharu2005-08-25 08:20:43 +0000
commit1f98fbb49f5d2767da43fe1cc45d521c8c660034 (patch)
treec55ccfb1613bfee962313dfcef06d242865eabc5 /src
parentfca32d15e29e4817856e2e380433cc2b79e8f39c (diff)
downloademacs-1f98fbb49f5d2767da43fe1cc45d521c8c660034.tar.gz
emacs-1f98fbb49f5d2767da43fe1cc45d521c8c660034.zip
(mac_copy_area, mac_copy_area_with_mask): Restore background color.
(mac_handle_visibility_change): New function. (x_make_frame_invisible, x_iconify_frame) (XTread_socket) [!USE_CARBON_EVENTS]: Use it. [USE_CARBON_EVENTS] (mac_handle_window_event) (install_window_handler): Handle visibilty change events. (x_make_frame_visible): Don't reposition window if it is iconified or asked for visible before. Select and uncollapse window when it is made visible. (x_make_frame_invisible): Don't reset x_highlight_frame. (x_iconify_frame): Likewise. Make invisible frame visible before it is iconified. (read_socket_inev): Move variable outside #if USE_CARBON_EVENTS. (do_window_update): Don't change visibility of invisible frame.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog21
-rw-r--r--src/macterm.c206
2 files changed, 174 insertions, 53 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 8ed2fd4c674..7223826cd08 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,24 @@
12005-08-25 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
2
3 * keyboard.c (kbd_buffer_get_event) [MAC_OS]: Make events for
4 ICONIFY/DEICONIFY_EVENT.
5
6 * macterm.c (mac_copy_area, mac_copy_area_with_mask): Restore
7 background color.
8 (mac_handle_visibility_change): New function.
9 (x_make_frame_invisible, x_iconify_frame)
10 (XTread_socket) [!USE_CARBON_EVENTS]: Use it.
11 [USE_CARBON_EVENTS] (mac_handle_window_event)
12 (install_window_handler): Handle visibilty change events.
13 (x_make_frame_visible): Don't reposition window if it is iconified
14 or asked for visible before. Select and uncollapse window when it
15 is made visible.
16 (x_make_frame_invisible): Don't reset x_highlight_frame.
17 (x_iconify_frame): Likewise. Make invisible frame visible before
18 it is iconified.
19 (read_socket_inev): Move variable outside #if USE_CARBON_EVENTS.
20 (do_window_update): Don't change visibility of invisible frame.
21
12005-08-22 Juri Linkov <juri@jurta.org> 222005-08-22 Juri Linkov <juri@jurta.org>
2 23
3 * term.c (turn_on_face): Check for TS_set_foreground and 24 * term.c (turn_on_face): Check for TS_set_foreground and
diff --git a/src/macterm.c b/src/macterm.c
index fd76e164d49..3c7af5f1cef 100644
--- a/src/macterm.c
+++ b/src/macterm.c
@@ -796,6 +796,8 @@ mac_copy_area (display, src, dest, gc, src_x, src_y, width, height, dest_x,
796 &src_r, &dest_r, srcCopy, 0); 796 &src_r, &dest_r, srcCopy, 0);
797#endif /* not TARGET_API_MAC_CARBON */ 797#endif /* not TARGET_API_MAC_CARBON */
798 UnlockPixels (GetGWorldPixMap (src)); 798 UnlockPixels (GetGWorldPixMap (src));
799
800 RGBBackColor (GC_BACK_COLOR (MAC_WINDOW_NORMAL_GC (dest)));
799} 801}
800 802
801 803
@@ -834,6 +836,8 @@ mac_copy_area_with_mask (display, src, mask, dest, gc, src_x, src_y,
834#endif /* not TARGET_API_MAC_CARBON */ 836#endif /* not TARGET_API_MAC_CARBON */
835 UnlockPixels (GetGWorldPixMap (mask)); 837 UnlockPixels (GetGWorldPixMap (mask));
836 UnlockPixels (GetGWorldPixMap (src)); 838 UnlockPixels (GetGWorldPixMap (src));
839
840 RGBBackColor (GC_BACK_COLOR (MAC_WINDOW_NORMAL_GC (dest)));
837} 841}
838 842
839 843
@@ -5646,6 +5650,53 @@ XTframe_raise_lower (f, raise_flag)
5646 5650
5647/* Change of visibility. */ 5651/* Change of visibility. */
5648 5652
5653static void
5654mac_handle_visibility_change (f)
5655 struct frame *f;
5656{
5657 WindowPtr wp = FRAME_MAC_WINDOW (f);
5658 int visible = 0, iconified = 0;
5659 struct input_event buf;
5660
5661 if (IsWindowVisible (wp))
5662 if (IsWindowCollapsed (wp))
5663 iconified = 1;
5664 else
5665 visible = 1;
5666
5667 if (!f->async_visible && visible)
5668 {
5669 if (f->iconified)
5670 {
5671 /* wait_reading_process_output will notice this and update
5672 the frame's display structures. If we were made
5673 invisible, we should not set garbaged, because that stops
5674 redrawing on Update events. */
5675 SET_FRAME_GARBAGED (f);
5676
5677 EVENT_INIT (buf);
5678 buf.kind = DEICONIFY_EVENT;
5679 XSETFRAME (buf.frame_or_window, f);
5680 kbd_buffer_store_event (&buf);
5681 }
5682 else if (! NILP (Vframe_list) && ! NILP (XCDR (Vframe_list)))
5683 /* Force a redisplay sooner or later to update the
5684 frame titles in case this is the second frame. */
5685 record_asynch_buffer_change ();
5686 }
5687 else if (f->async_visible && !visible)
5688 if (iconified)
5689 {
5690 EVENT_INIT (buf);
5691 buf.kind = ICONIFY_EVENT;
5692 XSETFRAME (buf.frame_or_window, f);
5693 kbd_buffer_store_event (&buf);
5694 }
5695
5696 f->async_visible = visible;
5697 f->async_iconified = iconified;
5698}
5699
5649/* This tries to wait until the frame is really visible. 5700/* This tries to wait until the frame is really visible.
5650 However, if the window manager asks the user where to position 5701 However, if the window manager asks the user where to position
5651 the frame, this will return before the user finishes doing that. 5702 the frame, this will return before the user finishes doing that.
@@ -5670,29 +5721,32 @@ x_make_frame_visible (f)
5670 before the window gets really visible. */ 5721 before the window gets really visible. */
5671 if (! FRAME_ICONIFIED_P (f) 5722 if (! FRAME_ICONIFIED_P (f)
5672 && ! f->output_data.mac->asked_for_visible) 5723 && ! f->output_data.mac->asked_for_visible)
5673 x_set_offset (f, f->left_pos, f->top_pos, 0);
5674
5675 f->output_data.mac->asked_for_visible = 1;
5676
5677#if TARGET_API_MAC_CARBON 5724#if TARGET_API_MAC_CARBON
5678 if (!(FRAME_SIZE_HINTS (f)->flags & (USPosition | PPosition))) 5725 if (!(FRAME_SIZE_HINTS (f)->flags & (USPosition | PPosition)))
5679 { 5726 {
5680 struct frame *sf = SELECTED_FRAME (); 5727 struct frame *sf = SELECTED_FRAME ();
5681 if (!FRAME_MAC_P (sf)) 5728 if (!FRAME_MAC_P (sf))
5682 RepositionWindow (FRAME_MAC_WINDOW (f), NULL, 5729 RepositionWindow (FRAME_MAC_WINDOW (f), NULL,
5683 kWindowCenterOnMainScreen); 5730 kWindowCenterOnMainScreen);
5684 else 5731 else
5685 RepositionWindow (FRAME_MAC_WINDOW (f), 5732 RepositionWindow (FRAME_MAC_WINDOW (f),
5686 FRAME_MAC_WINDOW (sf), 5733 FRAME_MAC_WINDOW (sf),
5687#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020 5734#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020
5688 kWindowCascadeStartAtParentWindowScreen 5735 kWindowCascadeStartAtParentWindowScreen
5689#else 5736#else
5690 kWindowCascadeOnParentWindowScreen 5737 kWindowCascadeOnParentWindowScreen
5691#endif 5738#endif
5692 ); 5739 );
5693 x_real_positions (f, &f->left_pos, &f->top_pos); 5740 x_real_positions (f, &f->left_pos, &f->top_pos);
5694 } 5741 }
5742 else
5695#endif 5743#endif
5744 x_set_offset (f, f->left_pos, f->top_pos, 0);
5745
5746 f->output_data.mac->asked_for_visible = 1;
5747
5748 SelectWindow (FRAME_MAC_WINDOW (f));
5749 CollapseWindow (FRAME_MAC_WINDOW (f), false);
5696 ShowWindow (FRAME_MAC_WINDOW (f)); 5750 ShowWindow (FRAME_MAC_WINDOW (f));
5697 } 5751 }
5698 5752
@@ -5751,9 +5805,14 @@ void
5751x_make_frame_invisible (f) 5805x_make_frame_invisible (f)
5752 struct frame *f; 5806 struct frame *f;
5753{ 5807{
5808 /* A deactivate event does not occur when the last visible frame is
5809 made invisible. So if we clear the highlight here, it will not
5810 be rehighlighted when it is made visible. */
5811#if 0
5754 /* Don't keep the highlight on an invisible frame. */ 5812 /* Don't keep the highlight on an invisible frame. */
5755 if (FRAME_MAC_DISPLAY_INFO (f)->x_highlight_frame == f) 5813 if (FRAME_MAC_DISPLAY_INFO (f)->x_highlight_frame == f)
5756 FRAME_MAC_DISPLAY_INFO (f)->x_highlight_frame = 0; 5814 FRAME_MAC_DISPLAY_INFO (f)->x_highlight_frame = 0;
5815#endif
5757 5816
5758 BLOCK_INPUT; 5817 BLOCK_INPUT;
5759 5818
@@ -5766,17 +5825,11 @@ x_make_frame_invisible (f)
5766 5825
5767 HideWindow (FRAME_MAC_WINDOW (f)); 5826 HideWindow (FRAME_MAC_WINDOW (f));
5768 5827
5769 /* We can't distinguish this from iconification
5770 just by the event that we get from the server.
5771 So we can't win using the usual strategy of letting
5772 FRAME_SAMPLE_VISIBILITY set this. So do it by hand,
5773 and synchronize with the server to make sure we agree. */
5774 f->visible = 0;
5775 FRAME_ICONIFIED_P (f) = 0;
5776 f->async_visible = 0;
5777 f->async_iconified = 0;
5778
5779 UNBLOCK_INPUT; 5828 UNBLOCK_INPUT;
5829
5830#if !USE_CARBON_EVENTS
5831 mac_handle_visibility_change (f);
5832#endif
5780} 5833}
5781 5834
5782/* Change window state from mapped to iconified. */ 5835/* Change window state from mapped to iconified. */
@@ -5785,21 +5838,37 @@ void
5785x_iconify_frame (f) 5838x_iconify_frame (f)
5786 struct frame *f; 5839 struct frame *f;
5787{ 5840{
5841 OSErr err;
5842
5843 /* A deactivate event does not occur when the last visible frame is
5844 iconified. So if we clear the highlight here, it will not be
5845 rehighlighted when it is deiconified. */
5846#if 0
5788 /* Don't keep the highlight on an invisible frame. */ 5847 /* Don't keep the highlight on an invisible frame. */
5789 if (FRAME_MAC_DISPLAY_INFO (f)->x_highlight_frame == f) 5848 if (FRAME_MAC_DISPLAY_INFO (f)->x_highlight_frame == f)
5790 FRAME_MAC_DISPLAY_INFO (f)->x_highlight_frame = 0; 5849 FRAME_MAC_DISPLAY_INFO (f)->x_highlight_frame = 0;
5850#endif
5791 5851
5792#if 0
5793 /* Review: Since window is still visible in dock, still allow updates? */
5794 if (f->async_iconified) 5852 if (f->async_iconified)
5795 return; 5853 return;
5796#endif
5797 5854
5798 BLOCK_INPUT; 5855 BLOCK_INPUT;
5799 5856
5800 CollapseWindow (FRAME_MAC_WINDOW (f), true); 5857 FRAME_SAMPLE_VISIBILITY (f);
5858
5859 if (! FRAME_VISIBLE_P (f))
5860 ShowWindow (FRAME_MAC_WINDOW (f));
5861
5862 err = CollapseWindow (FRAME_MAC_WINDOW (f), true);
5801 5863
5802 UNBLOCK_INPUT; 5864 UNBLOCK_INPUT;
5865
5866 if (err != noErr)
5867 error ("Can't notify window manager of iconification");
5868
5869#if !USE_CARBON_EVENTS
5870 mac_handle_visibility_change (f);
5871#endif
5803} 5872}
5804 5873
5805 5874
@@ -7188,7 +7257,7 @@ x_load_font (f, fontname, size)
7188 7257
7189 /* Set global flag fonts_changed_p to non-zero if the font loaded 7258 /* Set global flag fonts_changed_p to non-zero if the font loaded
7190 has a character with a smaller width than any other character 7259 has a character with a smaller width than any other character
7191 before, or if the font loaded has a smalle>r height than any 7260 before, or if the font loaded has a smaller height than any
7192 other font loaded before. If this happens, it will make a 7261 other font loaded before. If this happens, it will make a
7193 glyph matrix reallocation necessary. */ 7262 glyph matrix reallocation necessary. */
7194 fonts_changed_p |= x_compute_min_glyph_bounds (f); 7263 fonts_changed_p |= x_compute_min_glyph_bounds (f);
@@ -7319,12 +7388,12 @@ Lisp_Object Vmac_pass_command_to_system;
7319/* If Non-nil, the Mac "Control" key is passed on to the Mac Toolbox 7388/* If Non-nil, the Mac "Control" key is passed on to the Mac Toolbox
7320 for processing before Emacs sees it. */ 7389 for processing before Emacs sees it. */
7321Lisp_Object Vmac_pass_control_to_system; 7390Lisp_Object Vmac_pass_control_to_system;
7391#endif
7322 7392
7323/* Points to the variable `inev' in the function XTread_socket. It is 7393/* Points to the variable `inev' in the function XTread_socket. It is
7324 used for passing an input event to the function back from 7394 used for passing an input event to the function back from
7325 Carbon/Apple event handlers. */ 7395 Carbon/Apple event handlers. */
7326static struct input_event *read_socket_inev = NULL; 7396static struct input_event *read_socket_inev = NULL;
7327#endif
7328 7397
7329/* Set in term/mac-win.el to indicate that event loop can now generate 7398/* Set in term/mac-win.el to indicate that event loop can now generate
7330 drag and drop events. */ 7399 drag and drop events. */
@@ -7609,37 +7678,30 @@ do_window_update (WindowPtr win)
7609 { 7678 {
7610 if (f->async_visible == 0) 7679 if (f->async_visible == 0)
7611 { 7680 {
7681 /* Update events may occur when a frame gets iconified. */
7682#if 0
7612 f->async_visible = 1; 7683 f->async_visible = 1;
7613 f->async_iconified = 0; 7684 f->async_iconified = 0;
7614 SET_FRAME_GARBAGED (f); 7685 SET_FRAME_GARBAGED (f);
7615 7686#endif
7616 /* An update event is equivalent to MapNotify on X, so report
7617 visibility changes properly. */
7618 if (! NILP(Vframe_list) && ! NILP (XCDR (Vframe_list)))
7619 /* Force a redisplay sooner or later to update the
7620 frame titles in case this is the second frame. */
7621 record_asynch_buffer_change ();
7622 } 7687 }
7623 else 7688 else
7624 { 7689 {
7625 Rect r; 7690 Rect r;
7626
7627#if TARGET_API_MAC_CARBON 7691#if TARGET_API_MAC_CARBON
7628 { 7692 RgnHandle region = NewRgn ();
7629 RgnHandle region = NewRgn ();
7630 7693
7631 GetPortVisibleRegion (GetWindowPort (win), region); 7694 GetPortVisibleRegion (GetWindowPort (win), region);
7632 GetRegionBounds (region, &r); 7695 GetRegionBounds (region, &r);
7633 expose_frame (f, r.left, r.top, r.right - r.left, r.bottom - r.top); 7696 expose_frame (f, r.left, r.top, r.right - r.left, r.bottom - r.top);
7634 UpdateControls (win, region); 7697 UpdateControls (win, region);
7635 DisposeRgn (region); 7698 DisposeRgn (region);
7636 }
7637#else 7699#else
7638 r = (*win->visRgn)->rgnBBox; 7700 r = (*win->visRgn)->rgnBBox;
7639 expose_frame (f, r.left, r.top, r.right - r.left, r.bottom - r.top); 7701 expose_frame (f, r.left, r.top, r.right - r.left, r.bottom - r.top);
7640 UpdateControls (win, win->visRgn); 7702 UpdateControls (win, win->visRgn);
7641#endif 7703#endif
7642 } 7704 }
7643 } 7705 }
7644 7706
7645 EndUpdate (win); 7707 EndUpdate (win);
@@ -8171,6 +8233,17 @@ mac_handle_window_event (next_handler, event, data)
8171 return noErr; 8233 return noErr;
8172 } 8234 }
8173 break; 8235 break;
8236
8237 case kEventWindowShown:
8238 case kEventWindowHidden:
8239 case kEventWindowExpanded:
8240 case kEventWindowCollapsed:
8241 result = CallNextEventHandler (next_handler, event);
8242
8243 mac_handle_visibility_change (mac_window_to_frame (wp));
8244 return noErr;
8245
8246 break;
8174 } 8247 }
8175 8248
8176 return eventNotHandledErr; 8249 return eventNotHandledErr;
@@ -8246,7 +8319,11 @@ install_window_handler (window)
8246#if USE_CARBON_EVENTS 8319#if USE_CARBON_EVENTS
8247 EventTypeSpec specs_window[] = 8320 EventTypeSpec specs_window[] =
8248 {{kEventClassWindow, kEventWindowUpdate}, 8321 {{kEventClassWindow, kEventWindowUpdate},
8249 {kEventClassWindow, kEventWindowBoundsChanging}}; 8322 {kEventClassWindow, kEventWindowBoundsChanging},
8323 {kEventClassWindow, kEventWindowShown},
8324 {kEventClassWindow, kEventWindowHidden},
8325 {kEventClassWindow, kEventWindowExpanded},
8326 {kEventClassWindow, kEventWindowCollapsed}};
8250 EventTypeSpec specs_mouse[] = {{kEventClassMouse, kEventMouseWheelMoved}}; 8327 EventTypeSpec specs_mouse[] = {{kEventClassMouse, kEventMouseWheelMoved}};
8251 static EventHandlerUPP handle_window_eventUPP = NULL; 8328 static EventHandlerUPP handle_window_eventUPP = NULL;
8252 static EventHandlerUPP handle_mouse_eventUPP = NULL; 8329 static EventHandlerUPP handle_mouse_eventUPP = NULL;
@@ -9455,6 +9532,29 @@ XTread_socket (sd, expected, hold_quit)
9455 pending_autoraise_frame = 0; 9532 pending_autoraise_frame = 0;
9456 } 9533 }
9457 9534
9535#if !USE_CARBON_EVENTS
9536 /* Check which frames are still visible. We do this here because
9537 there doesn't seem to be any direct notification from the Window
9538 Manager that the visibility of a window has changed (at least,
9539 not in all cases). */
9540 {
9541 Lisp_Object tail, frame;
9542
9543 FOR_EACH_FRAME (tail, frame)
9544 {
9545 struct frame *f = XFRAME (frame);
9546
9547 /* The tooltip has been drawn already. Avoid the
9548 SET_FRAME_GARBAGED in mac_handle_visibility_change. */
9549 if (EQ (frame, tip_frame))
9550 continue;
9551
9552 if (FRAME_MAC_P (f))
9553 mac_handle_visibility_change (f);
9554 }
9555 }
9556#endif
9557
9458 UNBLOCK_INPUT; 9558 UNBLOCK_INPUT;
9459 return count; 9559 return count;
9460} 9560}