File: mouse.cc

package info (click to toggle)
console-apt 0.7.7.2potato2
  • links: PTS
  • area: main
  • in suites: potato
  • size: 612 kB
  • ctags: 658
  • sloc: cpp: 6,883; sh: 152; makefile: 47
file content (94 lines) | stat: -rw-r--r-- 2,142 bytes parent folder | download
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

#include <std.h>

#ifdef HAVE_LIBGPM

#include <list/screens.h>
#include <interface/coreui.h>
#include <interface/dialogs.h>
#include <interface/menu.h>

#include <gpm.h>

int gpm_user_handler(Gpm_Event * event, void *data)
{
	do
	{
		GPM_DRAWPOINTER(event);

		if (active_dialog != 0)
		{
			return active_dialog->gpm_handler(event);
		}
		else if (Gpm_StrictSingle(event->type))
		{
			if (event->y == 0 || event->y == 1)
			{
				if (event->x >= 0 && event->x <= ((COLS / 6) * 1))
					MenuDrop d(MenuDrop::M_Functions);
				else if (event->x > ((COLS / 6) * 1) && event->x <= ((COLS / 6) * 2))
					MenuDrop d(MenuDrop::M_Movement);
				else if (event->x > ((COLS / 6) * 2) && event->x <= ((COLS / 6) * 3))
					MenuDrop d(MenuDrop::M_Toggles);
				else if (event->x > ((COLS / 6) * 3) && event->x <= ((COLS / 6) * 4))
					MenuDrop d(MenuDrop::M_Modifiers);
				else if (event->x > ((COLS / 6) * 4) && event->x <= ((COLS / 6) * 5))
					MenuDrop d(MenuDrop::M_Filters);
				else if (event->x > ((COLS / 6) * 5) && event->x <= COLS)
					MenuDrop d(MenuDrop::M_Sorting);

				ui_refresh_current();
			}
			else if (event->y >= 3 && event->y <= MAIN_LINES + 2)
			{
				screen->_cursor = screen->_boundstart + event->y - 3;
				screen.boundreset(screen.Current());
				ui_redraw_current();
			}
		}

		/*printf
		   ("mouse: %s, at %2i,%2i (delta %2i,%2i), butt %i, mod %02X\r\n",
		   event->type & GPM_DOWN ? "press  " : (event->type & GPM_UP ?
		   "release" : "motion "), event->x, event->y,
		   event->dx, event->dy, event->buttons,
		   event->modifiers); */

		event->dx = event->dy = 0;	/* prepare for repetitions */
		if (event->type & GPM_DOWN)
			event->type = GPM_DRAG;

	}
	while ((event->type & GPM_DRAG) && Gpm_Repeat(200));

	return 0;

}

void gpm_open()
{
	Gpm_Connect conn;

	/* build a catch-all connectionData */

	conn.eventMask = ~0;
	conn.defaultMask = 0;
	conn.maxMod = ~0;
	conn.minMod = 0;

	if (Gpm_Open(&conn, 0) == -1)
	{
		fprintf(stderr, "Can't open mouse connection (GPM).\r\n");
		fflush(stderr);
		//exit(1);
	}			/*if */

	gpm_handler = gpm_user_handler;
}

void gpm_close()
{
	Gpm_Close();
}

#endif