Adding swapmouse patch ref. #28

This commit is contained in:
bakkeby 2021-05-16 11:40:15 +02:00
parent 80bb4b8ab7
commit ad7e16b38a
3 changed files with 46 additions and 4 deletions

View File

@ -15,6 +15,8 @@ Refer to [https://st.suckless.org/](https://st.suckless.org/) for details on the
### Changelog: ### Changelog:
2021-05-16 - Added swapmouse patch
2021-05-11 - Added default cursor patch 2021-05-11 - Added default cursor patch
2021-05-10 - Upgrade to 46b02f, 2021-03-28 2021-05-10 - Upgrade to 46b02f, 2021-03-28
@ -180,7 +182,8 @@ Refer to [https://st.suckless.org/](https://st.suckless.org/) for details on the
[theme.sh](https://github.com/lemnos/theme.sh) which expect these colours to be distinct [theme.sh](https://github.com/lemnos/theme.sh) which expect these colours to be distinct
- [relativeborder](https://st.suckless.org/patches/relativeborder/) - [relativeborder](https://st.suckless.org/patches/relativeborder/)
- allows you to specify a border that is relative in size to the width of a cell in the terminal - allows you to specify a border that is relative in size to the width of a cell in the
terminal
- [right-click-to-plumb](https://st.suckless.org/patches/right_click_to_plumb/) - [right-click-to-plumb](https://st.suckless.org/patches/right_click_to_plumb/)
- allows you to right-click on some selected text to send it to the plumbing program of choice - allows you to right-click on some selected text to send it to the plumbing program of choice
@ -192,16 +195,23 @@ Refer to [https://st.suckless.org/](https://st.suckless.org/) for details on the
- this patch adds SIXEL graphics support - this patch adds SIXEL graphics support
- st-embedder - st-embedder
- this patch allows clients to embed into the st window and can be useful if you tend to start X applications from the terminal - this patch allows clients to embed into the st window and can be useful if you tend to
start X applications from the terminal
- the behavior is similar to Plan 9 where applications can take over windows - the behavior is similar to Plan 9 where applications can take over windows
- [spoiler](https://st.suckless.org/patches/spoiler/) - [spoiler](https://st.suckless.org/patches/spoiler/)
- use inverted defaultbg/fg for selection when bg/fg are the same - use inverted defaultbg/fg for selection when bg/fg are the same
- [swapmouse](https://st.suckless.org/patches/swapmouse/)
- changes the mouse shape to the global default when the running program subscribes for mouse
events, for instance, in programs like ranger and fzf
- it emulates the behaviour shown by vte terminals like termite
- [sync](https://st.suckless.org/patches/sync/) - [sync](https://st.suckless.org/patches/sync/)
- adds synchronized-updates/application-sync support in st - adds synchronized-updates/application-sync support in st
- this has no effect except when an application uses the synchronized-update escape sequences - this has no effect except when an application uses the synchronized-update escape sequences
- with this patch nearly all cursor flicker is eliminated in tmux, and tmux detects it automatically via terminfo - with this patch nearly all cursor flicker is eliminated in tmux, and tmux detects it
automatically via terminfo
- [themed-cursor](https://st.suckless.org/patches/themed_cursor/) - [themed-cursor](https://st.suckless.org/patches/themed_cursor/)
- instead of a default X cursor, use the xterm cursor from your cursor theme - instead of a default X cursor, use the xterm cursor from your cursor theme

View File

@ -293,6 +293,13 @@
*/ */
#define SPOILER_PATCH 0 #define SPOILER_PATCH 0
/* This patch changes the mouse shape to the global default when the running program subscribes
* for mouse events, for instance, in programs like ranger and fzf. It emulates the behaviour
* shown by vte terminals like termite.
* https://st.suckless.org/patches/swapmouse/
*/
#define SWAPMOUSE_PATCH 0
/* This patch adds synchronized-updates/application-sync support in st. /* This patch adds synchronized-updates/application-sync support in st.
* This will have no effect except when an application uses the synchronized-update escape * This will have no effect except when an application uses the synchronized-update escape
* sequences. With this patch nearly all cursor flicker is eliminated in tmux, and tmux detects * sequences. With this patch nearly all cursor flicker is eliminated in tmux, and tmux detects

27
x.c
View File

@ -199,6 +199,10 @@ static int bellon = 0; /* visual bell status */
#if RELATIVEBORDER_PATCH #if RELATIVEBORDER_PATCH
int borderpx; int borderpx;
#endif // RELATIVEBORDER_PATCH #endif // RELATIVEBORDER_PATCH
#if SWAPMOUSE_PATCH
static Cursor cursor;
static XColor xmousefg, xmousebg;
#endif // SWAPMOUSE_PATCH
#include "patch/x_include.c" #include "patch/x_include.c"
@ -723,7 +727,14 @@ bmotion(XEvent *e)
{ {
#if HIDECURSOR_PATCH #if HIDECURSOR_PATCH
if (!xw.pointerisvisible) { if (!xw.pointerisvisible) {
#if SWAPMOUSE_PATCH
if (win.mode & MODE_MOUSE)
XUndefineCursor(xw.dpy, xw.win);
else
XDefineCursor(xw.dpy, xw.win, xw.vpointer);
#else
XDefineCursor(xw.dpy, xw.win, xw.vpointer); XDefineCursor(xw.dpy, xw.win, xw.vpointer);
#endif // SWAPMOUSE_PATCH
xw.pointerisvisible = 1; xw.pointerisvisible = 1;
if (!IS_SET(MODE_MOUSEMANY)) if (!IS_SET(MODE_MOUSEMANY))
xsetpointermotion(0); xsetpointermotion(0);
@ -1255,12 +1266,14 @@ xinit(int cols, int rows)
XGCValues gcvalues; XGCValues gcvalues;
#if HIDECURSOR_PATCH #if HIDECURSOR_PATCH
Pixmap blankpm; Pixmap blankpm;
#else #elif !SWAPMOUSE_PATCH
Cursor cursor; Cursor cursor;
#endif // HIDECURSOR_PATCH #endif // HIDECURSOR_PATCH
Window parent; Window parent;
pid_t thispid = getpid(); pid_t thispid = getpid();
#if !SWAPMOUSE_PATCH
XColor xmousefg, xmousebg; XColor xmousefg, xmousebg;
#endif // SWAPMOUSE_PATCH
#if ALPHA_PATCH #if ALPHA_PATCH
XWindowAttributes attr; XWindowAttributes attr;
XVisualInfo vis; XVisualInfo vis;
@ -2398,6 +2411,18 @@ xsetmode(int set, unsigned int flags)
{ {
int mode = win.mode; int mode = win.mode;
MODBIT(win.mode, set, flags); MODBIT(win.mode, set, flags);
#if SWAPMOUSE_PATCH
if ((flags & MODE_MOUSE)
#if HIDECURSOR_PATCH
&& xw.pointerisvisible
#endif // HIDECURSOR_PATCH
) {
if (win.mode & MODE_MOUSE)
XUndefineCursor(xw.dpy, xw.win);
else
XDefineCursor(xw.dpy, xw.win, cursor);
}
#endif // SWAPMOUSE_PATCH
if ((win.mode & MODE_REVERSE) != (mode & MODE_REVERSE)) if ((win.mode & MODE_REVERSE) != (mode & MODE_REVERSE))
redraw(); redraw();
} }