Skip to content

Commit

Permalink
* ui_layout.c:
Browse files Browse the repository at this point in the history
  - ui_screen_set_pointer_motion_event_mask() is used
    instead of ui_window_{add|remove}_event_mask().
  - ui_window_t::pointer_motion is replaced by screen_pointer_motion()
    only if autohide_scrollbar is enabled.
* ui_screen.[ch]: ui_screen_set_pointer_motion_event_mask() is added.
* vt_parser.c: The default value of XTSMPOINTER (CSI>p) is changed
  from 2 to 1.
* version.h: 3.9.2 -> 3.9.2post
  • Loading branch information
arakiken committed Jan 29, 2022
1 parent b59fa8d commit 0fd20ea
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 22 deletions.
15 changes: 15 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
2022-01-29 Araki Ken <[email protected]>

* ui_layout.c:
- ui_screen_set_pointer_motion_event_mask() is used
instead of ui_window_{add|remove}_event_mask().
- ui_window_t::pointer_motion is replaced by screen_pointer_motion()
only if autohide_scrollbar is enabled.

* ui_screen.[ch]: ui_screen_set_pointer_motion_event_mask() is added.

* vt_parser.c: The default value of XTSMPOINTER (CSI>p) is changed
from 2 to 1.

* version.h: 3.9.2 -> 3.9.2post

2022-01-16 Araki Ken <[email protected]>

* 3.9.2 released.
Expand Down
2 changes: 1 addition & 1 deletion main/version.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

#if 0
#define CHANGE_DATE "pre/@CHANGE_DATE@"
#elif 0
#elif 1
#define CHANGE_DATE "post/@CHANGE_DATE@"
#else
#define CHANGE_DATE ""
Expand Down
20 changes: 12 additions & 8 deletions uitoolkit/ui_layout.c
Original file line number Diff line number Diff line change
Expand Up @@ -933,8 +933,10 @@ static int need_idling_event(struct terminal *term) {
}
#endif

static void screen_pointer_motion(ui_window_t *win, XMotionEvent *event);

