reverted accidental commit

This commit is contained in:
Øyvind Kolås 2007-11-20 17:05:23 +00:00
parent 4320c354a3
commit 80ef0db622
2 changed files with 51 additions and 43 deletions

View File

@ -1120,56 +1120,64 @@ static void
event_click_count_generate (ClutterEvent *event) event_click_count_generate (ClutterEvent *event)
{ {
/* multiple button click detection */ /* multiple button click detection */
static gint click_count[2] = {0, 0}; static guint32 button_click_time[2] = { 0, 0 };
static gint previous_x[2] = {-1, -1}; static guint32 button_number[2] = { -1, -1 };
static gint previous_y[2] = {-1, -1}; static gint button_x[2] = { 0, 0 };
static guint32 previous_time[2] = {0, 0}; static gint button_y[2] = { 0, 0 };
static gint previous_button_number[2] = {-1, -1};
gint s; /* index into the state variable's arrays, 0 for normal
* events and 1 for synthetic events
*/
guint double_click_time, double_click_distance;
ClutterBackend *backend; ClutterBackend *backend;
guint double_click_time; ClutterMainContext *context;
guint double_click_distance;
context = clutter_context_get_default ();
backend = context->backend;
backend = clutter_context_get_default ()->backend;
double_click_distance = clutter_backend_get_double_click_distance (backend); double_click_distance = clutter_backend_get_double_click_distance (backend);
double_click_time = clutter_backend_get_double_click_time (backend); double_click_time = clutter_backend_get_double_click_time (backend);
s = (event->button.flags & CLUTTER_EVENT_FLAG_SYNTHETIC)?1:0; /* FIXME: below could be reduced in lines and handle >3 clicks */
if ((event->button.time < (button_click_time[1] + 2 * double_click_time))
&& (event->button.button == button_number[1])
&& (ABS (event->button.x - button_x[1]) <= double_click_distance)
&& (ABS (event->button.y - button_y[1]) <= double_click_distance))
{
event->button.click_count = 2;
switch (event->type) button_click_time[1] = 0;
{ button_click_time[0] = 0;
case CLUTTER_BUTTON_PRESS: button_number[1] = -1;
case CLUTTER_SCROLL: button_number[0] = -1;
/* check if we are in time and within distance to increment an button_x[0] = button_x[1] = 0;
* existing click count button_y[0] = button_y[1] = 0;
*/
if (event->button.time < previous_time[s] + double_click_time &&
(ABS (event->button.x - previous_x[s]) <= double_click_distance) &&
(ABS (event->button.y - previous_y[s]) <= double_click_distance)
&& event->button.button == previous_button_number[s])
{
click_count[s] ++;
} }
else /* start a new click count*/ else if ((event->button.time < (button_click_time[0] + double_click_time)) &&
(event->button.button == button_number[0]) &&
(ABS (event->button.x - button_x[0]) <= double_click_distance) &&
(ABS (event->button.y - button_y[0]) <= double_click_distance))
{ {
click_count[s]=1; event->button.click_count = 3;
previous_button_number[s] = event->button.button;
button_click_time[1] = button_click_time[0];
button_click_time[0] = event->button.time;
button_number[1] = button_number[0];
button_number[0] = event->button.button;
button_x[1] = button_x[0];
button_x[0] = event->button.x;
button_y[1] = button_y[0];
button_y[0] = event->button.y;
} }
else
{
event->button.click_count = 1;
/* store time and position for this click for comparison with next event */ button_click_time[1] = 0;
previous_time[s] = event->button.time; button_click_time[0] = event->button.time;
previous_x[s] = event->button.x; button_number[1] = -1;
previous_y[s] = event->button.y; button_number[0] = event->button.button;
button_x[1] = 0;
/* fallthrough */ button_x[0] = event->button.x;
case CLUTTER_BUTTON_RELEASE: button_y[1] = 0;
event->button.click_count=click_count[s]; button_y[0] = event->button.y;
break;
default:
g_assert (NULL);
} }
} }

View File

@ -124,7 +124,7 @@ clutter_stage_glx_realize (ClutterActor *actor)
0 0
}; };
if (stage_x11->xvisinfo) if (stage_x11->xvisinfo && stage_x11->is_foreign_xwin == 0)
XFree (stage_x11->xvisinfo); XFree (stage_x11->xvisinfo);
if (stage_x11->xvisinfo == None) if (stage_x11->xvisinfo == None)