fix middle click only left click; rename enum for mouse click

This commit is contained in:
rick 2022-12-17 03:06:21 +01:00
parent 6126d62097
commit e97e5f5009
Signed by: Rick
GPG key ID: 4A6223D66294EB20
4 changed files with 16 additions and 14 deletions

View file

@ -26,13 +26,14 @@ void init_event(event *event, char is_pressed)
void mouse_event(event *event, mouse_button button)
{
init_event(event, 0);
/* FIXME vérifier tous les flags pour des clics de souris en simultané */
switch (button)
{
case LEFT: event->infos |= 0x01;
case M_LEFT: event->infos |= 0x01;
break;
case RIGHT: event->infos |= 0x02;
case M_RIGHT: event->infos |= 0x02;
break;
case MIDDLE: event->infos |= 0x3;
case M_MIDDLE: event->infos |= 0x3;
break;
}
}

View file

@ -26,9 +26,10 @@ typedef struct {
} event;
typedef enum {
LEFT = 0x01,
RIGHT = 0x10,
MIDDLE = 0x11
M_NONE = 0,
M_LEFT = 0x01,
M_RIGHT = 0x02,
M_MIDDLE = 0x03
} mouse_button;

View file

@ -90,11 +90,11 @@ int listen(FILE *file)
/* printf("%d - %d\n", event.xmotion.x, event.xmotion.y); */
if ((left || right) && !(left && right)) {
mouse_button type_button;
if (left) type_button = LEFT;
if (right) type_button = RIGHT;
if (middle) type_button = MIDDLE;
if (left || right) {
mouse_button type_button = M_NONE;
if (left) type_button |= M_LEFT;
if (right) type_button |= M_RIGHT;
if (middle) type_button |= M_MIDDLE;
mouse_event_coord(user_event, type_button, event.xmotion.x, event.xmotion.y);
write_event(user_event, file);

View file

@ -32,9 +32,9 @@ void readfile(args_readfile *args)
break;
}
left = current_event->infos & LEFT;
right = current_event->infos & RIGHT;
middle = current_event->infos & MIDDLE;
left = (current_event->infos & M_LEFT) == M_LEFT;
right =(current_event->infos & M_RIGHT) == M_RIGHT;
middle=(current_event->infos & M_MIDDLE) == M_MIDDLE ;
x = current_event->x;
y = current_event->y;