static void change_sb_mode_intern(struct terminal *term, ui_sb_mode_t new_mode,
int dynamic_change) {
int dynamic_change /* true in changing by autohide */) {
ui_layout_t *layout;
ui_sb_mode_t old_mode;

Expand All @@ -947,13 +949,15 @@ static void change_sb_mode_intern(struct terminal *term, ui_sb_mode_t new_mode,

new_mode = SBM_NONE;
term->autohide_scrollbar = 1;
ui_window_add_event_mask(&term->screen->window, PointerMotionMask);
term->screen->window.pointer_motion = screen_pointer_motion;
ui_screen_set_pointer_motion_event_mask(term->screen, 1);
#ifndef USE_QUARTZ
layout->window.idling = window_idling;
#endif
} else if (!dynamic_change) {
term->autohide_scrollbar = 0;
ui_window_remove_event_mask(&term->screen->window, PointerMotionMask);
term->screen->window.pointer_motion = layout->pointer_motion;
ui_screen_set_pointer_motion_event_mask(term->screen, 0);
(*term->screen->xterm_listener.set_mouse_report)(term->screen->xterm_listener.self);

#ifndef USE_QUARTZ
Expand Down Expand Up @@ -1195,14 +1199,14 @@ ui_layout_t *ui_layout_new(ui_screen_t *screen, char *view_name, char *fg_color,
layout->line_scrolled_out = screen->screen_listener.line_scrolled_out;
screen->screen_listener.line_scrolled_out = line_scrolled_out;

layout->pointer_motion = screen->window.pointer_motion;
if (mode == SBM_AUTOHIDE) {
layout->term.sb_mode = SBM_NONE;
layout->term.autohide_scrollbar = 1;
screen->window.pointer_motion = screen_pointer_motion;
} else {
layout->term.sb_mode = mode;
}
layout->pointer_motion = screen->window.pointer_motion;
screen->window.pointer_motion = screen_pointer_motion;

if (layout->term.sb_mode == SBM_NONE) {
actual_width = ACTUAL_WIDTH(&screen->window);
Expand Down Expand Up @@ -1269,7 +1273,7 @@ ui_layout_t *ui_layout_new(ui_screen_t *screen, char *view_name, char *fg_color,
#ifndef USE_QUARTZ
layout->window.idling = window_idling;
#endif
ui_window_add_event_mask(&screen->window, PointerMotionMask);
ui_screen_set_pointer_motion_event_mask(screen, 1);
}

return layout;
Expand Down Expand Up @@ -1432,9 +1436,9 @@ int ui_layout_add_child(ui_layout_t *layout, ui_screen_t *screen, int horizontal

next->sb_mode = term->sb_mode;
if ((next->autohide_scrollbar = term->autohide_scrollbar)) {
ui_window_add_event_mask(&screen->window, PointerMotionMask);
screen->window.pointer_motion = screen_pointer_motion;
ui_screen_set_pointer_motion_event_mask(screen, 1);
}
screen->window.pointer_motion = screen_pointer_motion;

reset_layout(&layout->term, 0, 0, layout->window.width, layout->window.height);

Expand Down
42 changes: 30 additions & 12 deletions uitoolkit/ui_screen.c
Original file line number Diff line number Diff line change
Expand Up @@ -2489,6 +2489,10 @@ static void key_pressed(ui_window_t *win, XKeyEvent *event) {
screen->hide_pointer = 1;
} else {
ui_window_add_event_mask(win, PointerMotionMask);
/*
* Need to remove PointerMotionMask after reviving the pointer in moving it.
* (see pointer_motion())
*/
screen->hide_pointer = 2;
}
}
Expand Down Expand Up @@ -3532,18 +3536,20 @@ static void selecting_line(ui_screen_t *screen, int y, Time time) {

static void change_sb_mode(ui_screen_t *screen, ui_sb_mode_t sb_mode);

static void pointer_motion(ui_window_t *win, XMotionEvent *event) {
ui_screen_t *screen;

screen = (ui_screen_t *)win;

static void show_pointer(ui_screen_t *screen) {
if (screen->hide_pointer) {
ui_window_set_cursor(win, XC_xterm);
ui_window_set_cursor(&screen->window, XC_xterm);
if (screen->hide_pointer == 2) {
ui_window_remove_event_mask(win, PointerMotionMask);
ui_window_remove_event_mask(&screen->window, PointerMotionMask);
}
screen->hide_pointer = 0;
}
}

static void pointer_motion(ui_window_t *win, XMotionEvent *event) {
ui_screen_t *screen = (ui_screen_t *)win;

show_pointer(screen);

if (!(event->state & (ShiftMask | ControlMask)) &&
vt_term_get_mouse_report_mode(screen->term) >= ANY_EVENT_MOUSE_REPORT) {
Expand Down Expand Up @@ -6054,12 +6060,9 @@ static void xterm_set_mouse_report(void *p) {
}

if (vt_term_get_mouse_report_mode(screen->term) < ANY_EVENT_MOUSE_REPORT) {
/* pointer_motion may be overridden by ui_layout */
if (screen->window.pointer_motion == pointer_motion) {
ui_window_remove_event_mask(&screen->window, PointerMotionMask);
}
ui_screen_set_pointer_motion_event_mask(screen, 0);
} else {
ui_window_add_event_mask(&screen->window, PointerMotionMask);
ui_screen_set_pointer_motion_event_mask(screen, 1);
}
}

Expand Down Expand Up @@ -7612,3 +7615,18 @@ ui_picture_modifier_t *ui_screen_get_picture_modifier(ui_screen_t *screen) {
return &screen->pic_mod;
}
}

void ui_screen_set_pointer_motion_event_mask(ui_screen_t *screen, int flag) {
if (flag) {
ui_window_add_event_mask(&screen->window, PointerMotionMask);
if (screen->hide_pointer == 2) {
/* No need to remove PointerMotionMask after reviving the pointer in moving it. */
screen->hide_pointer = 1;
}
} else if (vt_term_get_mouse_report_mode(screen->term) != ANY_EVENT_MOUSE_REPORT &&
/* pointer_motion may be overridden by ui_layout */
screen->window.pointer_motion == pointer_motion) {
show_pointer(screen);
ui_window_remove_event_mask(&screen->window, PointerMotionMask);
}
}
2 changes: 2 additions & 0 deletions uitoolkit/ui_screen.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,4 +221,6 @@ void ui_screen_reload_color_cache(ui_screen_t *screen, int do_unload);

ui_picture_modifier_t *ui_screen_get_picture_modifier(ui_screen_t *screen);

void ui_screen_set_pointer_motion_event_mask(ui_screen_t *screen, int flag);

#endif
2 changes: 1 addition & 1 deletion vtemu/vt_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -7096,7 +7096,7 @@ vt_parser_t *vt_parser_new(vt_screen_t *screen, vt_termcap_ptr_t termcap, vt_cha
vt_parser->unicode_policy = policy;
vt_parser->cursor_style = cursor_style;
vt_parser->is_visible_cursor = 1;
vt_parser->hide_pointer_mode = 2; /* Compatible with xterm 344 */
vt_parser->hide_pointer_mode = 1; /* Compatible with xterm 370 */

if ((vt_parser->cc_conv = vt_char_encoding_conv_new(encoding)) == NULL) {
goto error;
Expand Down

0 comments on commit 0fd20ea

Please sign in to comment.