Commit 51ac64d9 authored by Juri Linkov's avatar Juri Linkov

Try to add more tab-bar support on Windows

parent 8bbad5aa
...@@ -6059,6 +6059,11 @@ DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame, ...@@ -6059,6 +6059,11 @@ DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame,
/* No menu bar for child frames. */ /* No menu bar for child frames. */
store_frame_param (f, Qmenu_bar_lines, make_fixnum (0)); store_frame_param (f, Qmenu_bar_lines, make_fixnum (0));
gui_default_parameter (f, parameters, Qtab_bar_lines,
NILP (Vtab_bar_mode)
? make_fixnum (0) : make_fixnum (1),
NULL, NULL, RES_TYPE_NUMBER);
gui_default_parameter (f, parameters, Qtool_bar_lines, gui_default_parameter (f, parameters, Qtool_bar_lines,
NILP (Vtool_bar_mode) NILP (Vtool_bar_mode)
? make_fixnum (0) : make_fixnum (1), ? make_fixnum (0) : make_fixnum (1),
...@@ -8808,6 +8813,9 @@ and width values are in pixels. ...@@ -8808,6 +8813,9 @@ and width values are in pixels.
`menu-bar-size' is a cons of the width and height of the menu bar of `menu-bar-size' is a cons of the width and height of the menu bar of
FRAME. FRAME.
`tab-bar-size' is a cons of the width and height of the tab bar of
FRAME.
`tool-bar-external', if non-nil, means the tool bar is external (never `tool-bar-external', if non-nil, means the tool bar is external (never
included in the inner edges of FRAME). included in the inner edges of FRAME).
...@@ -8830,6 +8838,7 @@ and width values are in pixels. ...@@ -8830,6 +8838,7 @@ and width values are in pixels.
unsigned int external_border_width, external_border_height; unsigned int external_border_width, external_border_height;
int title_bar_width = 0, title_bar_height = 0; int title_bar_width = 0, title_bar_height = 0;
int single_menu_bar_height, wrapped_menu_bar_height, menu_bar_height; int single_menu_bar_height, wrapped_menu_bar_height, menu_bar_height;
int tab_bar_height = FRAME_TAB_BAR_HEIGHT (f);
int tool_bar_height = FRAME_TOOL_BAR_HEIGHT (f); int tool_bar_height = FRAME_TOOL_BAR_HEIGHT (f);
int internal_border_width = FRAME_INTERNAL_BORDER_WIDTH (f); int internal_border_width = FRAME_INTERNAL_BORDER_WIDTH (f);
...@@ -8903,6 +8912,13 @@ and width values are in pixels. ...@@ -8903,6 +8912,13 @@ and width values are in pixels.
Fcons (make_fixnum Fcons (make_fixnum
(menu_bar.rcBar.right - menu_bar.rcBar.left), (menu_bar.rcBar.right - menu_bar.rcBar.left),
make_fixnum (menu_bar_height))), make_fixnum (menu_bar_height))),
Fcons (Qtab_bar_size,
Fcons (make_fixnum
(tab_bar_height
? (right - left - 2 * external_border_width
- 2 * internal_border_width)
: 0),
make_fixnum (tab_bar_height))),
Fcons (Qtool_bar_external, Qnil), Fcons (Qtool_bar_external, Qnil),
Fcons (Qtool_bar_position, tool_bar_height ? Qtop : Qnil), Fcons (Qtool_bar_position, tool_bar_height ? Qtop : Qnil),
Fcons (Qtool_bar_size, Fcons (Qtool_bar_size,
...@@ -8994,6 +9010,7 @@ menu bar or tool bar of FRAME. */) ...@@ -8994,6 +9010,7 @@ menu bar or tool bar of FRAME. */)
return list4 (make_fixnum (left + internal_border_width), return list4 (make_fixnum (left + internal_border_width),
make_fixnum (top make_fixnum (top
+ FRAME_TAB_BAR_HEIGHT (f)
+ FRAME_TOOL_BAR_HEIGHT (f) + FRAME_TOOL_BAR_HEIGHT (f)
+ internal_border_width), + internal_border_width),
make_fixnum (right - internal_border_width), make_fixnum (right - internal_border_width),
......
...@@ -36,6 +36,8 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ ...@@ -36,6 +36,8 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
"emacs.tooltip.attributeBackground:SystemInfoWindow\0" \ "emacs.tooltip.attributeBackground:SystemInfoWindow\0" \
"emacs.tool-bar.attributeForeground:SystemButtonText\0" \ "emacs.tool-bar.attributeForeground:SystemButtonText\0" \
"emacs.tool-bar.attributeBackground:SystemButtonFace\0" \ "emacs.tool-bar.attributeBackground:SystemButtonFace\0" \
"emacs.tab-bar.attributeForeground:SystemButtonText\0" \
"emacs.tab-bar.attributeBackground:SystemButtonFace\0" \
"emacs.menu.attributeForeground:SystemMenuText\0" \ "emacs.menu.attributeForeground:SystemMenuText\0" \
"emacs.menu.attributeBackground:SystemMenu\0" \ "emacs.menu.attributeBackground:SystemMenu\0" \
"emacs.scroll-bar.attributeForeground:SystemScrollbar\0" "emacs.scroll-bar.attributeForeground:SystemScrollbar\0"
......
...@@ -168,6 +168,8 @@ int w32_keyboard_codepage; ...@@ -168,6 +168,8 @@ int w32_keyboard_codepage;
int w32_message_fd = -1; int w32_message_fd = -1;
#endif /* CYGWIN */ #endif /* CYGWIN */
static void w32_handle_tab_bar_click (struct frame *,
struct input_event *);
static void w32_handle_tool_bar_click (struct frame *, static void w32_handle_tool_bar_click (struct frame *,
struct input_event *); struct input_event *);
static void w32_define_cursor (Window, Emacs_Cursor); static void w32_define_cursor (Window, Emacs_Cursor);
...@@ -3602,6 +3604,29 @@ w32_mouse_position (struct frame **fp, int insist, Lisp_Object *bar_window, ...@@ -3602,6 +3604,29 @@ w32_mouse_position (struct frame **fp, int insist, Lisp_Object *bar_window,
unblock_input (); unblock_input ();
} }
/***********************************************************************
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 Tool-bars
...@@ -4843,6 +4868,7 @@ w32_read_socket (struct terminal *terminal, ...@@ -4843,6 +4868,7 @@ w32_read_socket (struct terminal *terminal,
if (f && !FRAME_ICONIFIED_P (f)) if (f && !FRAME_ICONIFIED_P (f))
{ {
if (!hlinfo->mouse_face_hidden && FIXNUMP (Vmouse_highlight) 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)) && !EQ (f->tool_bar_window, hlinfo->mouse_face_window))
{ {
clear_mouse_face (hlinfo); clear_mouse_face (hlinfo);
...@@ -4868,6 +4894,7 @@ w32_read_socket (struct terminal *terminal, ...@@ -4868,6 +4894,7 @@ w32_read_socket (struct terminal *terminal,
if (f && !FRAME_ICONIFIED_P (f)) if (f && !FRAME_ICONIFIED_P (f))
{ {
if (!hlinfo->mouse_face_hidden && FIXNUMP (Vmouse_highlight) 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)) && !EQ (f->tool_bar_window, hlinfo->mouse_face_window))
{ {
clear_mouse_face (hlinfo); clear_mouse_face (hlinfo);
...@@ -4946,6 +4973,7 @@ w32_read_socket (struct terminal *terminal, ...@@ -4946,6 +4973,7 @@ w32_read_socket (struct terminal *terminal,
if (f && !FRAME_ICONIFIED_P (f)) if (f && !FRAME_ICONIFIED_P (f))
{ {
if (!hlinfo->mouse_face_hidden && FIXNUMP (Vmouse_highlight) 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)) && !EQ (f->tool_bar_window, hlinfo->mouse_face_window))
{ {
clear_mouse_face (hlinfo); clear_mouse_face (hlinfo);
...@@ -5051,6 +5079,7 @@ w32_read_socket (struct terminal *terminal, ...@@ -5051,6 +5079,7 @@ w32_read_socket (struct terminal *terminal,
{ {
/* If we decide we want to generate an event to be seen /* If we decide we want to generate an event to be seen
by the rest of Emacs, we put it here. */ by the rest of Emacs, we put it here. */
bool tab_bar_p = 0;
bool tool_bar_p = 0; bool tool_bar_p = 0;
int button = 0; int button = 0;
int up = 0; int up = 0;
...@@ -5060,6 +5089,31 @@ w32_read_socket (struct terminal *terminal, ...@@ -5060,6 +5089,31 @@ w32_read_socket (struct terminal *terminal,
{ {
w32_construct_mouse_click (&inev, &msg, f); 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? */ /* Is this in the tool-bar? */
if (WINDOWP (f->tool_bar_window) if (WINDOWP (f->tool_bar_window)
&& WINDOW_TOTAL_LINES (XWINDOW (f->tool_bar_window))) && WINDOW_TOTAL_LINES (XWINDOW (f->tool_bar_window)))
...@@ -5104,6 +5158,8 @@ w32_read_socket (struct terminal *terminal, ...@@ -5104,6 +5158,8 @@ w32_read_socket (struct terminal *terminal,
if (f != 0) if (f != 0)
{ {
f->mouse_moved = false; f->mouse_moved = false;
if (!tab_bar_p)
f->last_tab_bar_item = -1;
if (!tool_bar_p) if (!tool_bar_p)
f->last_tool_bar_item = -1; f->last_tool_bar_item = -1;
} }
...@@ -5127,6 +5183,7 @@ w32_read_socket (struct terminal *terminal, ...@@ -5127,6 +5183,7 @@ w32_read_socket (struct terminal *terminal,
event; any subsequent mouse-movement Emacs events event; any subsequent mouse-movement Emacs events
should reflect only motion after the ButtonPress. */ should reflect only motion after the ButtonPress. */
f->mouse_moved = false; f->mouse_moved = false;
f->last_tab_bar_item = -1;
f->last_tool_bar_item = -1; f->last_tool_bar_item = -1;
dpyinfo->last_mouse_frame = f; dpyinfo->last_mouse_frame = f;
} }
...@@ -5140,6 +5197,7 @@ w32_read_socket (struct terminal *terminal, ...@@ -5140,6 +5197,7 @@ w32_read_socket (struct terminal *terminal,
{ {
w32_construct_mouse_wheel (&inev, &msg, f1); w32_construct_mouse_wheel (&inev, &msg, f1);
f1->mouse_moved = false; f1->mouse_moved = false;
f1->last_tab_bar_item = -1;
f1->last_tool_bar_item = -1; f1->last_tool_bar_item = -1;
dpyinfo->last_mouse_frame = f1; dpyinfo->last_mouse_frame = f1;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment