1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
/* Metacity device functions */
/*
* Copyright (C) 2007 Paulo Ricardo Zanoni
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/
#include <config.h>
#include "devices.h"
#include "common.h"
#include "util.h"
#include "display.h"
#include <string.h>
#ifdef MPX
/* TODO: if these were macros, metacity would be faster! */
/* Should we :%s/find/get/g ??? */
MetaDevInfo*
meta_devices_find_mouse_by_name (MetaDisplay *display,
gchar *name)
{
int i;
for (i = 0; i < display->devices->miceUsed; i++)
if (strcmp(name, display->devices->mice[i].name) == 0)
return &display->devices->mice[i];
meta_warning ("Error! Could not find mouse named %s!\n", name);
return NULL;
}
MetaDevInfo*
meta_devices_find_mouse_by_id (MetaDisplay *display,
XID id)
{
int i;
for (i = 0; i < display->devices->miceUsed; i++)
if (id == display->devices->mice[i].xdev->device_id)
return &display->devices->mice[i];
meta_warning ("Error! Could not find mouse XID = %d!\n", (int) id);
return NULL;
}
MetaDevInfo*
meta_devices_find_keyboard_by_id (MetaDisplay *display,
XID id)
{
int i;
for (i = 0; i < display->devices->keybsUsed; i++)
if (id == display->devices->keyboards[i].xdev->device_id)
return &display->devices->keyboards[i];
meta_warning ("Error! Could not find keyboard XID = %d\n", (int) id);
return NULL;
}
MetaDevInfo*
meta_devices_find_paired_mouse (MetaDisplay *display, XID id)
{
int i, j;
for (i = 0; i < display->devices->keybsUsed; i++)
if (id == display->devices->keyboards[i].xdev->device_id)
{
for (j = 0; j < display->devices->miceUsed; j++)
if (display->devices->pairedPointers[i] ==
display->devices->mice[j].xdev->device_id)
return &display->devices->mice[j];
}
meta_warning("Error! Could not find mouse paired with keyboard XID = %d."
" This should never happen!!!.\n",
(int) id);
return NULL;
}
MetaDevInfo*
meta_devices_find_paired_keyboard (MetaDisplay *display, XID id)
{
/* FIXME: there can be more than one keyboard paired with the mouse... */
int i;
for (i = 0; i < display->devices->keybsUsed; i++)
if (id == display->devices->pairedPointers[i])
return &display->devices->keyboards[i];
meta_warning("Could not find keyboard paired with mouse XID = %d."
" Using another device.\n",
(int) id);
return &display->devices->keyboards[0];
}
#endif
|