summaryrefslogtreecommitdiff
path: root/launcher
diff options
authorDaniel d'Andrada <daniel.dandrada@canonical.com>2012-07-27 17:20:29 -0300
committerDaniel d'Andrada <daniel.dandrada@canonical.com>2012-07-27 17:20:29 -0300
commit738b3f1a75fe3b4f5b97838a5b06b80f4d158926 (patch)
tree2f0f580ea30ebdaea9d50a5b584ec0b83d9bb5e3 /launcher
parentfde2f5ce406aeb7c1b9753393a152c0f313db457 (diff)
Use gestures support from Nux and adapt code for regular gesture rules
Remove GeisAdapter as we are getting gesture events from Nux instead. Then modify code to handle geisv2-style gestures. They require acceptance/rejection and enable multiple simultaneous gestures (bzr r2526.1.1)
Diffstat (limited to 'launcher')
-rw-r--r--launcher/CMakeLists.txt1
-rw-r--r--launcher/GeisAdapter.cpp521
-rw-r--r--launcher/GeisAdapter.h172
-rw-r--r--launcher/Launcher.cpp89
-rw-r--r--launcher/Launcher.h10
-rw-r--r--launcher/StandaloneLauncher.cpp1
6 files changed, 55 insertions, 739 deletions
diff --git a/launcher/CMakeLists.txt b/launcher/CMakeLists.txt
index ceefbdb0e..3ac9e8db8 100644
--- a/launcher/CMakeLists.txt
+++ b/launcher/CMakeLists.txt
@@ -45,7 +45,6 @@ set (LAUNCHER_SOURCES
FavoriteStore.cpp
FavoriteStoreGSettings.cpp
FavoriteStorePrivate.cpp
- GeisAdapter.cpp
HudLauncherIcon.cpp
Launcher.cpp
LauncherController.cpp
diff --git a/launcher/GeisAdapter.cpp b/launcher/GeisAdapter.cpp
deleted file mode 100644
index d9fe220af..000000000
--- a/launcher/GeisAdapter.cpp
+++ /dev/null
@@ -1,521 +0,0 @@
-// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
-/*
- * Copyright (C) 2010 Canonical Ltd
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 3 as
- * published by the Free Software Foundation.
- *
- * 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, see <http://www.gnu.org/licenses/>.
- *
- * Authored by: Jason Smith <jason.smith@canonical.com>
- */
-
-#include <glib.h>
-#include <gdk/gdkx.h>
-#include <NuxCore/Logger.h>
-#include "GeisAdapter.h"
-
-namespace
-{
- GeisAdapter* adaptor_instance = nullptr;
- nux::logging::Logger logger("unity.geisadapter");
-}
-
-/* static */
-GeisAdapter& GeisAdapter::Instance()
-{
- if (!adaptor_instance)
- {
- LOG_ERROR(logger) << "No GeisAdapter created yet.";
- }
-
- return *adaptor_instance;
-}
-
-GeisAdapter::GeisAdapter() : _root_instance(nullptr)
-{
- if (adaptor_instance)
- {
- LOG_ERROR(logger) << "More than one GeisAdapter created.";
- }
- else
- {
- adaptor_instance = this;
- }
- RegisterRootInstance();
-}
-
-GeisAdapter::~GeisAdapter()
-{
- if (_root_instance != nullptr)
- geis_finish(_root_instance);
- if (adaptor_instance == this)
- {
- adaptor_instance = nullptr;
- }
-}
-
-void
-GeisAdapter::Run()
-{
- int fd = -1;
- GeisStatus status = GEIS_STATUS_NOT_SUPPORTED;
-
- if (_root_instance != nullptr)
- status = geis_configuration_get_value(_root_instance, GEIS_CONFIG_UNIX_FD, &fd);
-
- if (status != GEIS_STATUS_SUCCESS)
- return;
-
- _watch_id = g_io_add_watch(g_io_channel_unix_new(fd),
- G_IO_IN,
- &GeisAdapter::OnWatchIn,
- this);
-}
-
-gboolean
-GeisAdapter::OnWatchIn(GIOChannel* source, GIOCondition condition, gpointer data)
-{
- GeisAdapter* self = static_cast<GeisAdapter*>(data);
- geis_event_dispatch(self->_root_instance);
- return true;
-}
-
-void
-GeisAdapter::InputDeviceAdded(void* cookie, GeisInputDeviceId device_id, void* attrs)
-{
-}
-
-
-void
-GeisAdapter::InputDeviceChanged(void* cookie, GeisInputDeviceId device_id, void* attrs)
-{
-}
-
-
-void
-GeisAdapter::InputDeviceRemoved(void* cookie, GeisInputDeviceId device_id, void* attrs)
-{
-}
-
-void
-GeisAdapter::GestureAdded(void* cookie, GeisGestureType gesture_type, GeisGestureId gesture_id, GeisSize count, GeisGestureAttr* attrs)
-{
-}
-
-void
-GeisAdapter::GestureRemoved(void* cookie, GeisGestureType gesture_type, GeisGestureId gesture_id, GeisSize count, GeisGestureAttr* attrs)
-{
-}
-
-void
-GeisAdapter::GestureStart(void* cookie, GeisGestureType gesture_type, GeisGestureId gesture_id, GeisSize count, GeisGestureAttr* attrs)
-{
- GeisAdapter* self = static_cast<GeisAdapter*>(cookie);
-
- if (gesture_type == GEIS_GESTURE_PRIMITIVE_DRAG)
- {
- GeisDragData* data = self->ProcessDragGesture(count, attrs);
- data->id = gesture_id;
- self->drag_start.emit(data);
- g_free(data);
- }
- else if (gesture_type == GEIS_GESTURE_PRIMITIVE_ROTATE)
- {
- GeisRotateData* data = self->ProcessRotateGesture(count, attrs);
- data->id = gesture_id;
- self->rotate_start.emit(data);
- g_free(data);
- }
- else if (gesture_type == GEIS_GESTURE_PRIMITIVE_PINCH)
- {
- GeisPinchData* data = self->ProcessPinchGesture(count, attrs);
- data->id = gesture_id;
- self->pinch_start.emit(data);
- g_free(data);
- }
- else if (gesture_type == GEIS_GESTURE_PRIMITIVE_TAP)
- {
- GeisTapData* data = self->ProcessTapGesture(count, attrs);
- data->id = gesture_id;
- self->tap.emit(data);
- g_free(data);
- }
- else if (gesture_type == GEIS_GESTURE_PRIMITIVE_TOUCH)
- {
- GeisTouchData* data = self->ProcessTouchGesture(count, attrs);
- data->id = gesture_id;
- self->touch_start.emit(data);
- g_free(data);
- }
-}
-
-void
-GeisAdapter::GestureUpdate(void* cookie, GeisGestureType gesture_type, GeisGestureId gesture_id, GeisSize count, GeisGestureAttr* attrs)
-{
- GeisAdapter* self = static_cast<GeisAdapter*>(cookie);
-
- if (gesture_type == GEIS_GESTURE_PRIMITIVE_DRAG)
- {
- GeisDragData* data = self->ProcessDragGesture(count, attrs);
- data->id = gesture_id;
- self->drag_update.emit(data);
- g_free(data);
- }
- else if (gesture_type == GEIS_GESTURE_PRIMITIVE_ROTATE)
- {
- GeisRotateData* data = self->ProcessRotateGesture(count, attrs);
- data->id = gesture_id;
- self->rotate_update.emit(data);
- g_free(data);
- }
- else if (gesture_type == GEIS_GESTURE_PRIMITIVE_PINCH)
- {
- GeisPinchData* data = self->ProcessPinchGesture(count, attrs);
- data->id = gesture_id;
- self->pinch_update.emit(data);
- g_free(data);
- }
- else if (gesture_type == GEIS_GESTURE_PRIMITIVE_TAP)
- {
- GeisTapData* data = self->ProcessTapGesture(count, attrs);
- data->id = gesture_id;
- self->tap.emit(data);
- g_free(data);
- }
- else if (gesture_type == GEIS_GESTURE_PRIMITIVE_TOUCH)
- {
- GeisTouchData* data = self->ProcessTouchGesture(count, attrs);
- data->id = gesture_id;
- self->touch_update.emit(data);
- g_free(data);
- }
-}
-
-void
-GeisAdapter::GestureFinish(void* cookie, GeisGestureType gesture_type, GeisGestureId gesture_id, GeisSize count, GeisGestureAttr* attrs)
-{
- GeisAdapter* self = static_cast<GeisAdapter*>(cookie);
-
- if (gesture_type == GEIS_GESTURE_PRIMITIVE_DRAG)
- {
- GeisDragData* data = self->ProcessDragGesture(count, attrs);
- data->id = gesture_id;
- self->drag_finish.emit(data);
- g_free(data);
- }
- else if (gesture_type == GEIS_GESTURE_PRIMITIVE_ROTATE)
- {
- GeisRotateData* data = self->ProcessRotateGesture(count, attrs);
- data->id = gesture_id;
- self->rotate_finish.emit(data);
- g_free(data);
- }
- else if (gesture_type == GEIS_GESTURE_PRIMITIVE_PINCH)
- {
- GeisPinchData* data = self->ProcessPinchGesture(count, attrs);
- data->id = gesture_id;
- self->pinch_finish.emit(data);
- g_free(data);
- }
- else if (gesture_type == GEIS_GESTURE_PRIMITIVE_TAP)
- {
- GeisTapData* data = self->ProcessTapGesture(count, attrs);
- data->id = gesture_id;
- self->tap.emit(data);
- g_free(data);
- }
- else if (gesture_type == GEIS_GESTURE_PRIMITIVE_TOUCH)
- {
- GeisTouchData* data = self->ProcessTouchGesture(count, attrs);
- data->id = gesture_id;
- self->touch_finish.emit(data);
- g_free(data);
- }
-}
-
-GeisAdapter::GeisTapData* GeisAdapter::ProcessTapGesture(GeisSize count, GeisGestureAttr* attrs)
-{
- GeisTapData* result = (GeisTapData*) g_malloc0(sizeof(GeisTapData));
-
- int i;
- for (i = 0; i < (int) count; i++)
- {
- GeisGestureAttr attr = attrs[i];
- if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_DEVICE_ID))
- result->device_id = attr.integer_val;
- else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_CHILD_WINDOW_ID))
- result->window = (Window) attr.integer_val;
- else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_TIMESTAMP))
- result->timestamp = attr.integer_val;
- else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_FOCUS_X))
- result->focus_x = attr.float_val;
- else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_FOCUS_Y))
- result->focus_y = attr.float_val;
- else if (g_str_equal (attr.name, GEIS_GESTURE_ATTRIBUTE_TOUCHES))
- result->touches = attr.integer_val;
- else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_GESTURE_NAME))
- {
- if (!g_strcmp0(attr.string_val, GEIS_GESTURE_TYPE_TAP1))
- result->touches = 1;
- else if (!g_strcmp0(attr.string_val, GEIS_GESTURE_TYPE_TAP2))
- result->touches = 2;
- else if (!g_strcmp0(attr.string_val, GEIS_GESTURE_TYPE_TAP3))
- result->touches = 3;
- else if (!g_strcmp0(attr.string_val, GEIS_GESTURE_TYPE_TAP4))
- result->touches = 4;
- else if (!g_strcmp0(attr.string_val, GEIS_GESTURE_TYPE_TAP5))
- result->touches = 5;
- }
- else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_TAP_TIME))
- result->tap_length_ms = attr.integer_val;
- else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_POSITION_X))
- result->position_x = attr.float_val;
- else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_POSITION_Y))
- result->position_y = attr.float_val;
- else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_BOUNDINGBOX_X1))
- result->bound_x1 = attr.float_val;
- else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_BOUNDINGBOX_Y1))
- result->bound_y1 = attr.float_val;
- else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_BOUNDINGBOX_X2))
- result->bound_x2 = attr.float_val;
- else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_BOUNDINGBOX_Y2))
- result->bound_y2 = attr.float_val;
- }
-
- return result;
-}
-
-GeisAdapter::GeisTouchData* GeisAdapter::ProcessTouchGesture(GeisSize count, GeisGestureAttr* attrs)
-{
- GeisTouchData* result = (GeisTouchData*) g_malloc0(sizeof(GeisTouchData));
-
- int i;
- for (i = 0; i < (int) count; i++)
- {
- GeisGestureAttr attr = attrs[i];
- if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_DEVICE_ID))
- result->device_id = attr.integer_val;
- else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_CHILD_WINDOW_ID))
- result->window = (Window) attr.integer_val;
- else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_TIMESTAMP))
- result->timestamp = attr.integer_val;
- else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_FOCUS_X))
- result->focus_x = attr.float_val;
- else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_FOCUS_Y))
- result->focus_y = attr.float_val;
- else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_TOUCHES))
- result->touches = attr.integer_val;
- else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_BOUNDINGBOX_X1))
- result->bound_x1 = attr.float_val;
- else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_BOUNDINGBOX_Y1))
- result->bound_y1 = attr.float_val;
- else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_BOUNDINGBOX_X2))
- result->bound_x2 = attr.float_val;
- else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_BOUNDINGBOX_Y2))
- result->bound_y2 = attr.float_val;
- }
-
- return result;
-}
-
-GeisAdapter::GeisDragData* GeisAdapter::ProcessDragGesture(GeisSize count, GeisGestureAttr* attrs)
-{
- GeisDragData* result = (GeisDragData*) g_malloc0(sizeof(GeisDragData));
-
- int i;
- for (i = 0; i < (int) count; i++)
- {
- GeisGestureAttr attr = attrs[i];
- if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_DEVICE_ID))
- result->device_id = attr.integer_val;
- else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_CHILD_WINDOW_ID))
- result->window = (Window) attr.integer_val;
- else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_TIMESTAMP))
- result->timestamp = attr.integer_val;
- else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_FOCUS_X))
- result->focus_x = attr.float_val;
- else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_FOCUS_Y))
- result->focus_y = attr.float_val;
- else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_TOUCHES))
- result->touches = attr.integer_val;
- else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_POSITION_X))
- result->position_x = attr.float_val;
- else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_POSITION_Y))
- result->position_y = attr.float_val;
- else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_VELOCITY_X))
- result->velocity_x = attr.float_val;
- else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_VELOCITY_Y))
- result->velocity_y = attr.float_val;
- else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_DELTA_X))
- result->delta_x = attr.float_val;
- else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_DELTA_Y))
- result->delta_y = attr.float_val;
- else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_BOUNDINGBOX_X1))
- result->bound_x1 = attr.float_val;
- else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_BOUNDINGBOX_Y1))
- result->bound_y1 = attr.float_val;
- else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_BOUNDINGBOX_X2))
- result->bound_x2 = attr.float_val;
- else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_BOUNDINGBOX_Y2))
- result->bound_y2 = attr.float_val;
- }
-
- return result;
-}
-
-GeisAdapter::GeisPinchData* GeisAdapter::ProcessPinchGesture(GeisSize count, GeisGestureAttr* attrs)
-{
- GeisPinchData* result = (GeisPinchData*) g_malloc0(sizeof(GeisPinchData));
-
- int i;
- for (i = 0; i < (int) count; i++)
- {
- GeisGestureAttr attr = attrs[i];
- if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_DEVICE_ID))
- result->device_id = attr.integer_val;
- else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_CHILD_WINDOW_ID))
- result->window = (Window) attr.integer_val;
- else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_TIMESTAMP))
- result->timestamp = attr.integer_val;
- else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_FOCUS_X))
- result->focus_x = attr.float_val;
- else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_FOCUS_Y))
- result->focus_y = attr.float_val;
- else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_TOUCHES))
- result->touches = attr.integer_val;
- else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_RADIUS))
- result->radius = attr.float_val;
- else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_RADIUS_DELTA))
- result->radius_delta = attr.float_val;
- else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_RADIAL_VELOCITY))
- result->radius_velocity = attr.float_val;
- else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_BOUNDINGBOX_X1))
- result->bound_x1 = attr.float_val;
- else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_BOUNDINGBOX_Y1))
- result->bound_y1 = attr.float_val;
- else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_BOUNDINGBOX_X2))
- result->bound_x2 = attr.float_val;
- else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_BOUNDINGBOX_Y2))
- result->bound_y2 = attr.float_val;
- }
-
- return result;
-}
-
-GeisAdapter::GeisRotateData* GeisAdapter::ProcessRotateGesture(GeisSize count, GeisGestureAttr* attrs)
-{
- GeisRotateData* result = (GeisRotateData*) g_malloc0(sizeof(GeisRotateData));
-
- int i;
- for (i = 0; i < (int) count; i++)
- {
- GeisGestureAttr attr = attrs[i];
- if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_DEVICE_ID))
- result->device_id = attr.integer_val;
- else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_CHILD_WINDOW_ID))
- result->window = (Window) attr.integer_val;
- else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_TIMESTAMP))
- result->timestamp = attr.integer_val;
- else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_FOCUS_X))
- result->focus_x = attr.float_val;
- else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_FOCUS_Y))
- result->focus_y = attr.float_val;
- else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_TOUCHES))
- result->touches = attr.integer_val;
- else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_ANGLE))
- result->angle = attr.float_val;
- else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_ANGLE_DELTA))
- result->angle_delta = attr.float_val;
- else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_ANGULAR_VELOCITY))
- result->angle_velocity = attr.float_val;
- else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_BOUNDINGBOX_X1))
- result->bound_x1 = attr.float_val;
- else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_BOUNDINGBOX_Y1))
- result->bound_y1 = attr.float_val;
- else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_BOUNDINGBOX_X2))
- result->bound_x2 = attr.float_val;
- else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_BOUNDINGBOX_Y2))
- result->bound_y2 = attr.float_val;
- }
-
- return result;
-}
-
-static const char* s_gestures[] =
-{
- GEIS_GESTURE_TYPE_DRAG3, GEIS_GESTURE_TYPE_TAP3, GEIS_GESTURE_TYPE_ROTATE3, GEIS_GESTURE_TYPE_PINCH3, GEIS_GESTURE_TYPE_TOUCH3,
- GEIS_GESTURE_TYPE_DRAG4, GEIS_GESTURE_TYPE_TAP4, GEIS_GESTURE_TYPE_ROTATE4, GEIS_GESTURE_TYPE_PINCH4, GEIS_GESTURE_TYPE_TOUCH4,
- GEIS_GESTURE_TYPE_SYSTEM,
- NULL
-};
-
-void
-GeisAdapter::RegisterRootInstance()
-{
- static GeisInputFuncs input_funcs =
- {
- &GeisAdapter::InputDeviceAdded,
- &GeisAdapter::InputDeviceChanged,
- &GeisAdapter::InputDeviceRemoved
- };
-
- static GeisGestureFuncs gesture_funcs =
- {
- &GeisAdapter::GestureAdded,
- &GeisAdapter::GestureRemoved,
- &GeisAdapter::GestureStart,
- &GeisAdapter::GestureUpdate,
- &GeisAdapter::GestureFinish
- };
-
- GeisStatus status = GEIS_UNKNOWN_ERROR;
-
- GeisXcbWinInfo xcb_win_info;
- xcb_win_info.display_name = NULL,
- xcb_win_info.screenp = NULL,
- xcb_win_info.window_id = gdk_x11_get_default_root_xwindow();
-
- GeisWinInfo win_info =
- {
- GEIS_XCB_FULL_WINDOW,
- &xcb_win_info
- };
- GeisInstance instance;
-
- status = geis_init(&win_info, &instance);
- if (status != GEIS_STATUS_SUCCESS)
- {
- fprintf(stderr, "error in geis_init\n");
- return;
- }
-
- status = geis_input_devices(instance, &input_funcs, this);
- if (status != GEIS_STATUS_SUCCESS)
- {
- fprintf(stderr, "error subscribing to input devices\n");
- geis_finish(instance);
- return;
- }
-
- status = geis_subscribe(instance,
- GEIS_ALL_INPUT_DEVICES,
- s_gestures,
- &gesture_funcs,
- this);
- if (status != GEIS_STATUS_SUCCESS)
- {
- fprintf(stderr, "error subscribing to gestures\n");
- geis_finish(instance);
- return;
- }
-
- _root_instance = instance;
-}
diff --git a/launcher/GeisAdapter.h b/launcher/GeisAdapter.h
deleted file mode 100644
index f68923bed..000000000
--- a/launcher/GeisAdapter.h
+++ /dev/null
@@ -1,172 +0,0 @@
-// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
-/*
- * Copyright (C) 2010 Canonical Ltd
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 3 as
- * published by the Free Software Foundation.
- *
- * 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
- * aint with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- * Authored by: Jason Smith <jason.smith@canonical.com>
- */
-
-#ifndef GEISADAPTER_H
-#define GEISADAPTER_H
-
-/* Compiz */
-#include <sigc++/sigc++.h>
-#include <geis/geis.h>
-#include <Nux/Nux.h>
-
-class GeisAdapter : public sigc::trackable
-{
-public:
- static GeisAdapter& Instance();
-
- GeisAdapter();
- ~GeisAdapter();
-
- void Run();
-
- typedef struct _GeisTapData
- {
- int id;
- int device_id;
- Window window;
- int touches;
- int timestamp;
- float focus_x;
- float focus_y;
- int tap_length_ms;
- float position_x;
- float position_y;
- float bound_x1;
- float bound_y1;
- float bound_x2;
- float bound_y2;
- } GeisTapData;
-
- typedef struct _GeisDragData
- {
- int id;
- int device_id;
- Window window;
- int touches;
- int timestamp;
- float focus_x;
- float focus_y;
- float delta_x;
- float delta_y;
- float velocity_x;
- float velocity_y;
- float position_x;
- float position_y;
- float bound_x1;
- float bound_y1;
- float bound_x2;
- float bound_y2;
- } GeisDragData;
-
- typedef struct _GeisRotateData
- {
- int id;
- int device_id;
- Window window;
- int touches;
- int timestamp;
- float focus_x;
- float focus_y;
- float angle;
- float angle_delta;
- float angle_velocity;
- float bound_x1;
- float bound_y1;
- float bound_x2;
- float bound_y2;
- } GeisRotateData;
-
- typedef struct _GeisPinchData
- {
- int id;
- int device_id;
- Window window;
- int touches;
- int timestamp;
- float focus_x;
- float focus_y;
- float radius;
- float radius_delta;
- float radius_velocity;
- float bound_x1;
- float bound_y1;
- float bound_x2;
- float bound_y2;
- } GeisPinchData;
-
- typedef struct _GeisTouchData
- {
- int id;
- int device_id;
- Window window;
- int touches;
- int timestamp;
- float focus_x;
- float focus_y;
- float bound_x1;
- float bound_y1;
- float bound_x2;
- float bound_y2;
- } GeisTouchData;
-
- sigc::signal<void, GeisTapData*> tap;
-
- sigc::signal<void, GeisDragData*> drag_start;
- sigc::signal<void, GeisDragData*> drag_update;
- sigc::signal<void, GeisDragData*> drag_finish;
-
- sigc::signal<void, GeisRotateData*> rotate_start;
- sigc::signal<void, GeisRotateData*> rotate_update;
- sigc::signal<void, GeisRotateData*> rotate_finish;
-
- sigc::signal<void, GeisPinchData*> pinch_start;
- sigc::signal<void, GeisPinchData*> pinch_update;
- sigc::signal<void, GeisPinchData*> pinch_finish;
-
- sigc::signal<void, GeisTouchData*> touch_start;
- sigc::signal<void, GeisTouchData*> touch_update;
- sigc::signal<void, GeisTouchData*> touch_finish;
-protected:
- static gboolean OnWatchIn(GIOChannel* source, GIOCondition condition, gpointer data);
-
- static void InputDeviceAdded(void* cookie, GeisInputDeviceId device_id, void* attrs);
- static void InputDeviceChanged(void* cookie, GeisInputDeviceId device_id, void* attrs);
- static void InputDeviceRemoved(void* cookie, GeisInputDeviceId device_id, void* attrs);
-
- static void GestureAdded(void* cookie, GeisGestureType gesture_type, GeisGestureId gesture_id, GeisSize attr_count, GeisGestureAttr* attrs);
- static void GestureRemoved(void* cookie, GeisGestureType gesture_type, GeisGestureId gesture_id, GeisSize attr_count, GeisGestureAttr* attrs);
-
- static void GestureStart(void* cookie, GeisGestureType gesture_type, GeisGestureId gesture_id, GeisSize attr_count, GeisGestureAttr* attrs);
- static void GestureUpdate(void* cookie, GeisGestureType gesture_type, GeisGestureId gesture_id, GeisSize attr_count, GeisGestureAttr* attrs);
- static void GestureFinish(void* cookie, GeisGestureType gesture_type, GeisGestureId gesture_id, GeisSize attr_count, GeisGestureAttr* attrs);
-
- GeisTapData* ProcessTapGesture(GeisSize attr_count, GeisGestureAttr* attrs);
- GeisDragData* ProcessDragGesture(GeisSize attr_count, GeisGestureAttr* attrs);
- GeisPinchData* ProcessPinchGesture(GeisSize attr_count, GeisGestureAttr* attrs);
- GeisRotateData* ProcessRotateGesture(GeisSize attr_count, GeisGestureAttr* attrs);
- GeisTouchData* ProcessTouchGesture(GeisSize attr_count, GeisGestureAttr* attrs);
-
-private:
- void RegisterRootInstance();
-
- GeisInstance _root_instance;
- guint _watch_id;
-};
-
-#endif
diff --git a/launcher/Launcher.cpp b/launcher/Launcher.cpp
index bd6ebb3c5..3c9aa84cb 100644
--- a/launcher/Launcher.cpp
+++ b/launcher/Launcher.cpp
@@ -29,6 +29,7 @@
#include <NuxCore/Logger.h>
#include <NuxGraphics/NuxGraphics.h>
+#include <NuxGraphics/GestureEvent.h>
#include <NuxGraphics/GpuDevice.h>
#include <NuxGraphics/GLTextureResourceManager.h>
@@ -136,8 +137,8 @@ Launcher::Launcher(nux::BaseWindow* parent,
, _launcher_drag_delta_min(0)
, _enter_y(0)
, _last_button_press(0)
- , _drag_out_id(0)
, _drag_out_delta_x(0.0f)
+ , _drag_gesture_ongoing(false)
, _last_reveal_progress(0.0f)
, _collection_window(collection_window)
, _selection_atom(0)
@@ -185,11 +186,6 @@ Launcher::Launcher(nux::BaseWindow* parent,
plugin_adapter.terminate_expo.connect(sigc::mem_fun(this, &Launcher::OnPluginStateChanged));
plugin_adapter.compiz_screen_viewport_switch_ended.connect(sigc::mem_fun(this, &Launcher::EnsureAnimation));
- GeisAdapter& adapter = GeisAdapter::Instance();
- adapter.drag_start.connect(sigc::mem_fun(this, &Launcher::OnDragStart));
- adapter.drag_update.connect(sigc::mem_fun(this, &Launcher::OnDragUpdate));
- adapter.drag_finish.connect(sigc::mem_fun(this, &Launcher::OnDragFinish));
-
display.changed.connect(sigc::mem_fun(this, &Launcher::OnDisplayChanged));
// 0 out timers to avoid wonky startups
@@ -233,45 +229,39 @@ void Launcher::OnDisplayChanged(Display* display)
_collection_window->display = display;
}
-void Launcher::OnDragStart(GeisAdapter::GeisDragData* data)
+void
+Launcher::OnDragStart(const nux::GestureEvent &event)
{
- if (_drag_out_id && _drag_out_id == data->id)
- return;
-
- if (data->touches == 4)
+ _drag_gesture_ongoing = true;
+ if (_hidden)
{
- _drag_out_id = data->id;
- if (_hidden)
- {
- _drag_out_delta_x = 0.0f;
- }
- else
- {
- _drag_out_delta_x = DRAG_OUT_PIXELS;
- _hide_machine.SetQuirk(LauncherHideMachine::MT_DRAG_OUT, false);
- }
+ _drag_out_delta_x = 0.0f;
+ }
+ else
+ {
+ _drag_out_delta_x = DRAG_OUT_PIXELS;
+ _hide_machine.SetQuirk(LauncherHideMachine::MT_DRAG_OUT, false);
}
}
-void Launcher::OnDragUpdate(GeisAdapter::GeisDragData* data)
+void
+Launcher::OnDragUpdate(const nux::GestureEvent &event)
{
- if (data->id == _drag_out_id)
- {
- _drag_out_delta_x = CLAMP(_drag_out_delta_x + data->delta_x, 0.0f, DRAG_OUT_PIXELS);
- EnsureAnimation();
- }
+ _drag_out_delta_x =
+ CLAMP(_drag_out_delta_x + event.GetDelta().x, 0.0f, DRAG_OUT_PIXELS);
+ EnsureAnimation();
}
-void Launcher::OnDragFinish(GeisAdapter::GeisDragData* data)
+void
+Launcher::OnDragFinish(const nux::GestureEvent &event)
{
- if (data->id == _drag_out_id)
- {
- if (_drag_out_delta_x >= DRAG_OUT_PIXELS - 90.0f)
- _hide_machine.SetQuirk(LauncherHideMachine::MT_DRAG_OUT, true);
- TimeUtil::SetTimeStruct(&_times[TIME_DRAG_OUT], &_times[TIME_DRAG_OUT], ANIM_DURATION_SHORT);
- _drag_out_id = 0;
- EnsureAnimation();
- }
+ if (_drag_out_delta_x >= DRAG_OUT_PIXELS - 90.0f)
+ _hide_machine.SetQuirk(LauncherHideMachine::MT_DRAG_OUT, true);
+ TimeUtil::SetTimeStruct(&_times[TIME_DRAG_OUT],
+ &_times[TIME_DRAG_OUT],
+ ANIM_DURATION_SHORT);
+ EnsureAnimation();
+ _drag_gesture_ongoing = false;
}
void Launcher::AddProperties(GVariantBuilder* builder)
@@ -341,9 +331,11 @@ float Launcher::DragOutProgress(struct timespec const& current) const
float timeout = CLAMP((float)(unity::TimeUtil::TimeDelta(&current, &_times[TIME_DRAG_OUT])) / (float) ANIM_DURATION_SHORT, 0.0f, 1.0f);
float progress = CLAMP(_drag_out_delta_x / DRAG_OUT_PIXELS, 0.0f, 1.0f);
- if (_drag_out_id || _hide_machine.GetQuirk(LauncherHideMachine::MT_DRAG_OUT))
+ if (_drag_gesture_ongoing
+ || _hide_machine.GetQuirk(LauncherHideMachine::MT_DRAG_OUT))
return progress;
- return progress * (1.0f - timeout);
+ else
+ return progress * (1.0f - timeout);
}
float Launcher::AutohideProgress(struct timespec const& current) const
@@ -2505,7 +2497,26 @@ void Launcher::RenderIconToTexture(nux::GraphicsEngine& GfxContext, AbstractLaun
RestoreSystemRenderTarget();
}
-void Launcher::SetOffscreenRenderTarget(nux::ObjectPtr<nux::IOpenGLBaseTexture> texture)
+nux::GestureDeliveryRequest Launcher::GestureEvent(const nux::GestureEvent &event)
+{
+ switch(event.type)
+ {
+ case nux::EVENT_GESTURE_BEGIN:
+ OnDragStart(event);
+ break;
+ case nux::EVENT_GESTURE_UPDATE:
+ OnDragUpdate(event);
+ break;
+ default: // EVENT_GESTURE_END
+ OnDragFinish(event);
+ break;
+ }
+
+ return nux::GestureDeliveryRequest::NONE;
+}
+
+void
+Launcher::SetOffscreenRenderTarget(nux::ObjectPtr<nux::IOpenGLBaseTexture> texture)
{
int width = texture->GetWidth();
int height = texture->GetHeight();
diff --git a/launcher/Launcher.h b/launcher/Launcher.h
index 3c1c010d4..a41dfff71 100644
--- a/launcher/Launcher.h
+++ b/launcher/Launcher.h
@@ -32,7 +32,6 @@
#include "DNDCollectionWindow.h"
#include "DndData.h"
#include "EdgeBarrierController.h"
-#include "GeisAdapter.h"
#include "unity-shared/Introspectable.h"
#include "LauncherModel.h"
#include "LauncherOptions.h"
@@ -136,6 +135,7 @@ public:
void RenderIconToTexture(nux::GraphicsEngine& GfxContext, AbstractLauncherIcon::Ptr icon, nux::ObjectPtr<nux::IOpenGLBaseTexture> texture);
+ virtual nux::GestureDeliveryRequest GestureEvent(const nux::GestureEvent &event);
protected:
// Introspectable methods
std::string GetName() const;
@@ -183,9 +183,9 @@ private:
void OnWindowMapped(guint32 xid);
void OnWindowUnmapped(guint32 xid);
- void OnDragStart(GeisAdapter::GeisDragData* data);
- void OnDragUpdate(GeisAdapter::GeisDragData* data);
- void OnDragFinish(GeisAdapter::GeisDragData* data);
+ void OnDragStart(const nux::GestureEvent &event);
+ void OnDragUpdate(const nux::GestureEvent &event);
+ void OnDragFinish(const nux::GestureEvent &event);
bool HandleBarrierEvent(ui::PointerBarrierWrapper* owner, ui::BarrierEvent::Ptr event);
@@ -362,8 +362,8 @@ private:
int _launcher_drag_delta_min;
int _enter_y;
int _last_button_press;
- int _drag_out_id;
float _drag_out_delta_x;
+ bool _drag_gesture_ongoing;
float _last_reveal_progress;
nux::Point2 _mouse_position;
diff --git a/launcher/StandaloneLauncher.cpp b/launcher/StandaloneLauncher.cpp
index a3e7a7752..8dba0e4f7 100644
--- a/launcher/StandaloneLauncher.cpp
+++ b/launcher/StandaloneLauncher.cpp
@@ -59,7 +59,6 @@ int main(int argc, char** argv)
nux::NuxInitialize(0);
- GeisAdapter geis_adapter;
unity::Settings settings;
panel::Style panel_style;
internal::FavoriteStoreGSettings favorite_store;