aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJason Rumney2005-03-26 00:19:53 +0000
committerJason Rumney2005-03-26 00:19:53 +0000
commit55131bef54397b26d73ad4c5e4d5ac7ac816a45b (patch)
treed9b51063ad93b1501ca3b749fd587a7e06330425 /src
parent6e7d0438efec40d982a50849b7de0eebff450a25 (diff)
downloademacs-55131bef54397b26d73ad4c5e4d5ac7ac816a45b.tar.gz
emacs-55131bef54397b26d73ad4c5e4d5ac7ac816a45b.zip
(x_focus_changed, w32_detect_focus_change): New functions.
(w32_read_socket) [WM_SETFOCUS]: Call w32_detect_focus_change.
Diffstat (limited to 'src')
-rw-r--r--src/w32term.c95
1 files changed, 80 insertions, 15 deletions
diff --git a/src/w32term.c b/src/w32term.c
index 738f676ceaf..1223aa310d9 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -255,6 +255,10 @@ static void frame_highlight P_ ((struct frame *));
255static void frame_unhighlight P_ ((struct frame *)); 255static void frame_unhighlight P_ ((struct frame *));
256static void x_new_focus_frame P_ ((struct w32_display_info *, 256static void x_new_focus_frame P_ ((struct w32_display_info *,
257 struct frame *)); 257 struct frame *));
258static void x_focus_changed P_ ((int, int, struct w32_display_info *,
259 struct frame *, struct input_event *));
260static void w32_detect_focus_change P_ ((struct w32_display_info *,
261 W32Msg *, struct input_event *));
258static void w32_frame_rehighlight P_ ((struct frame *)); 262static void w32_frame_rehighlight P_ ((struct frame *));
259static void x_frame_rehighlight P_ ((struct w32_display_info *)); 263static void x_frame_rehighlight P_ ((struct w32_display_info *));
260static void x_draw_hollow_cursor P_ ((struct window *, struct glyph_row *)); 264static void x_draw_hollow_cursor P_ ((struct window *, struct glyph_row *));
@@ -2816,6 +2820,81 @@ x_new_focus_frame (dpyinfo, frame)
2816 x_frame_rehighlight (dpyinfo); 2820 x_frame_rehighlight (dpyinfo);
2817} 2821}
2818 2822
2823
2824/* Handle FocusIn and FocusOut state changes for FRAME.
2825 If FRAME has focus and there exists more than one frame, puts
2826 a FOCUS_IN_EVENT into *BUFP. */
2827
2828static void
2829x_focus_changed (type, state, dpyinfo, frame, bufp)
2830 int type;
2831 int state;
2832 struct w32_display_info *dpyinfo;
2833 struct frame *frame;
2834 struct input_event *bufp;
2835{
2836 if (type == WM_SETFOCUS)
2837 {
2838 if (dpyinfo->w32_focus_event_frame != frame)
2839 {
2840 x_new_focus_frame (dpyinfo, frame);
2841 dpyinfo->w32_focus_event_frame = frame;
2842
2843 /* Don't stop displaying the initial startup message
2844 for a switch-frame event we don't need. */
2845 if (GC_NILP (Vterminal_frame)
2846 && GC_CONSP (Vframe_list)
2847 && !GC_NILP (XCDR (Vframe_list)))
2848 {
2849 bufp->kind = FOCUS_IN_EVENT;
2850 XSETFRAME (bufp->frame_or_window, frame);
2851 }
2852 }
2853
2854 frame->output_data.x->focus_state |= state;
2855
2856 /* TODO: IME focus? */
2857 }
2858 else if (type == WM_KILLFOCUS)
2859 {
2860 frame->output_data.x->focus_state &= ~state;
2861
2862 if (dpyinfo->w32_focus_event_frame == frame)
2863 {
2864 dpyinfo->w32_focus_event_frame = 0;
2865 x_new_focus_frame (dpyinfo, 0);
2866 }
2867
2868 /* TODO: IME focus? */
2869 }
2870}
2871
2872
2873/* The focus may have changed. Figure out if it is a real focus change,
2874 by checking both FocusIn/Out and Enter/LeaveNotify events.
2875
2876 Returns FOCUS_IN_EVENT event in *BUFP. */
2877
2878static void
2879w32_detect_focus_change (dpyinfo, event, bufp)
2880 struct w32_display_info *dpyinfo;
2881 W32Msg *event;
2882 struct input_event *bufp;
2883{
2884 struct frame *frame;
2885
2886 frame = x_any_window_to_frame (dpyinfo, event->msg.hwnd);
2887 if (! frame)
2888 return;
2889
2890 /* On w32, this is only called from focus events, so no switch needed. */
2891 x_focus_changed (event->msg.message,
2892 (event->msg.message == WM_KILLFOCUS ?
2893 FOCUS_IMPLICIT : FOCUS_EXPLICIT),
2894 dpyinfo, frame, bufp);
2895}
2896
2897
2819/* Handle an event saying the mouse has moved out of an Emacs frame. */ 2898/* Handle an event saying the mouse has moved out of an Emacs frame. */
2820 2899
2821void 2900void
@@ -4660,27 +4739,13 @@ w32_read_socket (sd, expected, hold_quit)
4660 break; 4739 break;
4661 4740
4662 case WM_SETFOCUS: 4741 case WM_SETFOCUS:
4663 /* TODO: Port this change: 4742 w32_detect_focus_change (dpyinfo, &msg, &inev);
4664 2002-06-28 Jan D. <jan.h.d@swipnet.se>
4665 * xterm.h (struct x_output): Add focus_state.
4666 * xterm.c (x_focus_changed): New function.
4667 (x_detect_focus_change): New function.
4668 (XTread_socket): Call x_detect_focus_change for FocusIn/FocusOut
4669 EnterNotify and LeaveNotify to track X focus changes.
4670 */
4671 f = x_any_window_to_frame (dpyinfo, msg.msg.hwnd);
4672
4673 dpyinfo->w32_focus_event_frame = f;
4674
4675 if (f)
4676 x_new_focus_frame (dpyinfo, f);
4677 4743
4678 dpyinfo->grabbed = 0; 4744 dpyinfo->grabbed = 0;
4679 check_visibility = 1; 4745 check_visibility = 1;
4680 break; 4746 break;
4681 4747
4682 case WM_KILLFOCUS: 4748 case WM_KILLFOCUS:
4683 /* TODO: some of this belongs in MOUSE_LEAVE */
4684 f = x_top_window_to_frame (dpyinfo, msg.msg.hwnd); 4749 f = x_top_window_to_frame (dpyinfo, msg.msg.hwnd);
4685 4750
4686 if (f) 4751 if (f)