Both to prevent this and to add a toggle functionality, I modded the Wm struct to keep track of whether the cursor is visible (I know that it already has this attribute stored in w->config->cursor_not_visible (or something similar to this), but I thought that I'd add my own attribute to prevent any unforeseen bugs from occurring (plus having a "not" in a bool makes things messy). The attribute I added can be accessed like so: w->cursor_is_visible.
I added the cursor toggle event call to the wm and matchbox-remote as well: matchbox-remote -cursor-toggleAlso, here's a little desktop entry file and image in case anyone wants to plop it into an embedded system for easy mouse toggling with the click of an icon.
-- Tyler McClung [email protected]
Only in matchbox-window-manager-1.2: config.h
Only in matchbox-window-manager-1.2: config.log
Only in matchbox-window-manager-1.2: config.status
Only in matchbox-window-manager-1.2/data: Makefile
Only in matchbox-window-manager-1.2/data/schemas: Makefile
Only in matchbox-window-manager-1.2/data/themes/blondie: Makefile
Only in matchbox-window-manager-1.2/data/themes/Default: Makefile
Only in matchbox-window-manager-1.2/data/themes: Makefile
Only in matchbox-window-manager-1.2/data/themes/MBOpus: Makefile
Only in matchbox-window-manager-1.2: Makefile
Only in matchbox-window-manager-1.2/src: .deps
Only in matchbox-window-manager-1.2/src: main.c~
Only in matchbox-window-manager-1.2/src: Makefile
diff -ur matchbox-window-manager-1.2.orig/src/matchbox-remote.c matchbox-window-manager-1.2/src/matchbox-remote.c
--- matchbox-window-manager-1.2.orig/src/matchbox-remote.c 2006-11-17 03:37:14.000000000 -0800
+++ matchbox-window-manager-1.2/src/matchbox-remote.c 2009-07-16 09:42:24.000000000 -0700
@@ -22,7 +22,7 @@
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xatom.h>
-
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -37,6 +37,9 @@
#define MB_CMD_MISC 7
#define MB_CMD_COMPOSITE 8
#define MB_CMB_KEYS_RELOAD 9
+#define CMD_HIDE_CURSOR 10
+#define CMD_SHOW_CURSOR 11
+#define CMD_TOGGLE_CURSOR 12
#define MB_CMD_PANEL_TOGGLE_VISIBILITY 1
#define MB_CMD_PANEL_SIZE 2
@@ -130,7 +133,7 @@
desktop_manager_atom = XInternAtom(dpy, "_NET_DESKTOP_MANGER",False);
root = DefaultRootWindow(dpy);
-
+
if (cmd_id == MB_CMD_SET_THEME)
{
theme_prop = XInternAtom(dpy, "_MB_THEME", False);
@@ -214,27 +217,26 @@
printf(" -panel-toggle [panel id] Toogle panel visibility\n");
printf(" -input-toggle [1|0] Toggle Input method ( requires input-manager )\n");
printf(" -composite-toggle Toggle Compositing Engine ( if enabled )\n");
+ printf(" -cursor-toggle Toggles the cursor's visibility\n");
printf(" -keys-reload Reload key shortcut config ( if enabled )\n");
-
-
+ printf(" -hide Hides the cursor\n");
+ printf(" -show Shows the cursor\n");
/*
printf(" -panel-size <int>\n");
printf(" -panel-orientate <north|east|south|west>\n");
*/
- printf(" -h this help\n\n");
+ printf(" -anything else Opens this help\n\n");
exit(1);
}
int main(int argc, char* argv[])
{
- char *display_name = (char *)getenv("DISPLAY");
int i;
-
if (argc < 2) usage(argv[0]);
- dpy = XOpenDisplay(display_name);
+ dpy = XOpenDisplay(NULL);
if (dpy == NULL) {
- printf("Cant connect to display: %s\n", display_name);
+ printf("Cant connect to display: %s\n", XDisplayName(NULL));
exit(1);
}
@@ -245,7 +247,7 @@
switch (arg[1])
{
case 't' :
- if (argv[i+1] != NULL)
+ if (argv[i+1] != NULL)
mbcommand(MB_CMD_SET_THEME, argv[i+1]);
i++;
break;
@@ -263,11 +265,21 @@
mbcommand(MB_CMD_NEXT, NULL);
break;
case 'c':
+ if (!strcmp(arg+1,"cursor-toggle")) {
+ mbcommand(CMD_TOGGLE_CURSOR, NULL);
+ break;
+ }
mbcommand(MB_CMD_COMPOSITE, NULL);
break;
case 'k':
mbcommand(MB_CMB_KEYS_RELOAD, NULL);
break;
+ case 'h':
+ mbcommand(CMD_HIDE_CURSOR, NULL);
+ break;
+ case 's':
+ mbcommand(CMD_SHOW_CURSOR, NULL);
+ break;
case 'p':
if (!strcmp(arg+1,"panel-toggle"))
{
Only in matchbox-window-manager-1.2/src: matchbox-remote.c~
diff -ur matchbox-window-manager-1.2.orig/src/structs.h matchbox-window-manager-1.2/src/structs.h
--- matchbox-window-manager-1.2.orig/src/structs.h 2007-03-19 04:07:15.000000000 -0700
+++ matchbox-window-manager-1.2/src/structs.h 2009-07-16 09:40:54.000000000 -0700
@@ -145,6 +145,9 @@
#define MB_CMD_MISC 7 /* spare, used for debugging */
#define MB_CMD_COMPOSITE 8
#define MB_CMB_KEYS_RELOAD 9
+#define CMD_HIDE_CURSOR 10
+#define CMD_SHOW_CURSOR 11
+#define CMD_TOGGLE_CURSOR 12
/* Atoms, if you change these check ewmh_init() first */
@@ -574,6 +577,7 @@
int flags;
Client* focused_client; /* currently focused client */
+ Bool cursor_is_visible;
/* Stack stuff */
Only in matchbox-window-manager-1.2/src: structs.h~
diff -ur matchbox-window-manager-1.2.orig/src/wm.c matchbox-window-manager-1.2/src/wm.c
--- matchbox-window-manager-1.2.orig/src/wm.c 2007-03-19 04:16:10.000000000 -0700
+++ matchbox-window-manager-1.2/src/wm.c 2009-07-16 10:19:22.000000000 -0700
@@ -176,6 +176,7 @@
w->have_titlebar_panel = NULL;
w->flags ^= STARTUP_FLAG; /* Remove startup flag */
+ w->cursor_is_visible = True;
return w;
}
@@ -362,8 +363,10 @@
if (!strcmp ("-use_cursor", argv[i]))
{
if (++i>=*argc) wm_usage (argv[0]);
- if (strcmp(argv[i], "no") == 0)
+ if (strcmp(argv[i], "no") == 0)
+ {
w->config->no_cursor = True;
+ }
continue;
}
#ifndef USE_COMPOSITE
@@ -942,7 +945,6 @@
dbg("%s() ignoring event->type : %d\n", __func__, ev.type);
break;
}
-
comp_engine_handle_events(w, &ev);
#ifdef USE_XSYNC
@@ -999,6 +1001,20 @@
}
+void wm_handle_change_cursor_event(Wm *w, int visible)
+{
+ if ((visible == 0 && w->cursor_is_visible != False)|| (visible == 3 && w->cursor_is_visible)) //Needed to prevent bug with multiple hides
+ {
+ XFixesHideCursor (w->dpy, w->root);
+ w->cursor_is_visible = False;
+ }
+ else if ((visible == 1 && !w->cursor_is_visible) || visible == 3)
+ {
+ XFixesShowCursor (w->dpy, w->root);
+ w->cursor_is_visible = True;
+ }
+}
+
void
wm_handle_button_event(Wm *w, XButtonEvent *e)
{
@@ -1687,6 +1703,15 @@
dbg("%s() mb command requested %li\n", __func__, e->data.l[0] );
switch (e->data.l[0])
{
+ case CMD_TOGGLE_CURSOR:
+ wm_handle_change_cursor_event(w, 3);
+ break;
+ case CMD_SHOW_CURSOR : //Our custom event type (On Cursor Visibility changed)
+ wm_handle_change_cursor_event(w, 1);
+ break;
+ case CMD_HIDE_CURSOR : //Our custom event type (On Cursor Visibility changed)
+ wm_handle_change_cursor_event(w, 0);
+ break;
#ifndef STANDALONE
case MB_CMD_SET_THEME :
{
@@ -1716,7 +1741,7 @@
return;
}
-#endif
+#endif
case MB_CMD_EXIT :
exit(0);
case MB_CMD_NEXT :
Only in matchbox-window-manager-1.2/src: wm.c~
Only in matchbox-window-manager-1.2/src: wm.h~
Only in matchbox-window-manager-1.2: stamp-h1
<<attachment: cursor_toggle.xpm>>
[Desktop Entry] Version=1.0 Encoding=UTF-8 Type=Application Name=cursor_toggle Comment=Toggle the cursor's visibility Exec=matchbox-remote -cursor-toggle Icon=cursor_toggle.xpm
_______________________________________________ xorg mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/xorg
