diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2009-03-02 11:46:00 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2009-03-04 11:24:27 +1000 |
commit | 40dbe97f6138705369c30b4ad95014bd07c6913d (patch) | |
tree | 3e01f58dc740942ba439b72fbd01eec73f0df7fd /tools/syndaemon.c | |
parent | d52d633fcdbf0a6c3dcc0af43d40ab7e217ff89b (diff) |
syndaemon: move shm code into shm_init().
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Acked-by: Julien Cristau <jcristau@debian.org>
Diffstat (limited to 'tools/syndaemon.c')
-rw-r--r-- | tools/syndaemon.c | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/tools/syndaemon.c b/tools/syndaemon.c index 65112ab..515a132 100644 --- a/tools/syndaemon.c +++ b/tools/syndaemon.c @@ -438,6 +438,28 @@ void record_main_loop(Display* display, double idle_time) { } #endif /* HAVE_XRECORD */ +static int +shm_init() +{ + int shmid; + + /* Connect to the shared memory area */ + if ((shmid = shmget(SHM_SYNAPTICS, sizeof(SynapticsSHM), 0)) == -1) { + if ((shmid = shmget(SHM_SYNAPTICS, 0, 0)) == -1) { + fprintf(stderr, "Can't access shared memory area. SHMConfig disabled?\n"); + return 0; + } else { + fprintf(stderr, "Incorrect size of shared memory area. Incompatible driver version?\n"); + return 0; + } + } + if ((synshm = (SynapticsSHM*) shmat(shmid, NULL, 0)) == NULL) { + perror("shmat"); + return 0; + } + return 1; +} + int main(int argc, char *argv[]) { @@ -445,7 +467,6 @@ main(int argc, char *argv[]) int poll_delay = 200000; /* 200 ms */ Display *display; int c; - int shmid; int use_xrecord = 1; @@ -492,20 +513,8 @@ main(int argc, char *argv[]) exit(2); } - /* Connect to the shared memory area */ - if ((shmid = shmget(SHM_SYNAPTICS, sizeof(SynapticsSHM), 0)) == -1) { - if ((shmid = shmget(SHM_SYNAPTICS, 0, 0)) == -1) { - fprintf(stderr, "Can't access shared memory area. SHMConfig disabled?\n"); - exit(2); - } else { - fprintf(stderr, "Incorrect size of shared memory area. Incompatible driver version?\n"); - exit(2); - } - } - if ((synshm = (SynapticsSHM*) shmat(shmid, NULL, 0)) == NULL) { - perror("shmat"); + if (!shm_init()) exit(2); - } /* Install a signal handler to restore synaptics parameters on exit */ install_signal_handler(); |