diff options
author | Juri Linkov <juri@linkov.net> | 2019-09-02 00:30:18 +0300 |
---|---|---|
committer | Juri Linkov <juri@linkov.net> | 2019-09-02 00:30:18 +0300 |
commit | 51ac64d9aa6aec969c38a3774310479d1cbb4dc9 (patch) | |
tree | 99a1eb675d424e914a8d11f8e39d4fffcc4f6d34 /src/w32term.c | |
parent | 8bbad5aaa33f56a8aaec92e157fdf9587f3c1ca7 (diff) | |
download | emacs-51ac64d9aa6aec969c38a3774310479d1cbb4dc9.tar.gz emacs-51ac64d9aa6aec969c38a3774310479d1cbb4dc9.tar.bz2 emacs-51ac64d9aa6aec969c38a3774310479d1cbb4dc9.zip |
Try to add more tab-bar support on Windows
Diffstat (limited to 'src/w32term.c')
-rw-r--r-- | src/w32term.c | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/src/w32term.c b/src/w32term.c index 1f57635f6db..dc516390d16 100644 --- a/src/w32term.c +++ b/src/w32term.c @@ -168,6 +168,8 @@ int w32_keyboard_codepage; int w32_message_fd = -1; #endif /* CYGWIN */ +static void w32_handle_tab_bar_click (struct frame *, + struct input_event *); static void w32_handle_tool_bar_click (struct frame *, struct input_event *); static void w32_define_cursor (Window, Emacs_Cursor); @@ -3604,6 +3606,29 @@ w32_mouse_position (struct frame **fp, int insist, Lisp_Object *bar_window, /*********************************************************************** + Tab-bars + ***********************************************************************/ + +/* Handle mouse button event on the tab-bar of frame F, at + frame-relative coordinates X/Y. EVENT_TYPE is either ButtonPress + or ButtonRelease. */ + +static void +w32_handle_tab_bar_click (struct frame *f, struct input_event *button_event) +{ + int x = XFIXNAT (button_event->x); + int y = XFIXNAT (button_event->y); + + if (button_event->modifiers & down_modifier) + handle_tab_bar_click (f, x, y, 1, 0); + else + handle_tab_bar_click (f, x, y, 0, + button_event->modifiers & ~up_modifier); +} + + + +/*********************************************************************** Tool-bars ***********************************************************************/ @@ -4843,6 +4868,7 @@ w32_read_socket (struct terminal *terminal, if (f && !FRAME_ICONIFIED_P (f)) { if (!hlinfo->mouse_face_hidden && FIXNUMP (Vmouse_highlight) + && !EQ (f->tab_bar_window, hlinfo->mouse_face_window) && !EQ (f->tool_bar_window, hlinfo->mouse_face_window)) { clear_mouse_face (hlinfo); @@ -4868,6 +4894,7 @@ w32_read_socket (struct terminal *terminal, if (f && !FRAME_ICONIFIED_P (f)) { if (!hlinfo->mouse_face_hidden && FIXNUMP (Vmouse_highlight) + && !EQ (f->tab_bar_window, hlinfo->mouse_face_window) && !EQ (f->tool_bar_window, hlinfo->mouse_face_window)) { clear_mouse_face (hlinfo); @@ -4946,6 +4973,7 @@ w32_read_socket (struct terminal *terminal, if (f && !FRAME_ICONIFIED_P (f)) { if (!hlinfo->mouse_face_hidden && FIXNUMP (Vmouse_highlight) + && !EQ (f->tab_bar_window, hlinfo->mouse_face_window) && !EQ (f->tool_bar_window, hlinfo->mouse_face_window)) { clear_mouse_face (hlinfo); @@ -5051,6 +5079,7 @@ w32_read_socket (struct terminal *terminal, { /* If we decide we want to generate an event to be seen by the rest of Emacs, we put it here. */ + bool tab_bar_p = 0; bool tool_bar_p = 0; int button = 0; int up = 0; @@ -5060,6 +5089,31 @@ w32_read_socket (struct terminal *terminal, { w32_construct_mouse_click (&inev, &msg, f); + /* Is this in the tab-bar? */ + if (WINDOWP (f->tab_bar_window) + && WINDOW_TOTAL_LINES (XWINDOW (f->tab_bar_window))) + { + Lisp_Object window; + int x = XFIXNAT (inev.x); + int y = XFIXNAT (inev.y); + + window = window_from_coordinates (f, x, y, 0, 1, 0); + + if (EQ (window, f->tab_bar_window)) + { + w32_handle_tab_bar_click (f, &inev); + tab_bar_p = 1; + } + } + + if (tab_bar_p + || (dpyinfo->w32_focus_frame + && f != dpyinfo->w32_focus_frame + /* This does not help when the click happens in + a grand-parent frame. */ + && !frame_ancestor_p (f, dpyinfo->w32_focus_frame))) + inev.kind = NO_EVENT; + /* Is this in the tool-bar? */ if (WINDOWP (f->tool_bar_window) && WINDOW_TOTAL_LINES (XWINDOW (f->tool_bar_window))) @@ -5104,6 +5158,8 @@ w32_read_socket (struct terminal *terminal, if (f != 0) { f->mouse_moved = false; + if (!tab_bar_p) + f->last_tab_bar_item = -1; if (!tool_bar_p) f->last_tool_bar_item = -1; } @@ -5127,6 +5183,7 @@ w32_read_socket (struct terminal *terminal, event; any subsequent mouse-movement Emacs events should reflect only motion after the ButtonPress. */ f->mouse_moved = false; + f->last_tab_bar_item = -1; f->last_tool_bar_item = -1; dpyinfo->last_mouse_frame = f; } @@ -5140,6 +5197,7 @@ w32_read_socket (struct terminal *terminal, { w32_construct_mouse_wheel (&inev, &msg, f1); f1->mouse_moved = false; + f1->last_tab_bar_item = -1; f1->last_tool_bar_item = -1; dpyinfo->last_mouse_frame = f1; } |