libgrip-0.3.9+15.10.20150729/0000755000015300001610000000000012556203774015525 5ustar pbuserpbgroup00000000000000libgrip-0.3.9+15.10.20150729/COPYING.LGPL.2.10000644000015300001610000006363712556203475017631 0ustar pbuserpbgroup00000000000000 GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Libraries If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker. , 1 April 1990 Ty Coon, President of Vice That's all there is to it! libgrip-0.3.9+15.10.20150729/examples/0000755000015300001610000000000012556203774017343 5ustar pbuserpbgroup00000000000000libgrip-0.3.9+15.10.20150729/examples/rectangle-mover/0000755000015300001610000000000012556203774022435 5ustar pbuserpbgroup00000000000000libgrip-0.3.9+15.10.20150729/examples/rectangle-mover/gesture.c0000644000015300001610000001730312556203475024261 0ustar pbuserpbgroup00000000000000#include #include #include #include #include "gripgesturemanager.h" static gint rotate = 0; static gdouble scale = 1.0; static gdouble translate[2] = { 200, 200 }; static gint in_touch = 0; static void subscribe_gestures(GripGestureManager *manager, GtkWidget *window, GtkWidget *da); struct app_data { GripGestureManager *manager; GtkWidget *main_window; GtkWidget *da; }; static gboolean draw_canvas (GtkWidget *widget, cairo_t *cr, gpointer data) { gdouble radians; gint width = (in_touch > 0) ? 10 : 1; cairo_set_source_rgb (cr, 0, 0, 0); cairo_set_line_width (cr, width); radians = rotate * (G_PI / 180); cairo_translate (cr, translate[0], translate[1]); cairo_scale (cr, scale, scale); cairo_rotate (cr, radians); cairo_rectangle (cr, -50, -50, 100, 100); cairo_stroke_preserve (cr); cairo_set_source_rgb (cr, 1, 0, 1); cairo_fill (cr); return FALSE; } static void gesture_callback (GtkWidget *widget, GripTimeType time_type, GripGestureEvent *event, gpointer user_data) { if (time_type == GRIP_TIME_START) { in_touch++; } else if (time_type == GRIP_TIME_END) { in_touch--; } else { switch (event->type) { case GRIP_GESTURE_DRAG: { GripEventGestureDrag *e = (GripEventGestureDrag *)event; translate[0] += e->delta_x; translate[1] += e->delta_y; } break; case GRIP_GESTURE_PINCH: { GripEventGesturePinch *e = (GripEventGesturePinch *)event; GtkWindow *toplevel = (GtkWindow *)gtk_widget_get_toplevel (widget); gint window_width, window_height; const GripAxisExtents *x; const GripAxisExtents *y; gfloat width = 0; gfloat height = 0; gfloat factor = 0; gtk_window_get_size (toplevel, &window_width, &window_height); x = grip_input_device_get_x_extents (e->input_device); y = grip_input_device_get_y_extents (e->input_device); width = window_width / (x->maximum - x->minimum); height = window_height / (y->maximum - y->minimum); factor = sqrtf (width * width + height * height) / 5.2723; scale += e->radius_delta * factor; } break; case GRIP_GESTURE_ROTATE: { GripEventGestureRotate *e = (GripEventGestureRotate *)event; rotate += e->angle_delta * 100; } break; case GRIP_GESTURE_TAP: break; } } gtk_widget_queue_draw (GTK_WIDGET (widget)); } static void subscribe_toggled(GtkToggleButton *toggle_button, gpointer user_data) { struct app_data *app = (struct app_data*)(user_data); if (gtk_toggle_button_get_active(toggle_button)) { subscribe_gestures(app->manager, app->main_window, app->da); } else { grip_gesture_manager_unregister_window(app->manager, app->main_window); } } static GtkTreeModel * create_model () { return (GtkTreeModel *)gtk_list_store_new (1, G_TYPE_STRING); } /* Change this to suit your needs. */ #define DEVICE_TYPE GRIP_DEVICE_ALL static void subscribe_gestures(GripGestureManager *manager, GtkWidget *window, GtkWidget *da) { grip_gesture_manager_register_window (manager, da, GRIP_GESTURE_PINCH, DEVICE_TYPE, 2, gesture_callback, NULL, NULL); grip_gesture_manager_register_window (manager, da, GRIP_GESTURE_ROTATE, DEVICE_TYPE, 2, gesture_callback, NULL, NULL); grip_gesture_manager_register_window (manager, da, GRIP_GESTURE_DRAG, DEVICE_TYPE, 2, gesture_callback, NULL, NULL); grip_gesture_manager_register_window (manager, da, GRIP_GESTURE_TAP, DEVICE_TYPE, 2, gesture_callback, NULL, NULL); } static GtkWidget * create_window (struct app_data *app) { app->main_window = gtk_window_new (GTK_WINDOW_TOPLEVEL); GtkWidget *window = app->main_window; GtkWidget *hbox; GtkWidget *vbox; GtkWidget *button; GtkWidget *subscribed_toggle; GtkWidget *tv; GtkTreeModel *model; GtkWidget *sw; GtkCssProvider *style; GtkStyleContext *style_ctx; app->da = gtk_drawing_area_new (); gtk_window_set_title (GTK_WINDOW (window), "Touch Demo"); gtk_window_set_default_size (GTK_WINDOW (window), 600, 600); g_signal_connect (window, "destroy", G_CALLBACK (gtk_widget_destroyed), &window); g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL); hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (hbox), app->da, TRUE, TRUE, 0); model = create_model (); sw = gtk_scrolled_window_new (NULL, NULL); tv = gtk_tree_view_new_with_model (model); g_object_unref (model); gtk_container_add (GTK_CONTAINER (sw), tv); gtk_box_pack_start (GTK_BOX (vbox), sw, TRUE, TRUE, 0); button = gtk_button_new_with_label ("Quit"); g_signal_connect (button, "clicked", G_CALLBACK (gtk_main_quit), NULL); subscribed_toggle = gtk_toggle_button_new_with_label ("Gestures"); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(subscribed_toggle), TRUE); g_signal_connect (subscribed_toggle, "toggled", G_CALLBACK (subscribe_toggled), app); gtk_box_pack_start (GTK_BOX (vbox), subscribed_toggle, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); gtk_container_add (GTK_CONTAINER (window), hbox); style = gtk_css_provider_new(); style_ctx = gtk_widget_get_style_context(GTK_WIDGET(app->da)); gtk_css_provider_load_from_data(style, "* { background-color: #ffffff; }", -1, NULL); gtk_style_context_add_provider(style_ctx, GTK_STYLE_PROVIDER (style), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); g_signal_connect (app->da, "draw", G_CALLBACK (draw_canvas), NULL); subscribe_gestures(app->manager, window, app->da); g_object_unref(style); return window; } static void abort_handler (int x) { g_print (" **** ABORT ****\n"); exit (1); } int main (int argc, char **argv) { struct app_data app; gtk_init (&argc, &argv); /* Don't crash X if we're using some shitty Intel graphics like * my Dell XT2 has in it. */ signal (SIGABRT, abort_handler); app.manager = grip_gesture_manager_get (); create_window (&app); g_signal_connect (app.main_window, "destroy", G_CALLBACK (gtk_main_quit), NULL); gtk_widget_show_all (GTK_WIDGET (app.main_window)); gtk_main (); return 0; } libgrip-0.3.9+15.10.20150729/examples/rectangle-mover/Makefile.am0000644000015300001610000000043312556203475024467 0ustar pbuserpbgroup00000000000000noinst_PROGRAMS = \ grip-test grip_test_SOURCES = \ gesture.c grip_test_CPPFLAGS = \ -I$(top_srcdir) \ -I$(top_srcdir)/src \ -I$(top_builddir)/src \ $(GCC_FLAGS) \ $(GTK_CFLAGS) \ $(MAINTAINER_CFLAGS) grip_test_LDADD = $(top_builddir)/src/libgrip.la $(GTK_LIBS) -lm libgrip-0.3.9+15.10.20150729/examples/pygrip/0000755000015300001610000000000012556203774020655 5ustar pbuserpbgroup00000000000000libgrip-0.3.9+15.10.20150729/examples/pygrip/pygrip-gestures.xml0000644000015300001610000000101212556203475024540 0ustar pbuserpbgroup00000000000000 0 0 800 600 libgrip-0.3.9+15.10.20150729/examples/pygrip/pygrip.py0000755000015300001610000000242612556203475022546 0ustar pbuserpbgroup00000000000000#!/usr/bin/python from gi.repository import Gtk Gtk.require_version('2.0') from gi.repository import Grip # XXX For now, we'll use Grip directly. Once we have a good sense of what's # going to be needed in general for general Python code using Grip, we might # want to put that stuff in a wrapper grip module, and import everything from # there instead. class GestureTester(object): def __init__(self): builder = Gtk.Builder() builder.add_from_file("pygrip-gestures.xml") builder.connect_signals(self) self.window = builder.get_object("window1") self.gesture_manager = Grip.GestureManager() self.window.show() def window_mapped(self, widget, data=None): # The gesture manager is only going to be needed for GTK2, since GTK3 # will have the gesture API natively. Conversely, pygrip will only be # for GTK2, since PyGTK3 will having the bindings. finger_count = 2 self.gesture_manager.register_window(widget, Grip.GestureType.PINCH, finger_count, self.callback, None) def callback(self, window, time_type, gesture_event, data): print "received gesture" def quit(self, widget, data=None): Gtk.main_quit() if __name__ == "__main__": app = GestureTester() Gtk.main() libgrip-0.3.9+15.10.20150729/configure.ac0000644000015300001610000001013412556203475020010 0ustar pbuserpbgroup00000000000000# # shamelessly stolen from clutter-gtk # m4_define([grip_major_version], [0]) m4_define([grip_minor_version], [3]) m4_define([grip_micro_version], [9]) m4_define([grip_api_version], [grip_major_version.grip_minor_version]) m4_define([grip_version], [grip_major_version.grip_minor_version.grip_micro_version]) m4_define([grip_interface_age], [0]) m4_define([grip_binary_age], [m4_eval(100 * grip_minor_version + grip_micro_version)]) AC_PREREQ(2.59) AC_INIT([grip], [grip_version], [https://bugs.launchpad.net/libgrip]) AC_CONFIG_SRCDIR([src/grip.h]) AC_CONFIG_MACRO_DIR([m4]) AM_CONFIG_HEADER([config.h]) AM_INIT_AUTOMAKE([1.11 silent-rules]) AM_SILENT_RULES([yes]) AM_MAINTAINER_MODE AM_PATH_PYTHON AC_ARG_WITH([pygi_overrides_dir], AC_HELP_STRING([--with-pygi-overrides-dir], [Path to pygobject overrides directory])) AC_MSG_CHECKING(for pygobject overrides directory) if test "x$with_pygi_overrides_dir" = "x" ; then overrides_dir="`$PYTHON -c 'import gi; print(gi._overridesdir)' 2>/dev/null`" # fallback if the previous failed if test "x$overrides_dir" = "x" ; then overrides_dir="${pyexecdir}/gi/overrides" fi else overrides_dir="$with_pygi_overrides_dir" fi PYGI_OVERRIDES_DIR="$overrides_dir" AC_SUBST(PYGI_OVERRIDES_DIR) AC_MSG_RESULT($PYGI_OVERRIDES_DIR) GRIP_MAJOR_VERSION=grip_major_version GRIP_MINOR_VERSION=grip_minor_version GRIP_MICRO_VERSION=grip_micro_version GRIP_VERSION=grip_version AC_SUBST(GRIP_MAJOR_VERSION) AC_SUBST(GRIP_MINOR_VERSION) AC_SUBST(GRIP_MICRO_VERSION) AC_SUBST(GRIP_VERSION) m4_define([lt_current], [m4_eval(100 * grip_minor_version + grip_micro_version - grip_interface_age)]) m4_define([lt_revision], [grip_interface_age]) m4_define([lt_age], [m4_eval(grip_binary_age - grip_interface_age)]) GRIP_LT_CURRENT=lt_current GRIP_LT_REV=lt_revision GRIP_LT_AGE=lt_age GRIP_LT_VERSION="$GRIP_LT_CURRENT:$GRIP_LT_REV:$GRIP_LT_AGE" GRIP_LT_LDFLAGS="-version-info $GRIP_LT_VERSION" AC_SUBST(GRIP_LT_VERSION) AC_SUBST(GRIP_LT_LDFLAGS) dnl =========================================================================== # Checks for programs AC_PROG_CC AC_DISABLE_STATIC AC_PROG_LIBTOOL AC_PATH_PROG([GLIB_MKENUMS], [glib-mkenums]) # Checks for header files AC_HEADER_STDC AC_CHECK_HEADERS([fcntl.h stdlib.h string.h unistd.h]) # Checks for typedefs, structures and compiler charecteristics AC_C_CONST # Checks for library functions AC_FUNC_MALLOC AC_FUNC_MMAP AC_CHECK_FUNCS([memset munmap strcasecmp strdup]) PKG_CHECK_MODULES(GTK, gtk+-3.0 >= 3.0.8) AC_SUBST(GTK_CFLAGS) AC_SUBST(GTK_LIBS) PKG_CHECK_MODULES(GEIS, libgeis >= 2.1.1) AC_SUBST(GEIS_CFLAGS) AC_SUBST(GEIS_LIBS) GOBJECT_INTROSPECTION_CHECK([0.6.7]) dnl =========================================================================== if test "x$GCC" = "xyes"; then GCC_FLAGS="-g -Wall" fi AC_SUBST(GCC_FLAGS) # use strict compiler flags only on development releases m4_define([maintainer_flags_default], [m4_if(m4_eval(grip_minor_version % 2), [1], [yes], [no])]) AC_ARG_ENABLE([maintainer-flags], [AC_HELP_STRING([--enable-maintainer-flags=@<:@no/yes@:>@], [Use strict compiler flags @<:@default=no@:>@])], [], [enable_maintainer_flags=maintainer_flags_default]) MAINTAINER_CFLAGS="" AS_IF([test "x$enable_maintainer_flags" = "xyes" && test "x$GCC" = "xyes"], [ MAINTAINER_CFLAGS="-Werror -Wall -Wshadow -Wcast-align -Wno-uninitialized -Wempty-body -Wformat-security -Winit-self" ] ) AC_SUBST(MAINTAINER_CFLAGS) dnl = GTK Doc Check =========================================================== GTK_DOC_CHECK([1.8]) dnl =========================================================================== AC_CONFIG_FILES([ Makefile src/Makefile bindings/python/Makefile bindings/Makefile examples/rectangle-mover/Makefile libgrip.pc doc/Makefile doc/reference/Makefile doc/reference/libgrip-docs.sgml ]) AC_OUTPUT echo "" echo " grip $VERSION" echo " ===============================" echo "" echo " Prefix : ${prefix}" echo "" echo " Documentation: ${enable_gtk_doc}" echo "" libgrip-0.3.9+15.10.20150729/AUTHORS0000644000015300001610000000003012556203475016564 0ustar pbuserpbgroup00000000000000# Generated by Makefile libgrip-0.3.9+15.10.20150729/libgrip.pc.in0000644000015300001610000000034012556203475020101 0ustar pbuserpbgroup00000000000000prefix=@prefix@ exec_prefix=@exec_prefix@ libdir=@libdir@ includedir=@includedir@ Name: libgrip Description: Multitouch gesture library Version: @VERSION@ Libs: -L${libdir} -lgrip Cflags: -I${includedir} Requires: gtk+-3.0 libgrip-0.3.9+15.10.20150729/src/0000755000015300001610000000000012556203774016314 5ustar pbuserpbgroup00000000000000libgrip-0.3.9+15.10.20150729/src/grip.h0000644000015300001610000000207612556203475017431 0ustar pbuserpbgroup00000000000000/* * Copyright 2010 Canonical, Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of either or both of the following licenses: * * 1) the GNU Lesser General Public License version 3, as published by the * Free Software Foundation; and/or * 2) the GNU Lesser General Public License version 2.1, 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 warranties of * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR * PURPOSE. See the applicable version of the GNU Lesser General Public * License for more details. * * You should have received a copy of both the GNU Lesser General Public * License version 3 and version 2.1 along with this program. If not, see * * * Authors: * Cody Russell */ #ifndef GRIP_H #define GRIP_H #include #include #endif /* GRIP_H */ libgrip-0.3.9+15.10.20150729/src/libgrip.ver0000644000015300001610000000320512556203475020460 0ustar pbuserpbgroup00000000000000# Linker script for libgrip symbol versioning. # # Copyright (c) 2011 Canonical Ltd. # # This program is free software: you can redistribute it and/or modify it # under the terms of either or both of the following licenses: # # 1) the GNU Lesser General Public License version 3, as published by the # Free Software Foundation; and/or # 2) the GNU Lesser General Public License version 2.1, 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 warranties of # MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR # PURPOSE. See the applicable version of the GNU Lesser General Public # License for more details. # # You should have received a copy of both the GNU Lesser General Public # License version 3 and version 2.1 along with this program. If not, see # # GRIP_0.1 { global: grip_gesture_event_copy; grip_gesture_event_free; grip_gesture_event_get_type; grip_gesture_event_new; grip_gesture_manager_get; grip_gesture_manager_get_type; grip_gesture_manager_register_window; grip_gesture_type_get_type; grip_time_type_get_type; local: *; }; GRIP_0.2 { global: grip_gesture_manager_unregister_window; } GRIP_0.1; GRIP_0.2.2 { global: grip_input_device_get_id; grip_input_device_get_name; grip_input_device_get_type; grip_input_device_get_x_extents; grip_input_device_get_y_extents; grip_input_device_is_direct; grip_input_device_is_independent; } GRIP_0.1; GRIP_0.3 { global: grip_get_device_type; } GRIP_0.2.2; libgrip-0.3.9+15.10.20150729/src/griptypebuiltins.c.in0000644000015300001610000000135712556203475022506 0ustar pbuserpbgroup00000000000000/*** BEGIN file-header ***/ #include "griptypebuiltins.h" /*** END file-header ***/ /*** BEGIN file-production ***/ /* enumerations from "@filename@" */ #include "@filename@" /*** END file-production ***/ /*** BEGIN value-header ***/ GType @enum_name@_get_type(void) { static GType enum_type_id = 0; if (G_UNLIKELY (!enum_type_id)) { static const G@Type@Value values[] = { /*** END value-header ***/ /*** BEGIN value-production ***/ { @VALUENAME@, "@VALUENAME@", "@valuenick@" }, /*** END value-production ***/ /*** BEGIN value-tail ***/ { 0, NULL, NULL } }; enum_type_id = g_@type@_register_static (g_intern_static_string ("@EnumName@"), values); } return enum_type_id; } /*** END value-tail ***/ libgrip-0.3.9+15.10.20150729/src/gripinputdevice.h0000644000015300001610000000706012556203475021667 0ustar pbuserpbgroup00000000000000/* * Copyright 2011 Canonical, Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of either or both of the following licenses: * * 1) the GNU Lesser General Public License version 3, as published by the * Free Software Foundation; and/or * 2) the GNU Lesser General Public License version 2.1, 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 warranties of * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR * PURPOSE. See the applicable version of the GNU Lesser General Public * License for more details. * * You should have received a copy of both the GNU Lesser General Public * License version 3 and version 2.1 along with this program. If not, see * */ #ifndef GRIP_INPUT_DEVICE_H_ #define GRIP_INPUT_DEVICE_H_ #include G_BEGIN_DECLS /** * GripDeviceType: * @GRIP_DEVICE_TOUCHSCREEN: device is a touchscreen. * @GRIP_DEVICE_TOUCHPAD: device is a touchpad * @GRIP_DEVICE_INDEPENDENT: device is a Magic Mouse * * Describes certain properties of a gesture input device. */ typedef enum { GRIP_DEVICE_TOUCHSCREEN = 1, GRIP_DEVICE_TOUCHPAD = 2, GRIP_DEVICE_INDEPENDENT = 4, } GripDeviceType; /** * SECTION:GripInputDevice * * The Grip input device represents input devices known to the gesture * recognition stack. */ typedef struct GripAxisExtents { gfloat minimum; gfloat maximum; gfloat resolution; } GripAxisExtents; #ifndef G_IR_IGNORE /** * AxisExtents: (skip) * * A deprecated name for GripAxisExtents. */ typedef GripAxisExtents AxisExtents __attribute__((deprecated)); #endif GType grip_input_device_get_type (void) G_GNUC_CONST; #define GRIP_TYPE_INPUT_DEVICE \ (grip_input_device_get_type ()) #define GRIP_INPUT_DEVICE(obj) \ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ GRIP_TYPE_INPUT_DEVICE, \ GripInputDevice)) #define GRIP_INPUT_DEVICE_CLASS(obj) \ (G_TYPE_CHECK_CLASS_CAST ((obj), \ GRIP_TYPE_INPUT_DEVICE, \ GripInputDeviceClass)) #define GRIP_IS_INPUT_DEVICE(obj) \ (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \ GRIP_TYPE_INPUT_DEVICE)) #define GRIP_IS_INPUT_DEVICE_CLASS(obj) \ (G_TYPE_CHECK_CLASS_TYPE ((obj), \ GRIP_TYPE_INPUT_DEVICE)) #define GRIP_INPUT_DEVICE_GET_CLASS(obj) \ (G_TYPE_INSTANCE_GET_CLASS ((obj), \ GRIP_TYPE_INPUT_DEVICE, \ GripInputDeviceClass)) typedef struct GripInputDevicePrivate GripInputDevicePrivate; /** * GripInputDevice: * * This struct contains private data only, and should be accessed using the * functions below. */ typedef struct { GObject parent; GripInputDevicePrivate *priv; } GripInputDevice; typedef struct { GObjectClass parent_class; } GripInputDeviceClass; guint grip_input_device_get_id(GripInputDevice *input_device); const gchar * grip_input_device_get_name(GripInputDevice *input_device); gboolean grip_input_device_is_direct(GripInputDevice *input_device); gboolean grip_input_device_is_independent(GripInputDevice *input_device); const GripAxisExtents * grip_input_device_get_x_extents(GripInputDevice *input_device); const GripAxisExtents * grip_input_device_get_y_extents(GripInputDevice *input_device); GripDeviceType grip_get_device_type (GripInputDevice *input_device); G_END_DECLS #endif /* GRIP_INPUT_DEVICE_H_ */ libgrip-0.3.9+15.10.20150729/src/gripgesturemanager.c0000644000015300001610000011777512556203503022363 0ustar pbuserpbgroup00000000000000/* * Copyright 2010, 2011, 2013 Canonical, Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of either or both of the following licenses: * * 1) the GNU Lesser General Public License version 3, as published by the * Free Software Foundation; and/or * 2) the GNU Lesser General Public License version 2.1, 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 warranties of * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR * PURPOSE. See the applicable version of the GNU Lesser General Public * License for more details. * * You should have received a copy of both the GNU Lesser General Public * License version 3 and version 2.1 along with this program. If not, see * * * Authors: * Cody Russell */ #include "gripgesturemanager.h" #include #include #include "gripinputdevice.h" typedef struct _GripGestureBinding GripGestureBinding; typedef struct _GripRegistrationRequest GripRegistrationRequest; typedef GPtrArray GripDevices; /* * GripGestureClassMap: * @grip_type: the libgrip gesture type * @geis_class: the geis gesture class * * Provides a mapping between a grip gesture type and a geis gesture class. */ typedef struct _GripGestureClassMap { GripGestureType grip_type; GeisGestureClass geis_class; } GripGestureClassMap; /* * GripGestureManagerPrivate: * @geis: the GEIS instance * @is_initialized: GEIS async initialization has been successfully completed * @iochannel: connects the geis object with the main loop * @iochannel_id: the identifier for the iochannel * @devices: a collection of recognized input devices * @classes: a list of grip type to geis class mappings * @requests: a list of pending binding requests * @bindings: a list of current gesture bindings */ struct _GripGestureManagerPrivate { Geis geis; gboolean is_initialized; GIOChannel *iochannel; int iochannel_id; GripDevices *devices; GList *classes; GList *requests; GList *bindings; }; G_DEFINE_TYPE (GripGestureManager, grip_gesture_manager, G_TYPE_OBJECT) #define GRIP_GESTURE_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GRIP_TYPE_GESTURE_MANAGER, GripGestureManagerPrivate)) /* * GripGestureBinding: * @type: * @widget: * @touches: * @callback: * @data: * @destroy: * * The mapping between a GEIS subscription and a GTK widget. Sort of. */ struct _GripGestureBinding { GripGestureType type; GtkWidget *widget; guint touches; GeisSubscription subscription; GripGestureCallback callback; gpointer data; GDestroyNotify destroy; }; /* * GripRegistrationRequest: * @manager: the @GripGestureManager * @widget: the GtkWidget to be bound * @gesture_type: the type of gesture to subscribe for * @device_type: the type of input device to subscribe for * @touch_points: the number of touches making the gesture * @callback: the callback to be invoked on gesture events * @user_data: the callback context to be passed back on gesture events * @destroy: function to destroy the callback context (NULL for no function) * * A collection of information required to register a callback for a * particulatr type of gestures on a window. */ struct _GripRegistrationRequest { GripGestureManager *manager; GtkWidget *widget; GripGestureType gesture_type; GripDeviceType device_type; gint touch_points; GripGestureCallback callback; gpointer user_data; GDestroyNotify destroy; }; enum { DEVICE_AVAILABLE, DEVICE_UNAVAILABLE, SIGNAL_LAST }; static guint signals[SIGNAL_LAST]; static void process_gesture_events (GripGestureManager *manager, GeisEvent geis_event); static void toplevel_mapped_cb (GtkWidget *toplevel, GdkEvent *event, gpointer user_data); static void grip_geis_device_added(GripGestureManager *manager G_GNUC_UNUSED, GeisEvent geis_event) { GeisAttr attr = geis_event_attr_by_name(geis_event, GEIS_EVENT_ATTRIBUTE_DEVICE); g_return_if_fail (attr); GeisDevice device = geis_attr_value_to_pointer(attr); g_return_if_fail (device); switch (geis_event_type(geis_event)) { case GEIS_EVENT_DEVICE_AVAILABLE: { GripInputDevice *input_device = g_object_new (GRIP_TYPE_INPUT_DEVICE, "geis-device", device, NULL); g_ptr_array_add(manager->priv->devices, input_device); g_signal_emit (manager, signals[DEVICE_AVAILABLE], 0, input_device); } break; case GEIS_EVENT_DEVICE_UNAVAILABLE: { guint device_id = geis_device_id (device); GripDevices *devices = manager->priv->devices; guint i; for (i = 0; i < devices->len; ++i) { GripInputDevice *input_device = g_ptr_array_index (devices, i); if (device_id == grip_input_device_get_id (input_device)) { g_signal_emit (manager, signals[DEVICE_UNAVAILABLE], 0, input_device); g_ptr_array_remove_index (devices, i); break; } } } break; default: break; } } static void process_class_event(GripGestureManagerPrivate *priv G_GNUC_UNUSED, GeisEvent geis_event) { GeisAttr attr = geis_event_attr_by_name (geis_event, GEIS_EVENT_ATTRIBUTE_CLASS); g_return_if_fail (attr); GeisGestureClass gesture_class = geis_attr_value_to_pointer (attr); g_return_if_fail (gesture_class); switch (geis_event_type (geis_event)) { case GEIS_EVENT_CLASS_AVAILABLE: { gchar const *class_name = geis_gesture_class_name (gesture_class); /* check for dups */ GList *l; for (l = priv->classes; l != NULL; l = l->next) { GripGestureClassMap *p = (GripGestureClassMap *)l->data; if (0 == g_strcmp0 (geis_gesture_class_name (p->geis_class), class_name)) { g_warning ("multiple class definitions for '%s' received", class_name); return; } } GripGestureClassMap *m = g_new0 (GripGestureClassMap, 1); if (0 == g_strcmp0 (class_name, "Drag")) m->grip_type = GRIP_GESTURE_DRAG; else if (0 == g_strcmp0 (class_name, "Pinch")) m->grip_type = GRIP_GESTURE_PINCH; else if (0 == g_strcmp0 (class_name, "Rotate")) m->grip_type = GRIP_GESTURE_ROTATE; else if (0 == g_strcmp0 (class_name, "Tap")) m->grip_type = GRIP_GESTURE_TAP; else m->grip_type = (GripGestureType)100; m->geis_class = gesture_class; priv->classes = g_list_append (priv->classes, m); } break; default: /* @todo handle class-changed and class-unavailable events */ g_warning ("gesture class event ignored"); break; } } static void grip_geis_event_callback(Geis geis G_GNUC_UNUSED, GeisEvent geis_event, void *context) { GripGestureManager *self = GRIP_GESTURE_MANAGER (context); GripGestureManagerPrivate *priv = GRIP_GESTURE_MANAGER_GET_PRIVATE (self); switch (geis_event_type(geis_event)) { case GEIS_EVENT_DEVICE_AVAILABLE: case GEIS_EVENT_DEVICE_UNAVAILABLE: grip_geis_device_added (self, geis_event); break; case GEIS_EVENT_CLASS_AVAILABLE: case GEIS_EVENT_CLASS_CHANGED: case GEIS_EVENT_CLASS_UNAVAILABLE: process_class_event(priv, geis_event); break; case GEIS_EVENT_INIT_COMPLETE: priv->is_initialized = TRUE; break; case GEIS_EVENT_GESTURE_BEGIN: case GEIS_EVENT_GESTURE_UPDATE: case GEIS_EVENT_GESTURE_END: process_gesture_events(self, geis_event); break; default: g_warning ("event ignored"); break; } geis_event_delete(geis_event); return; } static void grip_gesture_manager_dispose (GObject *object G_GNUC_UNUSED) { } static void grip_gesture_manager_finalize (GObject *object) { GripGestureManagerPrivate *priv = GRIP_GESTURE_MANAGER_GET_PRIVATE (object); g_list_foreach(priv->classes, (GFunc) g_free, NULL); g_list_free(priv->classes); g_ptr_array_foreach (priv->devices, (GFunc) g_object_unref, NULL); g_ptr_array_unref (priv->devices); } static GObject * grip_gesture_manager_constructor (GType type, guint n_params, GObjectConstructParam *params) { static GObject *self = NULL; if (self == NULL) { self = G_OBJECT_CLASS (grip_gesture_manager_parent_class)-> constructor (type, n_params, params); g_object_add_weak_pointer (self, (gpointer) &self); } return g_object_ref (self); } static void grip_gesture_manager_class_init (GripGestureManagerClass *class) { GObjectClass *gobject_class; gobject_class = G_OBJECT_CLASS (class); grip_gesture_manager_parent_class = g_type_class_peek_parent (class); g_type_class_add_private (gobject_class, sizeof (GripGestureManagerPrivate)); gobject_class->constructor = grip_gesture_manager_constructor; gobject_class->dispose = grip_gesture_manager_dispose; gobject_class->finalize = grip_gesture_manager_finalize; /** * GripGestureManager::device-available: * @gesture_manager: the #GripGestureManager sending the signal * @input_device: the new #GripInputDevice just added. * * Signals the availability of a new gesture-capable input device. */ signals[DEVICE_AVAILABLE] = g_signal_new ("device-available", GRIP_TYPE_GESTURE_MANAGER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, GRIP_TYPE_INPUT_DEVICE); /** * GripGestureManager::device-unavailable: * @gesture_manager: the #GripGestureManager sending the signal * @input_device: the new #GripInputDevice just added. * * Signals the unavailability of a gesture-capable input device. */ signals[DEVICE_UNAVAILABLE] = g_signal_new ("device-unavailable", GRIP_TYPE_GESTURE_MANAGER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, GRIP_TYPE_INPUT_DEVICE); } /* * device_id_to_input_device: * @gesture_manager: the #GripGestureManager * @device_id: the device ID * * Finds a known #GripInputDevice given a GEIS device identifier. * * Returns: a pointer to a #GripInputDevice or %NULL if not found. */ static GripInputDevice * device_id_to_input_device (GripGestureManager *gesture_manager, GeisInputDeviceId device_id) { guint j; GripInputDevice *input_device = NULL; for (j = 0; j < gesture_manager->priv->devices->len; ++j) { GripInputDevice *device; device = g_ptr_array_index (gesture_manager->priv->devices, j); if (grip_input_device_get_id (device) == device_id) { input_device = device; break; } } return input_device; } static gint pinch_gesture_handle_properties (GripEventGesturePinch *event, GeisFrame frame) { guint attr_count = geis_frame_attr_count (frame); gint num_touches = 0; guint i; for (i = 0; i < attr_count; ++i) { GeisAttr attr = geis_frame_attr(frame, i); GeisString attr_name = geis_attr_name(attr); if (g_strcmp0 (attr_name, GEIS_GESTURE_ATTRIBUTE_TOUCHES) == 0) num_touches = geis_attr_value_to_integer(attr); if (g_strcmp0 (attr_name, GEIS_GESTURE_ATTRIBUTE_TIMESTAMP) == 0) event->timestamp = geis_attr_value_to_integer(attr); else if (g_strcmp0 (attr_name, GEIS_GESTURE_ATTRIBUTE_FOCUS_X) == 0) event->focus_x = geis_attr_value_to_float(attr); else if (g_strcmp0 (attr_name, GEIS_GESTURE_ATTRIBUTE_FOCUS_Y) == 0) event->focus_y = geis_attr_value_to_float(attr); else if (g_strcmp0 (attr_name, GEIS_GESTURE_ATTRIBUTE_RADIUS_DELTA) == 0) event->radius_delta = geis_attr_value_to_float(attr); else if (g_strcmp0 (attr_name, GEIS_GESTURE_ATTRIBUTE_RADIAL_VELOCITY) == 0) event->radial_velocity = geis_attr_value_to_float(attr); else if (g_strcmp0 (attr_name, GEIS_GESTURE_ATTRIBUTE_RADIUS) == 0) event->radius = geis_attr_value_to_float(attr); else if (g_strcmp0 (attr_name, GEIS_GESTURE_ATTRIBUTE_POSITION_X) == 0) event->position_x = geis_attr_value_to_float(attr); else if (g_strcmp0 (attr_name, GEIS_GESTURE_ATTRIBUTE_POSITION_Y) == 0) event->position_y = geis_attr_value_to_float(attr); } return num_touches; } static gint drag_gesture_handle_properties (GripEventGestureDrag *event, GeisFrame frame) { guint attr_count = geis_frame_attr_count (frame); gint num_touches = 0; guint i; for (i = 0; i < attr_count; ++i) { GeisAttr attr = geis_frame_attr(frame, i); GeisString attr_name = geis_attr_name(attr); if (g_strcmp0 (attr_name, GEIS_GESTURE_ATTRIBUTE_TOUCHES) == 0) num_touches = geis_attr_value_to_integer(attr); if (g_strcmp0 (attr_name, GEIS_GESTURE_ATTRIBUTE_TIMESTAMP) == 0) event->timestamp = geis_attr_value_to_integer(attr); else if (g_strcmp0 (attr_name, GEIS_GESTURE_ATTRIBUTE_FOCUS_X) == 0) event->focus_x = geis_attr_value_to_float(attr); else if (g_strcmp0 (attr_name, GEIS_GESTURE_ATTRIBUTE_FOCUS_Y) == 0) event->focus_y = geis_attr_value_to_float(attr); else if (g_strcmp0 (attr_name, GEIS_GESTURE_ATTRIBUTE_DELTA_X) == 0) event->delta_x = geis_attr_value_to_float(attr); else if (g_strcmp0 (attr_name, GEIS_GESTURE_ATTRIBUTE_DELTA_Y) == 0) event->delta_y = geis_attr_value_to_float(attr); else if (g_strcmp0 (attr_name, GEIS_GESTURE_ATTRIBUTE_VELOCITY_X) == 0) event->velocity_x = geis_attr_value_to_float(attr); else if (g_strcmp0 (attr_name, GEIS_GESTURE_ATTRIBUTE_VELOCITY_Y) == 0) event->velocity_y = geis_attr_value_to_float(attr); else if (g_strcmp0 (attr_name, GEIS_GESTURE_ATTRIBUTE_POSITION_X) == 0) event->position_x = geis_attr_value_to_float(attr); else if (g_strcmp0 (attr_name, GEIS_GESTURE_ATTRIBUTE_POSITION_Y) == 0) event->position_y = geis_attr_value_to_float(attr); } return num_touches; } static gint rotate_gesture_handle_properties (GripEventGestureRotate *event, GeisFrame frame) { guint attr_count = geis_frame_attr_count (frame); gint num_touches = 0; guint i; for (i = 0; i < attr_count; ++i) { GeisAttr attr = geis_frame_attr(frame, i); GeisString attr_name = geis_attr_name(attr); if (g_strcmp0 (attr_name, GEIS_GESTURE_ATTRIBUTE_TOUCHES) == 0) num_touches = geis_attr_value_to_integer(attr); if (g_strcmp0 (attr_name, GEIS_GESTURE_ATTRIBUTE_TIMESTAMP) == 0) event->timestamp = geis_attr_value_to_integer(attr); else if (g_strcmp0 (attr_name, GEIS_GESTURE_ATTRIBUTE_FOCUS_X) == 0) event->focus_x = geis_attr_value_to_float(attr); else if (g_strcmp0 (attr_name, GEIS_GESTURE_ATTRIBUTE_FOCUS_Y) == 0) event->focus_y = geis_attr_value_to_float(attr); else if (g_strcmp0 (attr_name, GEIS_GESTURE_ATTRIBUTE_ANGLE_DELTA) == 0) event->angle_delta = geis_attr_value_to_float(attr); else if (g_strcmp0 (attr_name, GEIS_GESTURE_ATTRIBUTE_ANGULAR_VELOCITY) == 0) event->angular_velocity = geis_attr_value_to_float(attr); else if (g_strcmp0 (attr_name, GEIS_GESTURE_ATTRIBUTE_ANGLE) == 0) event->angle = geis_attr_value_to_float(attr); else if (g_strcmp0 (attr_name, GEIS_GESTURE_ATTRIBUTE_POSITION_X) == 0) event->position_x = geis_attr_value_to_float(attr); else if (g_strcmp0 (attr_name, GEIS_GESTURE_ATTRIBUTE_POSITION_Y) == 0) event->position_y = geis_attr_value_to_float(attr); } return num_touches; } static gint tap_gesture_handle_properties (GripEventGestureTap *event, GeisFrame frame) { guint attr_count = geis_frame_attr_count (frame); gint num_touches = 0; guint i; for (i = 0; i < attr_count; ++i) { GeisAttr attr = geis_frame_attr(frame, i); GeisString attr_name = geis_attr_name(attr); if (g_strcmp0 (attr_name, GEIS_GESTURE_ATTRIBUTE_TOUCHES) == 0) num_touches = geis_attr_value_to_integer(attr); if (g_strcmp0 (attr_name, GEIS_GESTURE_ATTRIBUTE_TIMESTAMP) == 0) event->timestamp = geis_attr_value_to_integer(attr); else if (g_strcmp0 (attr_name, GEIS_GESTURE_ATTRIBUTE_FOCUS_X) == 0) event->focus_x = geis_attr_value_to_float(attr); else if (g_strcmp0 (attr_name, GEIS_GESTURE_ATTRIBUTE_FOCUS_Y) == 0) event->focus_y = geis_attr_value_to_float(attr); else if (g_strcmp0 (attr_name, GEIS_GESTURE_ATTRIBUTE_POSITION_X) == 0) event->position_x = geis_attr_value_to_float(attr); else if (g_strcmp0 (attr_name, GEIS_GESTURE_ATTRIBUTE_POSITION_Y) == 0) event->position_y = geis_attr_value_to_float(attr); else if (g_strcmp0 (attr_name, GEIS_GESTURE_ATTRIBUTE_TAP_TIME) == 0) event->tap_time = geis_attr_value_to_float(attr); } return num_touches; } /** * Gets the extents of a widget in root window coordinates. */ static void get_absolute_widget_extents (GtkWidget *widget, gint *left, gint *right, gint *top, gint *bottom) { GdkWindow* widget_window = gtk_widget_get_window (widget); gdk_window_get_origin (widget_window, left, top); gint window_width = gdk_window_get_width (widget_window); gint window_height = gdk_window_get_height (widget_window); gdk_window_get_root_coords (widget_window, window_width, window_height, right, bottom); } /** * Gets the focus of a gesture frame in root window coordinates. */ static void get_absolute_frame_focus (GeisFrame frame, gint *x, gint *y) { *x = 0; *y = 0; GeisAttr focus_x_attr = geis_frame_attr_by_name (frame, GEIS_GESTURE_ATTRIBUTE_FOCUS_X); if (focus_x_attr) { *x = (int)geis_attr_value_to_float(focus_x_attr); } GeisAttr focus_y_attr = geis_frame_attr_by_name (frame, GEIS_GESTURE_ATTRIBUTE_FOCUS_Y); if (focus_y_attr) { *y = (int)geis_attr_value_to_float(focus_y_attr); } } /** * Indicates if the focus of a gesture frame is inside a widget. */ static gboolean is_frame_focus_in_widget (GeisFrame frame, GtkWidget *widget) { gboolean frame_focus_is_in_widget = FALSE; GtkWidget *toplevel_widget = gtk_widget_get_toplevel (widget); guint toplevel_widget_window_id = GDK_WINDOW_XID (gtk_widget_get_window (toplevel_widget)); GeisAttr window_attr = geis_frame_attr_by_name(frame, GEIS_GESTURE_ATTRIBUTE_EVENT_WINDOW_ID); guint window_id = geis_attr_value_to_integer(window_attr); if (window_id == toplevel_widget_window_id) { gint widget_left, widget_top, widget_right, widget_bottom; get_absolute_widget_extents (widget, &widget_left, &widget_right, &widget_top, &widget_bottom); gint focus_x, focus_y; get_absolute_frame_focus (frame, &focus_x, &focus_y); frame_focus_is_in_widget = (focus_x >= widget_left && focus_x <= widget_right && focus_y >= widget_top && focus_y <= widget_bottom); } return frame_focus_is_in_widget; } static void process_gesture_events (GripGestureManager *manager, GeisEvent geis_event) { GripGestureManagerPrivate *priv = manager->priv; GripTimeType time_type = GRIP_TIME_UPDATE; if (geis_event_type(geis_event) == GEIS_EVENT_GESTURE_BEGIN) time_type = GRIP_TIME_START; else if (geis_event_type(geis_event) == GEIS_EVENT_GESTURE_END) time_type = GRIP_TIME_END; GeisAttr attr = geis_event_attr_by_name (geis_event, GEIS_EVENT_ATTRIBUTE_GROUPSET); g_return_if_fail (attr); GeisGroupSet groupset = geis_attr_value_to_pointer (attr); g_return_if_fail (groupset); GeisSize i; for (i = 0; i < geis_groupset_group_count (groupset); ++i) { GeisGroup group = geis_groupset_group (groupset, i); g_return_if_fail (group); GeisSize j; for (j = 0; j < geis_group_frame_count (group); ++j) { GeisFrame frame = geis_group_frame(group, j); g_return_if_fail (frame); GeisAttr device_attr = geis_frame_attr_by_name(frame, GEIS_GESTURE_ATTRIBUTE_DEVICE_ID); guint device_id = geis_attr_value_to_integer(device_attr); GripInputDevice *input_device = device_id_to_input_device (manager, device_id); GList *l; for (l = priv->bindings; l != NULL; l = l->next) { GripGestureBinding *binding = (GripGestureBinding *)l->data; if (is_frame_focus_in_widget(frame, binding->widget)) { GList *class_list; for (class_list = priv->classes; class_list != NULL; class_list = class_list->next) { GripGestureClassMap *p = (GripGestureClassMap *)class_list->data; if (p->grip_type == binding->type) { if (geis_frame_is_class(frame, p->geis_class)) { GripGestureEvent *grip_event = grip_gesture_event_new (p->grip_type); if (p->grip_type == GRIP_GESTURE_DRAG) { GripEventGestureDrag *drag = (GripEventGestureDrag *)grip_event; drag->type = p->grip_type; drag->id = geis_frame_id(frame); drag->input_device = input_device; drag->fingers = drag_gesture_handle_properties (drag, frame); binding->callback (binding->widget, time_type, grip_event, binding->data); } else if (p->grip_type == GRIP_GESTURE_PINCH) { GripEventGesturePinch *pinch = (GripEventGesturePinch *)grip_event; pinch->type = p->grip_type; pinch->id = geis_frame_id(frame); pinch->input_device = input_device; pinch->fingers = pinch_gesture_handle_properties (pinch, frame); binding->callback (binding->widget, time_type, grip_event, binding->data); } else if (p->grip_type == GRIP_GESTURE_ROTATE) { GripEventGestureRotate *rotate = (GripEventGestureRotate *)grip_event; rotate->type = p->grip_type; rotate->id = geis_frame_id(frame); rotate->input_device = input_device; rotate->fingers = rotate_gesture_handle_properties (rotate, frame); binding->callback (binding->widget, time_type, grip_event, binding->data); } else if (p->grip_type == GRIP_GESTURE_TAP) { GripEventGestureTap *tap = (GripEventGestureTap *)grip_event; tap->type = p->grip_type; tap->id = geis_frame_id(frame); tap->input_device = input_device; tap->fingers = tap_gesture_handle_properties (tap, frame); binding->callback (binding->widget, time_type, grip_event, binding->data); } grip_gesture_event_free (grip_event); } } } } } } } } static gboolean grip_geis_event_ready (GIOChannel *source G_GNUC_UNUSED, GIOCondition condition G_GNUC_UNUSED, gpointer context) { Geis geis = (Geis)context; GeisStatus status G_GNUC_UNUSED = geis_dispatch_events(geis); return TRUE; } static void grip_gesture_manager_init (GripGestureManager *self) { GripGestureManagerPrivate *priv = self->priv = GRIP_GESTURE_MANAGER_GET_PRIVATE (self); priv->devices = g_ptr_array_new (); priv->is_initialized = FALSE; priv->geis = geis_new (GEIS_INIT_TRACK_DEVICES, GEIS_INIT_TRACK_GESTURE_CLASSES, NULL); g_return_if_fail (priv->geis); int fd; geis_get_configuration(priv->geis, GEIS_CONFIGURATION_FD, &fd); priv->iochannel = g_io_channel_unix_new (fd); priv->iochannel_id = g_io_add_watch (priv->iochannel, G_IO_IN, grip_geis_event_ready, priv->geis); geis_register_device_callback (priv->geis, grip_geis_event_callback, self); geis_register_class_callback (priv->geis, grip_geis_event_callback, self); geis_register_event_callback (priv->geis, grip_geis_event_callback, self); } static void window_destroyed_cb (GtkWidget *object, gpointer user_data) { GripGestureManager *manager = (GripGestureManager *)user_data; GList *l = manager->priv->bindings; while (l != NULL) { GList *next = l->next; GripGestureBinding *binding = l->data; if (gtk_widget_get_toplevel (binding->widget) == object) { geis_subscription_delete (binding->subscription); if (binding->destroy) binding->destroy (binding->data); g_free (binding); manager->priv->bindings = g_list_delete_link (manager->priv->bindings, l); } l = next; } } /* Public API */ GripGestureManager * grip_gesture_manager_get (void) { return g_object_new (GRIP_TYPE_GESTURE_MANAGER, NULL); } /* * processed_mapped_window_request: * @reg: a #GripRegistrationRequest (removed from the GripGestureManager * requests listand freed). * * Creates a subscription for a widget mapped to a window. */ static void processed_mapped_window_request (GripRegistrationRequest *req) { g_return_if_fail (GRIP_IS_GESTURE_MANAGER (req->manager)); g_return_if_fail (GTK_IS_WIDGET (req->widget)); GtkWidget *toplevel = gtk_widget_get_toplevel (req->widget); g_return_if_fail (GTK_IS_WINDOW (toplevel)); GripGestureManagerPrivate *priv = req->manager->priv; if (!priv->is_initialized) return; guint window_id = GDK_WINDOW_XID (gtk_widget_get_window(toplevel)); /* XXX - check for duplicates in reg->bindings first */ GripGestureBinding *binding = g_new0 (GripGestureBinding, 1); binding->type = req->gesture_type; binding->widget = req->widget; binding->touches = req->touch_points; binding->callback = req->callback; binding->data = req->user_data; binding->destroy = req->destroy; char sub_name[48]; snprintf(sub_name, 48, "sub-%x-%x-%x", window_id, req->gesture_type, req->touch_points); binding->subscription = geis_subscription_new (priv->geis, sub_name, GEIS_SUBSCRIPTION_CONT); g_return_if_fail (binding->subscription); char filter_id[20]; snprintf(filter_id, 20, "grip-%x", window_id); GeisFilter window_filter = geis_filter_new(priv->geis, filter_id); geis_filter_add_term(window_filter, GEIS_FILTER_REGION, GEIS_REGION_ATTRIBUTE_WINDOWID, GEIS_FILTER_OP_EQ, window_id, NULL); switch (req->gesture_type) { case GRIP_GESTURE_DRAG: geis_filter_add_term(window_filter, GEIS_FILTER_CLASS, GEIS_CLASS_ATTRIBUTE_NAME, GEIS_FILTER_OP_EQ, GEIS_GESTURE_DRAG, GEIS_GESTURE_ATTRIBUTE_TOUCHES, GEIS_FILTER_OP_EQ, req->touch_points, NULL); break; case GRIP_GESTURE_PINCH: geis_filter_add_term(window_filter, GEIS_FILTER_CLASS, GEIS_CLASS_ATTRIBUTE_NAME, GEIS_FILTER_OP_EQ, GEIS_GESTURE_PINCH, GEIS_GESTURE_ATTRIBUTE_TOUCHES, GEIS_FILTER_OP_EQ, req->touch_points, NULL); break; case GRIP_GESTURE_ROTATE: geis_filter_add_term(window_filter, GEIS_FILTER_CLASS, GEIS_CLASS_ATTRIBUTE_NAME, GEIS_FILTER_OP_EQ, GEIS_GESTURE_ROTATE, GEIS_GESTURE_ATTRIBUTE_TOUCHES, GEIS_FILTER_OP_EQ, req->touch_points, NULL); break; case GRIP_GESTURE_TAP: geis_filter_add_term(window_filter, GEIS_FILTER_CLASS, GEIS_CLASS_ATTRIBUTE_NAME, GEIS_FILTER_OP_EQ, GEIS_GESTURE_TAP, GEIS_GESTURE_ATTRIBUTE_TOUCHES, GEIS_FILTER_OP_EQ, req->touch_points, NULL); break; } if (req->device_type & GRIP_DEVICE_TOUCHSCREEN) { char filter_name[32]; snprintf(filter_name, 32, "%s/touchscreen", filter_id); GeisFilter touchscreen_filter = geis_filter_clone (window_filter, filter_name); geis_filter_add_term(touchscreen_filter, GEIS_FILTER_DEVICE, GEIS_DEVICE_ATTRIBUTE_DIRECT_TOUCH, GEIS_FILTER_OP_EQ, GEIS_TRUE, NULL); GeisStatus status = geis_subscription_add_filter(binding->subscription, touchscreen_filter); g_return_if_fail (status == GEIS_STATUS_SUCCESS); } if (req->device_type & GRIP_DEVICE_TOUCHPAD) { char filter_name[32]; snprintf(filter_name, 32, "%s/touchpad", filter_id); GeisFilter touchpad_filter = geis_filter_clone (window_filter, filter_name); geis_filter_add_term(touchpad_filter, GEIS_FILTER_DEVICE, GEIS_DEVICE_ATTRIBUTE_DIRECT_TOUCH, GEIS_FILTER_OP_EQ, GEIS_FALSE, NULL); GeisStatus status = geis_subscription_add_filter(binding->subscription, touchpad_filter); g_return_if_fail (status == GEIS_STATUS_SUCCESS); } if (req->device_type & GRIP_DEVICE_INDEPENDENT) { char filter_name[32]; snprintf(filter_name, 32, "%s/indep", filter_id); GeisFilter indep_filter = geis_filter_clone (window_filter, filter_name); geis_filter_add_term(indep_filter, GEIS_FILTER_DEVICE, GEIS_DEVICE_ATTRIBUTE_INDEPENDENT_TOUCH, GEIS_FILTER_OP_EQ, GEIS_TRUE, NULL); GeisStatus status = geis_subscription_add_filter(binding->subscription, indep_filter); g_return_if_fail (status == GEIS_STATUS_SUCCESS); } /* * If any device types were specified, the window_filter was cloned and needs * to be disposed of, otehrwise it's _the_ filter. */ if (req->device_type) { geis_filter_delete(window_filter); } else { GeisStatus status = geis_subscription_add_filter(binding->subscription, window_filter); g_return_if_fail (status == GEIS_STATUS_SUCCESS); } GeisStatus status = geis_subscription_activate (binding->subscription); g_return_if_fail (status == GEIS_STATUS_SUCCESS); priv->bindings = g_list_append (priv->bindings, binding); g_signal_connect (toplevel, "destroy", G_CALLBACK (window_destroyed_cb), req->manager); /* remove the request from the watch list */ g_free (req); priv->requests = g_list_remove (priv->requests, req); } /* * register_mapped_window: * @manager: a Grip gesture manager object * @toplevel: a top-level widget * * Processes all subscriptions requests for a newly-mapped window. */ static void register_mapped_window (GripGestureManager *manager, GtkWidget *toplevel) { g_return_if_fail (gtk_widget_is_toplevel (toplevel)); GList *pending_request = manager->priv->requests; while (pending_request) { GList *next = pending_request->next; GripRegistrationRequest *req = pending_request->data; if (gtk_widget_get_toplevel (req->widget) == toplevel) { processed_mapped_window_request (req); } pending_request = next; } } /* * register_toplevel_widget: * @manager: a Grip gesture manager object * @toplevel: a top-level widget * * Handles the registration of a widget that has just become a top-level widget. * * If the top-level widget is mapped to a window, it;s handled right away. * Otherwise, a callback is queued for when it does become mapped to a window. */ static void register_toplevel_widget (GripGestureManager *manager, GtkWidget *toplevel) { g_return_if_fail (gtk_widget_is_toplevel (toplevel)); if (gtk_widget_get_mapped (GTK_WIDGET (toplevel))) { register_mapped_window (manager, toplevel); } else { g_signal_connect (toplevel, "map-event", G_CALLBACK (toplevel_mapped_cb), manager); } } /* * toplevel_notify_cb: * * Called when a widget property has changed. * * The only widget property we're interested in here is the "parent" property. * We can't subscribe to gestures on a window until the widget is mapped to a * window. Only top-level widgets can be mapped to a window: we just keep * queueing this callback on successive parent widgets until one is a top-level * widget, then process that one. */ static void toplevel_notify_cb (GtkWidget *widget, GParamSpec *pspec, gpointer user_data) { if (pspec->name == g_intern_static_string ("parent")) { GtkWidget *toplevel = gtk_widget_get_toplevel (widget); GripGestureManager *manager = (GripGestureManager *)user_data; g_signal_handlers_disconnect_by_func (widget, G_CALLBACK (toplevel_notify_cb), user_data); if (gtk_widget_is_toplevel (toplevel)) { register_toplevel_widget (manager, toplevel); } else { g_signal_connect (G_OBJECT (toplevel), "notify", G_CALLBACK (toplevel_notify_cb), user_data); } } } /* * toplevel_mapped_cb: * * A callback invoked when a toplevel widget with one or more pending gesture * registration requests has been mapped to a window. * * This callback will in fact process all pending registration requests for the * newly-mapped window. */ static void toplevel_mapped_cb (GtkWidget *toplevel, GdkEvent *event G_GNUC_UNUSED, gpointer user_data) { GripGestureManager *manager = (GripGestureManager *)user_data; register_mapped_window (manager, toplevel); g_signal_handlers_disconnect_by_func (toplevel, toplevel_mapped_cb, user_data); } /** * grip_gesture_manager_register_window: * @manager: A #GripGestureManager instance. * @widget: A #GtkWidget to register the gesture event for. * @gesture_type: The type of gesture event to register. * @device_type: The type of the device use to create the gesture. * @touch_points: Number of touch points for this gesture. * @callback: Called when a gesture starts, updates, or ends. * @user_data: User data * @destroy: Destroy callback for user data. * * Registers a widget to receive gesture events. * * The callback parameters provided will be called by the * #GripGestureManager whenever the user initiates a gesture * on the specified window. */ void grip_gesture_manager_register_window (GripGestureManager *manager, GtkWidget *widget, GripGestureType gesture_type, GripDeviceType device_type, gint touch_points, GripGestureCallback callback, gpointer user_data, GDestroyNotify destroy) { g_return_if_fail (GRIP_IS_GESTURE_MANAGER (manager)); g_return_if_fail (GTK_IS_WIDGET (widget)); GtkWidget *toplevel = gtk_widget_get_toplevel (widget); GripRegistrationRequest *req = g_new0 (GripRegistrationRequest, 1); req->manager = manager; req->widget = widget; req->gesture_type = gesture_type; req->device_type = device_type; req->touch_points = touch_points; req->callback = callback; req->user_data = user_data; req->destroy = destroy; manager->priv->requests = g_list_append (manager->priv->requests, req); if (GTK_IS_WINDOW (toplevel)) { register_toplevel_widget (manager, toplevel); } else { g_signal_connect (toplevel, "notify", G_CALLBACK (toplevel_notify_cb), manager); } } void grip_gesture_manager_unregister_window (GripGestureManager *manager G_GNUC_UNUSED, GtkWidget *toplevel G_GNUC_UNUSED) { g_return_if_fail (GRIP_IS_GESTURE_MANAGER (manager)); g_return_if_fail (GTK_IS_WINDOW (toplevel)); window_destroyed_cb (toplevel, manager); } GType grip_gesture_event_get_type (void) { static GType type = 0; if (type == 0) { type = g_boxed_type_register_static (g_intern_static_string ("GripGestureEvent"), (GBoxedCopyFunc)grip_gesture_event_copy, (GBoxedFreeFunc)grip_gesture_event_free); } return type; } /** * grip_gesture_event_new: * @gesture_type: the type of the gesture * * Creates a new Grip gesture event. * * Returns: a new #GripGestureEvent */ GripGestureEvent * grip_gesture_event_new (GripGestureType gesture_type) { GripGestureEvent *event = g_slice_new0 (GripGestureEvent); event->any.type = gesture_type; return event; } /** * grip_gesture_event_copy: * @event: an existing #GripGestureEvent * * Creates a new #GripGestureEvent instance using a deep copy of and existing * event. * * Returns: a new #GripGestureEvent */ GripGestureEvent * grip_gesture_event_copy (const GripGestureEvent *event) { GripGestureEvent *new_event; g_return_val_if_fail (event != NULL, NULL); new_event = grip_gesture_event_new (event->type); *new_event = *event; return new_event; } /** * grip_gesture_event_free: * @event: a #GripGestureEvent * * Frees the resources allocated for a #GripGestureEvent. */ void grip_gesture_event_free (GripGestureEvent *event) { g_return_if_fail (event != NULL); g_slice_free (GripGestureEvent, event); } libgrip-0.3.9+15.10.20150729/src/gripgesturemanager.h0000644000015300001610000003326512556203475022367 0ustar pbuserpbgroup00000000000000/* * Copyright 2010, 2011 Canonical, Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of either or both of the following licenses: * * 1) the GNU Lesser General Public License version 3, as published by the * Free Software Foundation; and/or * 2) the GNU Lesser General Public License version 2.1, 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 warranties of * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR * PURPOSE. See the applicable version of the GNU Lesser General Public * License for more details. * * You should have received a copy of both the GNU Lesser General Public * License version 3 and version 2.1 along with this program. If not, see * * * Authors: * Cody Russell */ #ifndef GRIP_GESTURE_MANAGER_H #define GRIP_GESTURE_MANAGER_H #include #include "gripinputdevice.h" G_BEGIN_DECLS /** * SECTION:GripGestureManager * * The Grip gesture managre is a singleton object that connections to the * gesture recognition engine and manages gesture subscriptions for GTK widgets. */ /** * SECTION:GripGestureEvents * * A series of one or more events are passed to the gesture callback. Each * event conveys information specific to the type of gesture occurring. */ /** * GRIP_TYPE_GESTURE_MANAGER: * * Gets the #GType for the #GripGestureManager. */ #define GRIP_TYPE_GESTURE_MANAGER (grip_gesture_manager_get_type ()) /** * GRIP_GESTURE_MANAGER: * @obj: The #GObject to convert. * * Performs a checked conversion of a #GObject to a #GripGestureManager. */ #define GRIP_GESTURE_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GRIP_TYPE_GESTURE_MANAGER, GripGestureManager)) /** * GRIP_GESTURE_MANAGER_CLASS: * @klass: The #GObjectClass to convert. * * Performes a checked conversion of a #GObjectClass to a * #GripGestureManagerClass. */ #define GRIP_GESTURE_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GRIP_TYPE_GESTURE_MANAGER, GripGestureManagerClass)) /** * GRIP_IS_GESTURE_MANAGER: * @obj: The #GObject to check. * * Checks to see if #GripGestureManagerClass is in the #GObjectClass heirarchy * of @obj. */ #define GRIP_IS_GESTURE_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GRIP_TYPE_GESTURE_MANAGER)) /** * GRIP_IS_GESTURE_MANAGER_CLASS: * @klass: The #GObjectClass to check. * * Checks to see if a #GripGestureManagerClass object is in the object heirarchy * of @klass. */ #define GRIP_IS_GESTURE_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GRIP_TYPE_GESTURE_MANAGER)) /** * GRIP_GESTURE_MANAGER_GET_CLASS: * @obj: A #GObject. * * Gets the @GripGestureManagerClass object for @obj if that object is a member * of its #GObjectClass heirarchy. */ #define GRIP_GESTURE_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GRIP_TYPE_GESTURE_MANAGER, GripGestureManagerClass)) typedef struct _GripGestureManager GripGestureManager; typedef struct _GripGestureManagerClass GripGestureManagerClass; typedef struct _GripGestureManagerPrivate GripGestureManagerPrivate; typedef union _GripGestureEvent GripGestureEvent; typedef struct _GripEventGestureAny GripEventGestureAny; typedef struct _GripEventGestureDrag GripEventGestureDrag; typedef struct _GripEventGesturePinch GripEventGesturePinch; typedef struct _GripEventGestureRotate GripEventGestureRotate; typedef struct _GripEventGestureTap GripEventGestureTap; /** * GripGestureType: * @GRIP_GESTURE_DRAG: a drag gesture * @GRIP_GESTURE_PINCH: a pinch/expand gesture * @GRIP_GESTURE_ROTATE: a rotate gesture * @GRIP_GESTURE_TAP: a tap gesture * * Indicates the type of gesture for which a gesture event is being received. */ typedef enum { GRIP_GESTURE_DRAG = 0, GRIP_GESTURE_PINCH = 1, GRIP_GESTURE_ROTATE = 2, GRIP_GESTURE_TAP = 15 } GripGestureType; #define GRIP_DEVICE_ALL (GRIP_DEVICE_TOUCHSCREEN | GRIP_DEVICE_TOUCHPAD | GRIP_DEVICE_INDEPENDENT) /** * GripTimeType: * @GRIP_TIME_START: a new gesture is starting * @GRIP_TIME_UPDATE: an existing gesture is updating * @GRIP_TIME_END: a gesture is ending * * Indicates the part of the gesture stream ocuuring during the gesture event. */ typedef enum { GRIP_TIME_START, GRIP_TIME_UPDATE, GRIP_TIME_END } GripTimeType; /** * GripEventGestureAny: * * This struct is not used. */ struct _GripEventGestureAny { GdkEventType type; GdkWindow *window; }; /** * GripEventGestureDrag: * @type: the #GripGestureType of the gesture * @id: identifies the gesture * @window: the #GdkWindow in which the gesture occurred * @root: the root #GdkWindow * @child: the child #GdkWindow * @timestamp: the time the gesture event occurred * @fingers: the number of touches making up the gesture * @focus_x: the X coordinate of the focus point of the gesture start * @focus_y: the Y coordinate of the focus point of the gesture start * @delta_x: the change in the X coordinate since the last gesture event * @delta_y: the change in the Y coordinate since the last gesture event * @velocity_x: the rate of change of the X coordinate * @velocity_y: the rate of change of the Y coordinate * @position_x: the current X coordinate of the centroid poistion of the touches * @position_y: the current Y coordinate of the centroid poistion of the touches * @input_device: the #GripInputDevice used to make the gesture * * Data associated with a drag event. A drag is a lateral motion. */ struct _GripEventGestureDrag { GripGestureType type; guint id; GdkWindow *window; GdkWindow *root; GdkWindow *child; guint32 timestamp; gint fingers; gdouble focus_x; gdouble focus_y; gint delta_x; gint delta_y; gdouble velocity_x; gdouble velocity_y; gdouble position_x; gdouble position_y; GripInputDevice *input_device; }; /** * GripEventGesturePinch: * @type: the #GripGestureType of the gesture * @id: identifies the gesture * @window: the #GdkWindow in which the gesture occurred * @root: the root #GdkWindow * @child: the child #GdkWindow * @timestamp: the time the gesture event occurred * @fingers: the number of touches making up the gesture * @focus_x: the X coordinate of the focus point of the gesture start * @focus_y: the Y coordinate of the focus point of the gesture start * @radius_delta: the change in the radius (in screen coordinates) * @radial_velocity: the rate of change of the radius * @radius: the current radius (in screen coordinates) * @position_x: the current X coordinate of the centroid poistion of the touches * @position_y: the current Y coordinate of the centroid poistion of the touches * @input_device: the #GripInputDevice used to make the gesture * * Data associated with a pinch event. A pinch is an expand or contract motion. */ struct _GripEventGesturePinch { GripGestureType type; guint id; GdkWindow *window; GdkWindow *root; GdkWindow *child; guint32 timestamp; guint fingers; gdouble focus_x; gdouble focus_y; gdouble radius_delta; gdouble radial_velocity; gdouble radius; gfloat position_x; gfloat position_y; GripInputDevice *input_device; }; /** * GripEventGestureRotate: * @type: the #GripGestureType of the gesture * @id: identifies the gesture * @window: the #GdkWindow in which the gesture occurred * @root: the root #GdkWindow * @child: the child #GdkWindow * @timestamp: the time the gesture event occurred * @fingers: the number of touches making up the gesture * @focus_x: the X coordinate of the focus point of the gesture start * @focus_y: the Y coordinate of the focus point of the gesture start * @angle_delta: the change in the rotation angle (in radians) * @angular_velocity: the rate of change in the rotation angle * @angle: the current rotation angle * @position_x: the current X coordinate of the centroid poistion of the touches * @position_y: the current Y coordinate of the centroid poistion of the touches * @input_device: the #GripInputDevice used to make the gesture * * Data associated with a rotate gesture event. */ struct _GripEventGestureRotate { GripGestureType type; guint id; GdkWindow *window; GdkWindow *root; GdkWindow *child; guint32 timestamp; guint fingers; gdouble focus_x; gdouble focus_y; gdouble angle_delta; gdouble angular_velocity; gdouble angle; gfloat position_x; gfloat position_y; GripInputDevice *input_device; }; /** * GripEventGestureTap: * @type: the #GripGestureType of the gesture * @id: identifies the gesture * @window: the #GdkWindow in which the gesture occurred * @root: the root #GdkWindow * @child: the child #GdkWindow * @timestamp: the time the gesture event occurred * @fingers: the number of touches making up the gesture * @tap_time: the duration of the tap * @focus_x: the X coordinate of the focus point of the gesture start * @focus_y: the Y coordinate of the focus point of the gesture start * @position_x: the current X coordinate of the centroid poistion of the touches * @position_y: the current Y coordinate of the centroid poistion of the touches * @input_device: the #GripInputDevice used to make the gesture * * Data associated with a tap gesture. */ struct _GripEventGestureTap { GripGestureType type; guint id; GdkWindow *window; GdkWindow *root; GdkWindow *child; guint32 timestamp; guint fingers; guint32 tap_time; gfloat focus_x; gfloat focus_y; gfloat position_x; gfloat position_y; GripInputDevice *input_device; }; /** * GripGestureEvent: * @type: the #GripGestureType, selects the variant record * @drag: the event contains a drag gesture record * @pinch: the event contains a pinch gesture record * @rotate: the event contains a rotate gesture record * @tap: the event contains a tap gesture record * * This is a boxed type. */ union _GripGestureEvent { GripGestureType type; GripEventGestureAny any; GripEventGestureDrag drag; GripEventGesturePinch pinch; GripEventGestureRotate rotate; GripEventGestureTap tap; }; /** * GripGestureManager: * @parent_instance: the parent #GObject instance. * * A singleton manager into which a window may be registered to receive * multitouch gesture events. */ struct _GripGestureManager { /*< Public >*/ GObject parent_instance; /*< Private >*/ GripGestureManagerPrivate *priv; }; /** * GripGestureManagerClass: * @parent_class: the base #GObjectClass * * The class object for a #GripGestureManager. */ struct _GripGestureManagerClass { GObjectClass parent_class; }; /** * GripGestureCallback: * @widget: (in): A #GtkWidget pointer * @time: A #GripTimeType * @gesture: (in): A #GripGestureEvent pointer * @user_data: (transfer none): user data * * The gesture callback function is registered by the * grip_gesture_manager_register_window() function and gets called whenever a * new gesture event has been received. The same function may be registered for * more than one gesture type. * * The GripGestureCallback function is the main customization point * for application response to gestural input. **/ typedef void (* GripGestureCallback) (GtkWidget *widget, GripTimeType time, GripGestureEvent *gesture, gpointer user_data); GType grip_gesture_manager_get_type (void) G_GNUC_CONST; /** * grip_gesture_manager_get: * * Retrieves a #GripGestureManager pointer. * * Return value: (transfer none): A #GripGestureManager **/ GripGestureManager *grip_gesture_manager_get (void); /** * grip_gesture_manager_register_window: * @manager: self * @widget: A #GtkWidget on which to register the gesture * @gesture_type: Gesture type * @device_type: Type of the device producing the gesture. * @touch_points: Number of touch points * @callback: Callback * @user_data: (transfer none): User data * @destroy: (transfer none) (scope async): Destroy */ void grip_gesture_manager_register_window (GripGestureManager *manager, GtkWidget *widget, GripGestureType gesture_type, GripDeviceType device_type, gint touch_points, GripGestureCallback callback, gpointer user_data, GDestroyNotify destroy); void grip_gesture_manager_unregister_window (GripGestureManager *manager, GtkWidget *widget); GType grip_gesture_event_get_type (void) G_GNUC_CONST; GripGestureEvent *grip_gesture_event_new (GripGestureType gesture_type); void grip_gesture_event_free (GripGestureEvent *event); GripGestureEvent *grip_gesture_event_copy (const GripGestureEvent *event); G_END_DECLS #endif /* GRIP_GESTURE_MANAGER_H */ libgrip-0.3.9+15.10.20150729/src/gripinputdevice.c0000644000015300001610000002614312556203475021665 0ustar pbuserpbgroup00000000000000/* * Copyright 2011, 2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of either or both of the following licenses: * * 1) the GNU Lesser General Public License version 3, as published by the * Free Software Foundation; and/or * 2) the GNU Lesser General Public License version 2.1, 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 warranties of * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR * PURPOSE. See the applicable version of the GNU Lesser General Public * License for more details. * * You should have received a copy of both the GNU Lesser General Public * License version 3 and version 2.1 along with this program. If not, see * */ #include "gripinputdevice.h" #include #include G_DEFINE_TYPE (GripInputDevice, grip_input_device, G_TYPE_OBJECT); struct GripInputDevicePrivate { GeisDevice geis_device; gchar *name; GeisInputDeviceId device_id; gint touches; gboolean is_direct; gboolean is_independent; GripAxisExtents x_extents; GripAxisExtents y_extents; }; enum { PROP_0, PROP_GEIS_DEVICE, PROP_GEIS_DEVICE_ATTRS }; /* * grip_input_device_constructor: * @type: The internal type of the #GripInputDevice class. * @n_params: The number of constructor parameters passed. * @params: A collection of constructor parameters. * * Constructs a new input device. */ static GObject * grip_input_device_constructor (GType type, guint n_params, GObjectConstructParam *params) { GObjectClass *parent_class = G_OBJECT_CLASS (grip_input_device_parent_class); GObject *object = parent_class->constructor (type, n_params, params); GripInputDevice *input_device = GRIP_INPUT_DEVICE (object); guint i; if (input_device->priv->geis_device == NULL) { for (i = 0; i < n_params; ++i) { if (0 == g_strcmp0(params[i].pspec->name, "device-attrs")) { GeisGestureAttr *attrs = (GeisGestureAttr *)g_value_get_pointer (params[i].value); GeisGestureAttr *a; for (a = attrs; a->name; a++) { if (0 == g_strcmp0 (a->name, GEIS_DEVICE_ATTRIBUTE_NAME)) input_device->priv->name = g_strdup (a->string_val); else if (0 == g_strcmp0 (a->name, GEIS_DEVICE_ATTRIBUTE_ID)) input_device->priv->device_id = a->integer_val; else if (0 == g_strcmp0 (a->name, GEIS_DEVICE_ATTRIBUTE_TOUCHES)) input_device->priv->touches = a->integer_val; else if (0 == g_strcmp0 (a->name, GEIS_DEVICE_ATTRIBUTE_DIRECT_TOUCH)) input_device->priv->is_direct = a->boolean_val; else if (0 == g_strcmp0 (a->name, GEIS_DEVICE_ATTRIBUTE_INDEPENDENT_TOUCH)) input_device->priv->is_independent = a->boolean_val; else if (0 == g_strcmp0 (a->name, GEIS_DEVICE_ATTRIBUTE_MIN_X)) input_device->priv->x_extents.minimum = a->float_val; else if (0 == g_strcmp0 (a->name, GEIS_DEVICE_ATTRIBUTE_MAX_X)) input_device->priv->x_extents.maximum = a->float_val; else if (0 == g_strcmp0 (a->name, GEIS_DEVICE_ATTRIBUTE_RES_X)) input_device->priv->x_extents.resolution = a->float_val; else if (0 == g_strcmp0 (a->name, GEIS_DEVICE_ATTRIBUTE_MIN_Y)) input_device->priv->y_extents.minimum = a->float_val; else if (0 == g_strcmp0 (a->name, GEIS_DEVICE_ATTRIBUTE_MAX_Y)) input_device->priv->y_extents.maximum = a->float_val; else if (0 == g_strcmp0 (a->name, GEIS_DEVICE_ATTRIBUTE_RES_Y)) input_device->priv->y_extents.resolution = a->float_val; } } } } else { guint num_attrs = geis_device_attr_count(input_device->priv->geis_device); for (i = 0; i < num_attrs; ++i) { GeisAttr attr = geis_device_attr(input_device->priv->geis_device, i); if (0 == g_strcmp0 (geis_attr_name(attr), GEIS_DEVICE_ATTRIBUTE_NAME)) input_device->priv->name = g_strdup (geis_attr_value_to_string(attr)); else if (0 == g_strcmp0 (geis_attr_name(attr), GEIS_DEVICE_ATTRIBUTE_ID)) input_device->priv->device_id = geis_attr_value_to_integer(attr); else if (0 == g_strcmp0 (geis_attr_name(attr), GEIS_DEVICE_ATTRIBUTE_TOUCHES)) input_device->priv->touches = geis_attr_value_to_integer(attr); else if (0 == g_strcmp0 (geis_attr_name(attr), GEIS_DEVICE_ATTRIBUTE_DIRECT_TOUCH)) input_device->priv->is_direct = geis_attr_value_to_boolean(attr); else if (0 == g_strcmp0 (geis_attr_name(attr), GEIS_DEVICE_ATTRIBUTE_INDEPENDENT_TOUCH)) input_device->priv->is_independent = geis_attr_value_to_boolean(attr); else if (0 == g_strcmp0 (geis_attr_name(attr), GEIS_DEVICE_ATTRIBUTE_MIN_X)) input_device->priv->x_extents.minimum = geis_attr_value_to_float(attr); else if (0 == g_strcmp0 (geis_attr_name(attr), GEIS_DEVICE_ATTRIBUTE_MAX_X)) input_device->priv->x_extents.maximum = geis_attr_value_to_float(attr); else if (0 == g_strcmp0 (geis_attr_name(attr), GEIS_DEVICE_ATTRIBUTE_RES_X)) input_device->priv->x_extents.resolution = geis_attr_value_to_float(attr); else if (0 == g_strcmp0 (geis_attr_name(attr), GEIS_DEVICE_ATTRIBUTE_MIN_Y)) input_device->priv->y_extents.minimum = geis_attr_value_to_float(attr); else if (0 == g_strcmp0 (geis_attr_name(attr), GEIS_DEVICE_ATTRIBUTE_MAX_Y)) input_device->priv->y_extents.maximum = geis_attr_value_to_float(attr); else if (0 == g_strcmp0 (geis_attr_name(attr), GEIS_DEVICE_ATTRIBUTE_RES_Y)) input_device->priv->y_extents.resolution = geis_attr_value_to_float(attr); } } return object; } /* * grip_input_device_finalize: * @object: A #GripInputDevice object * * Frees all allocated resources of a #GripInputDevice before turing in for the * night. */ static void grip_input_device_finalize (GObject *object) { GObjectClass *parent_class = G_OBJECT_CLASS (grip_input_device_parent_class); GripInputDevice *input_device = GRIP_INPUT_DEVICE (object); g_free (input_device->priv->name); parent_class->finalize (object); } /* * grip_input_device_set_property: * @object: A #GripInputDevice object * @property_id: Identifies the property. * @value: The value of the property. * @pspec: The specification of the property. * * Sets properties on a #GripInputDevice. */ static void grip_input_device_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { GripInputDevice *input_device = GRIP_INPUT_DEVICE (object); switch (property_id) { case PROP_GEIS_DEVICE: input_device->priv->geis_device = g_value_get_pointer (value); break; case PROP_GEIS_DEVICE_ATTRS: break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; } } /** * grip_input_device_get_id: * @input_device: (in): A #GripInputDevice * * Gets the internal identifier of the input device. * * Returns: the internal identifier of the input device */ guint grip_input_device_get_id(GripInputDevice *input_device) { return input_device->priv->device_id; } /** * grip_input_device_get_name: * @input_device: (in): A #GripInputDevice * * Gets the name of the input device, as retrieved from the device itself. * * Returns: the seld-described name of the input device. */ const gchar * grip_input_device_get_name (GripInputDevice *input_device) { return input_device->priv->name; } /** * grip_input_device_is_direct: * @input_device: (in): A #GripInputDevice * * Indicates if the input device is a direct input device (eg. touchscreen) or * not (eg. touchpad). * * Returns: %TRUE if the input device is an direct device, %FALSE * otherwsie. */ gboolean grip_input_device_is_direct(GripInputDevice *input_device) { return input_device->priv->is_direct; } /** * grip_input_device_is_independent: * @input_device: (in): A #GripInputDevice * * Indicates if the input device is an independent input device (for example, an * Apple MagicMouse). * * Returns: %TRUE if the input device is an independent device, %FALSE * otherwsie. */ gboolean grip_input_device_is_independent(GripInputDevice *input_device) { return input_device->priv->is_independent; } /** * grip_input_device_get_x_extents: * @input_device: (in): A #GripInputDevice * * Returns: the X-axis extents of the device. */ const GripAxisExtents * grip_input_device_get_x_extents(GripInputDevice *input_device) { return &input_device->priv->x_extents; } /** * grip_input_device_get_y_extents: * @input_device: (in): A #GripInputDevice * * Returns: the Y-axis extents of the device. */ const GripAxisExtents * grip_input_device_get_y_extents(GripInputDevice *input_device) { return &input_device->priv->y_extents; } /* * grip_input_device_init: * @self: A #GripInputDevice * * Initializes a #GripInputDevice object before construction. */ static void grip_input_device_init (GripInputDevice *self) { self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GRIP_TYPE_INPUT_DEVICE, GripInputDevicePrivate); } /* * grip_input_device_class_init: * @klass: the class object. * * Initializes the #GripInputDeviceClass. */ static void grip_input_device_class_init (GripInputDeviceClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); g_type_class_add_private (object_class, sizeof (GripInputDevicePrivate)); object_class->constructor = grip_input_device_constructor; object_class->set_property = grip_input_device_set_property; object_class->finalize = grip_input_device_finalize; /** * GripInputDevice:device-attrs: * * A list of GEIS v1 device attrs (passed into the device callback) used to * construct a #GripInputDevice. */ g_object_class_install_property (object_class, PROP_GEIS_DEVICE_ATTRS, g_param_spec_pointer ("device-attrs", "GEIS1 device attributes", "a list of GEIS v1 device attributes", G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS)); /** * GripInputDevice:geis-device: * * A GEIS v2 device object used to construct a #GripInputDevice. */ g_object_class_install_property (object_class, PROP_GEIS_DEVICE, g_param_spec_pointer ("geis-device", "GEIS device", "a GEIS device", G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS)); } GripDeviceType grip_get_device_type (GripInputDevice *input_device) { gboolean is_direct = grip_input_device_is_direct (input_device); gboolean is_independent = grip_input_device_is_independent (input_device); if (is_direct && !is_independent) return GRIP_DEVICE_TOUCHSCREEN; if (!is_direct && !is_independent) return GRIP_DEVICE_TOUCHPAD; if (!is_direct && is_independent) return GRIP_DEVICE_INDEPENDENT; g_critical("Unknown touch device type."); return GRIP_DEVICE_TOUCHSCREEN; } libgrip-0.3.9+15.10.20150729/src/Makefile.am0000644000015300001610000000553612556203475020357 0ustar pbuserpbgroup00000000000000grip_version_script = \ $(srcdir)/libgrip.ver grip_built_public_sources = \ griptypebuiltins.h stamp_files = \ griptypebuiltins.h \ griptypebuiltins.c sources_h = \ gripgesturemanager.h \ gripinputdevice.h EXTRA_DIST = \ griptypebuiltins.h.in \ griptypebuiltins.c.in \ $(grip_version_script) griptypebuiltins.h: stamp-griptypebuiltins.h stamp-griptypebuiltins.h: $(sources_h) ( cd $(srcdir) && $(GLIB_MKENUMS) --template griptypebuiltins.h.in \ $(sources_h) ) >> xgen-gtbh \ && (cmp -s xgen-gtbh griptypebuiltins.h || cp xgen-gtbh griptypebuiltins.h ) \ && rm -f xgen-gtbh && echo timestamp > $(@F) griptypebuiltins.c: stamp-griptypebuiltins.h ( cd $(srcdir) && $(GLIB_MKENUMS) --template griptypebuiltins.c.in \ $(sources_h) ) > xgen-gtbc \ && cp xgen-gtbc griptypebuiltins.c && rm -f xgen-gtbc CLEANFILES = if HAVE_INTROSPECTION BUILT_GIRSOURCES = introspection_sources = $(patsubst %,$(srcdir)/%,$(sources_h)) irscanner_headers = $(patsubst %,$(srcdir)/%,$(sources_h)) Grip-1.0.gir: $(INTROSPECTION_SCANNER) $(irscanner_headers) Makefile.am $(INTROSPECTION_SCANNER) \ -v --namespace Grip \ --nsversion=0.2 \ --warn-all --warn-error \ -DG_IR_IGNORE \ --libtool=$(top_builddir)/libtool \ --add-include-path=$(srcdir) $(GTK_CFLAGS) \ --include=GObject-2.0 \ --include=GLib-2.0 \ --include=Gtk-3.0 \ --library=grip \ --output $@ $(irscanner_headers) \ $(addprefix --c-include=src/, $(grip_headers)) BUILT_GIRSOURCES += Grip-1.0.gir girdir = $(datadir)/gir-1.0 gir_DATA = $(BUILT_GIRSOURCES) typelibsdir = $(libdir)/girepository-1.0 typelibs_DATA = $(BUILT_GIRSOURCES:.gir=.typelib) %.typelib: %.gir $(INTROSPECTION_COMPILER) $(INTROSPECTION_COMPILER) \ --includedir=$(srcdir) \ --includedir=. \ --includedir=$(top_builddir)/src \ $(INTROSPECTION_COMPILER_OPTS) \ $< -o $(@F) CLEANFILES += $(BUILT_GIRSOURCES) $(typelibs_DATA) endif INCLUDES = \ -I$(srcdir) \ -I$(top_srcdir) \ -DG_LOG_DOMAIN=\"GRIP\" \ -DPREFIX=\"$(prefix)"\" \ -DLIBDIR=\"$(libdir)"\" \ -DG_DISABLE_DEPRECATED \ -DGDK_PIXBUF_DISABLE_DEPRECATED \ -DGDK_DISABLE_DEPRECATED \ -DGTK_DISABLE_DEPRECATED AM_CPPFLAGS = \ -Wall -Wextra \ $(GCC_FLAGS) \ $(GTK_CFLAGS) \ $(GEIS_CFLAGS) \ $(MAINTAINER_CFLAGS) lib_LTLIBRARIES = libgrip.la libgrip_la_SOURCES = \ gripgesturemanager.c \ gripinputdevice.c \ griptypebuiltins.c libgripincludedir=$(includedir)/libgrip libgripinclude_HEADERS = \ $(sources_h) \ grip.h libgrip_la_LIBADD = $(GTK_LIBS) $(GEIS_LIBS) libgrip_la_LDFLAGS = \ -Wl,-z,defs -Wl,--as-needed \ -Wl,--version-script=$(grip_version_script) \ $(GRIP_LT_LDFLAGS) \ $(GTK_LT_LDFLAGS) gripheadersdir = $(includedir)/grip DISTCLEANFILES = \ stamp-griptypebuiltins.h \ griptypebuiltins.h \ griptypebuiltins.c libgrip-0.3.9+15.10.20150729/src/griptypebuiltins.h.in0000644000015300001610000000077212556203475022513 0ustar pbuserpbgroup00000000000000/*** BEGIN file-header ***/ #ifndef GRIP_ENUM_TYPES_H #define GRIP_ENUM_TYPES_H #include G_BEGIN_DECLS /*** END file-header ***/ /*** BEGIN file-production ***/ /* enumerations from "@filename@" */ /*** END file-production ***/ /*** BEGIN file-tail ***/ G_END_DECLS #endif /* !GRIP_ENUM_TYPES_H */ /*** END file-tail ***/ /*** BEGIN value-header ***/ GType @enum_name@_get_type (void) G_GNUC_CONST; #define GRIP_TYPE_@ENUMSHORT@ (@enum_name@_get_type()) /*** END value-header ***/ libgrip-0.3.9+15.10.20150729/NEWS0000644000015300001610000000000012556203475016210 0ustar pbuserpbgroup00000000000000libgrip-0.3.9+15.10.20150729/COPYING0000644000015300001610000001672712556203475016573 0ustar pbuserpbgroup00000000000000 GNU LESSER GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below. 0. Additional Definitions. As used herein, "this License" refers to version 3 of the GNU Lesser General Public License, and the "GNU GPL" refers to version 3 of the GNU General Public License. "The Library" refers to a covered work governed by this License, other than an Application or a Combined Work as defined below. An "Application" is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library. A "Combined Work" is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the "Linked Version". The "Minimal Corresponding Source" for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version. The "Corresponding Application Code" for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work. 1. Exception to Section 3 of the GNU GPL. You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL. 2. Conveying Modified Versions. If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version: a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy. 3. Object Code Incorporating Material from Library Header Files. The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following: a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the object code with a copy of the GNU GPL and this license document. 4. Combined Works. You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following: a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the Combined Work with a copy of the GNU GPL and this license document. c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document. d) Do one of the following: 0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source. 1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version. e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.) 5. Combined Libraries. You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License. b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 6. Revised Versions of the GNU Lesser General Public License. The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation. If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library. libgrip-0.3.9+15.10.20150729/TODO0000644000015300001610000000000012556203475016201 0ustar pbuserpbgroup00000000000000libgrip-0.3.9+15.10.20150729/autogen.sh0000755000015300001610000000031412556203475017522 0ustar pbuserpbgroup00000000000000#!/bin/sh PKG_NAME="grip" which gnome-autogen.sh || { echo "You need gnome-common from GNOME git" exit 1 } USE_GNOME2_MACROS=1 \ USE_COMMON_DOC_BUILD=yes \ gnome-autogen.sh --enable-gtk-doc $@ libgrip-0.3.9+15.10.20150729/Makefile.am0000644000015300001610000000264412556203475017565 0ustar pbuserpbgroup00000000000000SUBDIRS = src bindings examples/rectangle-mover doc pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = libgrip.pc CLEANFILES = libgrip.pc DISTCLEANFILES = libgrip.pc grip*.tar.gz EXTRA_DIST = libgrip.pc.in m4/introspection.m4 autogen.sh ACLOCAL_AMFLAGS=-I m4 DISTCHECK_CONFIGURE_FLAGS = --enable-gtk-doc --enable-introspection --enable-localinstall dist-hook: @if test -d "$(top_srcdir)/.bzr"; \ then \ echo Creating ChangeLog && \ ( cd "$(top_srcdir)" && \ echo '# Generated by Makefile. Do not edit.'; echo; \ $(top_srcdir)/missing --run bzr log --gnu-changelog ) > ChangeLog.tmp \ && mv -f ChangeLog.tmp $(top_distdir)/ChangeLog \ || (rm -f ChangeLog.tmp; \ echo Failed to generate ChangeLog >&2 ); \ else \ echo Failed to generate ChangeLog: not a branch >&2; \ fi @if test -d "$(top_srcdir)/.bzr"; \ then \ echo Creating AUTHORS && \ ( cd "$(top_srcdir)" && \ echo '# Generated by Makefile. Do not edit.'; echo; \ $(top_srcdir)/missing --run bzr log --long --levels=0 | grep -e "^\s*author:" -e "^\s*committer:" | cut -d ":" -f 2 | cut -d "<" -f 1 | sort -u) > AUTHORS.tmp \ && mv -f AUTHORS.tmp $(top_distdir)/AUTHORS \ || (rm -f AUTHORS.tmp; \ echo Failed to generate AUTHORS >&2 ); \ else \ echo Failed to generate AUTHORS: not a branch >&2; \ fi libgrip-0.3.9+15.10.20150729/README0000644000015300001610000000000012556203475016371 0ustar pbuserpbgroup00000000000000libgrip-0.3.9+15.10.20150729/m4/0000755000015300001610000000000012556203774016045 5ustar pbuserpbgroup00000000000000libgrip-0.3.9+15.10.20150729/m4/introspection.m40000644000015300001610000000600312556203475021204 0ustar pbuserpbgroup00000000000000dnl -*- mode: autoconf -*- dnl Copyright 2009 Johan Dahlin dnl dnl This file is free software; the author(s) gives unlimited dnl permission to copy and/or distribute it, with or without dnl modifications, as long as this notice is preserved. dnl # serial 1 m4_define([_GOBJECT_INTROSPECTION_CHECK_INTERNAL], [ AC_BEFORE([AC_PROG_LIBTOOL],[$0])dnl setup libtool first AC_BEFORE([AM_PROG_LIBTOOL],[$0])dnl setup libtool first AC_BEFORE([LT_INIT],[$0])dnl setup libtool first dnl enable/disable introspection m4_if([$2], [require], [dnl enable_introspection=yes ],[dnl AC_ARG_ENABLE(introspection, AS_HELP_STRING([--enable-introspection[=@<:@no/auto/yes@:>@]], [Enable introspection for this build]),, [enable_introspection=auto]) ])dnl AC_MSG_CHECKING([for gobject-introspection]) dnl presence/version checking AS_CASE([$enable_introspection], [no], [dnl found_introspection="no (disabled, use --enable-introspection to enable)" ],dnl [yes],[dnl PKG_CHECK_EXISTS([gobject-introspection-1.0],, AC_MSG_ERROR([gobject-introspection-1.0 is not installed])) PKG_CHECK_EXISTS([gobject-introspection-1.0 >= $1], found_introspection=yes, AC_MSG_ERROR([You need to have gobject-introspection >= $1 installed to build AC_PACKAGE_NAME])) ],dnl [auto],[dnl PKG_CHECK_EXISTS([gobject-introspection-1.0 >= $1], found_introspection=yes, found_introspection=no) ],dnl [dnl AC_MSG_ERROR([invalid argument passed to --enable-introspection, should be one of @<:@no/auto/yes@:>@]) ])dnl AC_MSG_RESULT([$found_introspection]) INTROSPECTION_SCANNER= INTROSPECTION_COMPILER= INTROSPECTION_GENERATE= INTROSPECTION_GIRDIR= INTROSPECTION_TYPELIBDIR= if test "x$found_introspection" = "xyes"; then INTROSPECTION_SCANNER=`$PKG_CONFIG --variable=g_ir_scanner gobject-introspection-1.0` INTROSPECTION_COMPILER=`$PKG_CONFIG --variable=g_ir_compiler gobject-introspection-1.0` INTROSPECTION_GENERATE=`$PKG_CONFIG --variable=g_ir_generate gobject-introspection-1.0` INTROSPECTION_GIRDIR=`$PKG_CONFIG --variable=girdir gobject-introspection-1.0` INTROSPECTION_TYPELIBDIR="$($PKG_CONFIG --variable=typelibdir gobject-introspection-1.0)" fi AC_SUBST(INTROSPECTION_SCANNER) AC_SUBST(INTROSPECTION_COMPILER) AC_SUBST(INTROSPECTION_GENERATE) AC_SUBST(INTROSPECTION_GIRDIR) AC_SUBST(INTROSPECTION_TYPELIBDIR) AM_CONDITIONAL(HAVE_INTROSPECTION, test "x$found_introspection" = "xyes") ]) dnl Usage: dnl GOBJECT_INTROSPECTION_CHECK([minimum-g-i-version]) AC_DEFUN([GOBJECT_INTROSPECTION_CHECK], [ _GOBJECT_INTROSPECTION_CHECK_INTERNAL([$1]) ]) dnl Usage: dnl GOBJECT_INTROSPECTION_REQUIRE([minimum-g-i-version]) AC_DEFUN([GOBJECT_INTROSPECTION_REQUIRE], [ _GOBJECT_INTROSPECTION_CHECK_INTERNAL([$1], [require]) ]) libgrip-0.3.9+15.10.20150729/INSTALL0000644000015300001610000003661012556203475016562 0ustar pbuserpbgroup00000000000000Installation Instructions ************************* Copyright (C) 1994-1996, 1999-2002, 2004-2013 Free Software Foundation, Inc. Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved. This file is offered as-is, without warranty of any kind. Basic Installation ================== Briefly, the shell command `./configure && make && make install' should configure, build, and install this package. The following more-detailed instructions are generic; see the `README' file for instructions specific to this package. Some packages provide this `INSTALL' file but do not implement all of the features documented below. The lack of an optional feature in a given package is not necessarily a bug. More recommendations for GNU packages can be found in *note Makefile Conventions: (standards)Makefile Conventions. The `configure' shell script attempts to guess correct values for various system-dependent variables used during compilation. It uses those values to create a `Makefile' in each directory of the package. It may also create one or more `.h' files containing system-dependent definitions. Finally, it creates a shell script `config.status' that you can run in the future to recreate the current configuration, and a file `config.log' containing compiler output (useful mainly for debugging `configure'). It can also use an optional file (typically called `config.cache' and enabled with `--cache-file=config.cache' or simply `-C') that saves the results of its tests to speed up reconfiguring. Caching is disabled by default to prevent problems with accidental use of stale cache files. If you need to do unusual things to compile the package, please try to figure out how `configure' could check whether to do them, and mail diffs or instructions to the address given in the `README' so they can be considered for the next release. If you are using the cache, and at some point `config.cache' contains results you don't want to keep, you may remove or edit it. The file `configure.ac' (or `configure.in') is used to create `configure' by a program called `autoconf'. You need `configure.ac' if you want to change it or regenerate `configure' using a newer version of `autoconf'. The simplest way to compile this package is: 1. `cd' to the directory containing the package's source code and type `./configure' to configure the package for your system. Running `configure' might take a while. While running, it prints some messages telling which features it is checking for. 2. Type `make' to compile the package. 3. Optionally, type `make check' to run any self-tests that come with the package, generally using the just-built uninstalled binaries. 4. Type `make install' to install the programs and any data files and documentation. When installing into a prefix owned by root, it is recommended that the package be configured and built as a regular user, and only the `make install' phase executed with root privileges. 5. Optionally, type `make installcheck' to repeat any self-tests, but this time using the binaries in their final installed location. This target does not install anything. Running this target as a regular user, particularly if the prior `make install' required root privileges, verifies that the installation completed correctly. 6. You can remove the program binaries and object files from the source code directory by typing `make clean'. To also remove the files that `configure' created (so you can compile the package for a different kind of computer), type `make distclean'. There is also a `make maintainer-clean' target, but that is intended mainly for the package's developers. If you use it, you may have to get all sorts of other programs in order to regenerate files that came with the distribution. 7. Often, you can also type `make uninstall' to remove the installed files again. In practice, not all packages have tested that uninstallation works correctly, even though it is required by the GNU Coding Standards. 8. Some packages, particularly those that use Automake, provide `make distcheck', which can by used by developers to test that all other targets like `make install' and `make uninstall' work correctly. This target is generally not run by end users. Compilers and Options ===================== Some systems require unusual options for compilation or linking that the `configure' script does not know about. Run `./configure --help' for details on some of the pertinent environment variables. You can give `configure' initial values for configuration parameters by setting variables in the command line or in the environment. Here is an example: ./configure CC=c99 CFLAGS=-g LIBS=-lposix *Note Defining Variables::, for more details. Compiling For Multiple Architectures ==================================== You can compile the package for more than one kind of computer at the same time, by placing the object files for each architecture in their own directory. To do this, you can use GNU `make'. `cd' to the directory where you want the object files and executables to go and run the `configure' script. `configure' automatically checks for the source code in the directory that `configure' is in and in `..'. This is known as a "VPATH" build. With a non-GNU `make', it is safer to compile the package for one architecture at a time in the source code directory. After you have installed the package for one architecture, use `make distclean' before reconfiguring for another architecture. On MacOS X 10.5 and later systems, you can create libraries and executables that work on multiple system types--known as "fat" or "universal" binaries--by specifying multiple `-arch' options to the compiler but only a single `-arch' option to the preprocessor. Like this: ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ CPP="gcc -E" CXXCPP="g++ -E" This is not guaranteed to produce working output in all cases, you may have to build one architecture at a time and combine the results using the `lipo' tool if you have problems. Installation Names ================== By default, `make install' installs the package's commands under `/usr/local/bin', include files under `/usr/local/include', etc. You can specify an installation prefix other than `/usr/local' by giving `configure' the option `--prefix=PREFIX', where PREFIX must be an absolute file name. You can specify separate installation prefixes for architecture-specific files and architecture-independent files. If you pass the option `--exec-prefix=PREFIX' to `configure', the package uses PREFIX as the prefix for installing programs and libraries. Documentation and other data files still use the regular prefix. In addition, if you use an unusual directory layout you can give options like `--bindir=DIR' to specify different values for particular kinds of files. Run `configure --help' for a list of the directories you can set and what kinds of files go in them. In general, the default for these options is expressed in terms of `${prefix}', so that specifying just `--prefix' will affect all of the other directory specifications that were not explicitly provided. The most portable way to affect installation locations is to pass the correct locations to `configure'; however, many packages provide one or both of the following shortcuts of passing variable assignments to the `make install' command line to change installation locations without having to reconfigure or recompile. The first method involves providing an override variable for each affected directory. For example, `make install prefix=/alternate/directory' will choose an alternate location for all directory configuration variables that were expressed in terms of `${prefix}'. Any directories that were specified during `configure', but not in terms of `${prefix}', must each be overridden at install time for the entire installation to be relocated. The approach of makefile variable overrides for each directory variable is required by the GNU Coding Standards, and ideally causes no recompilation. However, some platforms have known limitations with the semantics of shared libraries that end up requiring recompilation when using this method, particularly noticeable in packages that use GNU Libtool. The second method involves providing the `DESTDIR' variable. For example, `make install DESTDIR=/alternate/directory' will prepend `/alternate/directory' before all installation names. The approach of `DESTDIR' overrides is not required by the GNU Coding Standards, and does not work on platforms that have drive letters. On the other hand, it does better at avoiding recompilation issues, and works well even when some directory options were not specified in terms of `${prefix}' at `configure' time. Optional Features ================= If the package supports it, you can cause programs to be installed with an extra prefix or suffix on their names by giving `configure' the option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. Some packages pay attention to `--enable-FEATURE' options to `configure', where FEATURE indicates an optional part of the package. They may also pay attention to `--with-PACKAGE' options, where PACKAGE is something like `gnu-as' or `x' (for the X Window System). The `README' should mention any `--enable-' and `--with-' options that the package recognizes. For packages that use the X Window System, `configure' can usually find the X include and library files automatically, but if it doesn't, you can use the `configure' options `--x-includes=DIR' and `--x-libraries=DIR' to specify their locations. Some packages offer the ability to configure how verbose the execution of `make' will be. For these packages, running `./configure --enable-silent-rules' sets the default to minimal output, which can be overridden with `make V=1'; while running `./configure --disable-silent-rules' sets the default to verbose, which can be overridden with `make V=0'. Particular systems ================== On HP-UX, the default C compiler is not ANSI C compatible. If GNU CC is not installed, it is recommended to use the following options in order to use an ANSI C compiler: ./configure CC="cc -Ae -D_XOPEN_SOURCE=500" and if that doesn't work, install pre-built binaries of GCC for HP-UX. HP-UX `make' updates targets which have the same time stamps as their prerequisites, which makes it generally unusable when shipped generated files such as `configure' are involved. Use GNU `make' instead. On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot parse its `' header file. The option `-nodtk' can be used as a workaround. If GNU CC is not installed, it is therefore recommended to try ./configure CC="cc" and if that doesn't work, try ./configure CC="cc -nodtk" On Solaris, don't put `/usr/ucb' early in your `PATH'. This directory contains several dysfunctional programs; working variants of these programs are available in `/usr/bin'. So, if you need `/usr/ucb' in your `PATH', put it _after_ `/usr/bin'. On Haiku, software installed for all users goes in `/boot/common', not `/usr/local'. It is recommended to use the following options: ./configure --prefix=/boot/common Specifying the System Type ========================== There may be some features `configure' cannot figure out automatically, but needs to determine by the type of machine the package will run on. Usually, assuming the package is built to be run on the _same_ architectures, `configure' can figure that out, but if it prints a message saying it cannot guess the machine type, give it the `--build=TYPE' option. TYPE can either be a short name for the system type, such as `sun4', or a canonical name which has the form: CPU-COMPANY-SYSTEM where SYSTEM can have one of these forms: OS KERNEL-OS See the file `config.sub' for the possible values of each field. If `config.sub' isn't included in this package, then this package doesn't need to know the machine type. If you are _building_ compiler tools for cross-compiling, you should use the option `--target=TYPE' to select the type of system they will produce code for. If you want to _use_ a cross compiler, that generates code for a platform different from the build platform, you should specify the "host" platform (i.e., that on which the generated programs will eventually be run) with `--host=TYPE'. Sharing Defaults ================ If you want to set default values for `configure' scripts to share, you can create a site shell script called `config.site' that gives default values for variables like `CC', `cache_file', and `prefix'. `configure' looks for `PREFIX/share/config.site' if it exists, then `PREFIX/etc/config.site' if it exists. Or, you can set the `CONFIG_SITE' environment variable to the location of the site script. A warning: not all `configure' scripts look for a site script. Defining Variables ================== Variables not defined in a site shell script can be set in the environment passed to `configure'. However, some packages may run configure again during the build, and the customized values of these variables may be lost. In order to avoid this problem, you should set them in the `configure' command line, using `VAR=value'. For example: ./configure CC=/usr/local2/bin/gcc causes the specified `gcc' to be used as the C compiler (unless it is overridden in the site shell script). Unfortunately, this technique does not work for `CONFIG_SHELL' due to an Autoconf limitation. Until the limitation is lifted, you can use this workaround: CONFIG_SHELL=/bin/bash ./configure CONFIG_SHELL=/bin/bash `configure' Invocation ====================== `configure' recognizes the following options to control how it operates. `--help' `-h' Print a summary of all of the options to `configure', and exit. `--help=short' `--help=recursive' Print a summary of the options unique to this package's `configure', and exit. The `short' variant lists options used only in the top level, while the `recursive' variant lists options also present in any nested packages. `--version' `-V' Print the version of Autoconf used to generate the `configure' script, and exit. `--cache-file=FILE' Enable the cache: use and save the results of the tests in FILE, traditionally `config.cache'. FILE defaults to `/dev/null' to disable caching. `--config-cache' `-C' Alias for `--cache-file=config.cache'. `--quiet' `--silent' `-q' Do not print messages saying which checks are being made. To suppress all normal output, redirect it to `/dev/null' (any error messages will still be shown). `--srcdir=DIR' Look for the package's source code in directory DIR. Usually `configure' can determine that directory automatically. `--prefix=DIR' Use DIR as the installation prefix. *note Installation Names:: for more details, including other options available for fine-tuning the installation locations. `--no-create' `-n' Run the configure checks, but stop before creating any output files. `configure' also accepts some other, not widely useful, options. Run `configure --help' for more details. libgrip-0.3.9+15.10.20150729/bindings/0000755000015300001610000000000012556203774017322 5ustar pbuserpbgroup00000000000000libgrip-0.3.9+15.10.20150729/bindings/Makefile.am0000644000015300001610000000002112556203475021345 0ustar pbuserpbgroup00000000000000SUBDIRS = python libgrip-0.3.9+15.10.20150729/bindings/python/0000755000015300001610000000000012556203774020643 5ustar pbuserpbgroup00000000000000libgrip-0.3.9+15.10.20150729/bindings/python/Makefile.am0000644000015300001610000000015112556203475022672 0ustar pbuserpbgroup00000000000000pygioverridesdir = $(PYGI_OVERRIDES_DIR) pygioverrides_PYTHON = \ Grip.py EXTRA_DIST = Grip.py libgrip-0.3.9+15.10.20150729/bindings/python/Grip.py0000644000015300001610000000321612556203475022116 0ustar pbuserpbgroup00000000000000# # Copyright 2010 Canonical, Ltd. # # This program is free software: you can redistribute it and/or modify it # under the terms of either or both of the following licenses: # # 1) the GNU Lesser General Public License version 3, as published by the # Free Software Foundation; and/or # 2) the GNU Lesser General Public License version 2.1, 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 warranties of # MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR # PURPOSE. See the applicable version of the GNU Lesser General Public # License for more details. # # You should have received a copy of both the GNU Lesser General Public # License version 3 and version 2.1 along with this program. If not, see # # # Authors: # Cody Russell # from ..overrides import override from ..importer import modules Grip = modules['Grip']._introspection_module __all__ = [] class GestureEvent(Grip.GestureEvent): _UNION_MEMBERS = { Grip.GestureType.DRAG: 'drag', Grip.GestureType.PINCH: 'pinch', Grip.GestureType.ROTATE: 'rotate', Grip.GestureType.TAP: 'tap' } def __new__(cls, *args, **kwargs): return Grip.GestureEvent.__new__(cls) def __getattr__(self, name): real_event = getattr(self, '_UNION_MEMBERS').get(self.type) if real_event: return getattr(getattr(self, real_event), name) else: return getattr(self, name) GestureEvent = override(GestureEvent) __all__.append('GestureEvent') libgrip-0.3.9+15.10.20150729/ChangeLog0000644000015300001610000000003012556203475017266 0ustar pbuserpbgroup00000000000000# Generated by Makefile libgrip-0.3.9+15.10.20150729/doc/0000755000015300001610000000000012556203774016272 5ustar pbuserpbgroup00000000000000libgrip-0.3.9+15.10.20150729/doc/reference/0000755000015300001610000000000012556203774020230 5ustar pbuserpbgroup00000000000000libgrip-0.3.9+15.10.20150729/doc/reference/libgrip-docs.sgml.in0000644000015300001610000000345712556203475024106 0ustar pbuserpbgroup00000000000000 ]> libgrip Reference Manual for @PACKAGE@ @VERSION@. libgrip Overview The libgrip library provides multi-touch and gesture events to GTK widgets. The libgrip library provides a singleton GripGestureManager that maintains a connection to the gesture recognizer. Any widgets interested in acting on gestures must register one or more callback functions with the GripGestureManager, one per gesture primitive. The widgets will receive data describing the ongoing state of gestures as they occur, and must take appropriate action in the callback function. Programming Interface Object Hierarchy API Index Index of deprecated API libgrip-0.3.9+15.10.20150729/doc/reference/Makefile.am0000644000015300001610000000711012556203475022261 0ustar pbuserpbgroup00000000000000## Process this file with automake to produce Makefile.in # This is a blank Makefile.am for using gtk-doc. # Copy this to your project's API docs directory and modify the variables to # suit your project. See the GTK+ Makefiles in gtk+/docs/reference for examples # of using the various options. # The name of the module, e.g. 'glib'. DOC_MODULE=libgrip # Uncomment for versioned docs and specify the version of the module, e.g. '2'. #DOC_MODULE_VERSION=2 # The top-level SGML file. You can change this if you want to. DOC_MAIN_SGML_FILE=$(DOC_MODULE)-docs.sgml # Directories containing the source code, relative to $(srcdir). # gtk-doc will search all .c and .h files beneath these paths # for inline comments documenting functions and macros. # e.g. DOC_SOURCE_DIR=../../../gtk ../../../gdk DOC_SOURCE_DIR=$(top_srcdir)/src # Extra options to pass to gtkdoc-scangobj. Not normally needed. SCANGOBJ_OPTIONS= # Extra options to supply to gtkdoc-scan. # e.g. SCAN_OPTIONS=--deprecated-guards="GTK_DISABLE_DEPRECATED" #SCAN_OPTIONS=--rebuild-types SCAN_OPTIONS= # Extra options to supply to gtkdoc-mkdb. # e.g. MKDB_OPTIONS=--xml-mode --output-format=xml MKDB_OPTIONS=--xml-mode --output-format=xml # Extra options to supply to gtkdoc-mktmpl # e.g. MKTMPL_OPTIONS=--only-section-tmpl MKTMPL_OPTIONS= # Extra options to supply to gtkdoc-mkhtml MKHTML_OPTIONS= # Extra options to supply to gtkdoc-fixref. Not normally needed. # e.g. FIXXREF_OPTIONS=--extra-dir=../gdk-pixbuf/html --extra-dir=../gdk/html FIXXREF_OPTIONS= # Used for dependencies. The docs will be rebuilt if any of these change. # e.g. HFILE_GLOB=$(top_srcdir)/gtk/*.h # e.g. CFILE_GLOB=$(top_srcdir)/gtk/*.c HFILE_GLOB=$(DOC_SOURCE_DIR)/*.h CFILE_GLOB=$(DOC_SOURCE_DIR)/*.c # Extra header to include when scanning, which are not under DOC_SOURCE_DIR # e.g. EXTRA_HFILES=$(top_srcdir}/contrib/extra.h EXTRA_HFILES= # Header files or dirs to ignore when scanning. Use base file/dir names # e.g. IGNORE_HFILES=gtkdebug.h gtkintl.h private_code IGNORE_HFILES= # Images to copy into HTML directory. # e.g. HTML_IMAGES=$(top_srcdir)/gtk/stock-icons/stock_about_24.png HTML_IMAGES= # Extra SGML files that are included by $(DOC_MAIN_SGML_FILE). # e.g. content_files=running.sgml building.sgml changes-2.0.sgml content_files= # SGML files where gtk-doc abbrevations (#GtkWidget) are expanded # These files must be listed here *and* in content_files # e.g. expand_content_files=running.sgml expand_content_files= # CFLAGS and LDFLAGS for compiling gtkdoc-scangobj with your library. # Only needed if you are using gtkdoc-scangobj to dynamically query widget # signals and properties. # e.g. GTKDOC_CFLAGS=-I$(top_srcdir) -I$(top_builddir) $(GTK_DEBUG_FLAGS) # e.g. GTKDOC_LIBS=$(top_builddir)/gtk/$(gtktargetlib) GTKDOC_CFLAGS=$(GTK_CFLAGS) GTKDOC_LIBS=$(top_builddir)/src/libgrip.la $(GTK_LIBS) # This includes the standard gtk-doc make rules, copied by gtkdocize. include $(top_srcdir)/gtk-doc.make # Other files to distribute # e.g. EXTRA_DIST += version.xml.in EXTRA_DIST += libgrip-docs.sgml.in # Files not to distribute # for --rebuild-types in $(SCAN_OPTIONS), e.g. $(DOC_MODULE).types # for --rebuild-sections in $(SCAN_OPTIONS) e.g. $(DOC_MODULE)-sections.txt #DISTCLEANFILES += # Comment this out if you want 'make check' to test you doc status # and run some sanity checks if ENABLE_GTK_DOC TESTS_ENVIRONMENT = cd $(srcdir) && \ DOC_MODULE=$(DOC_MODULE) DOC_MAIN_SGML_FILE=$(DOC_MAIN_SGML_FILE) \ SRCDIR=$(abs_srcdir) BUILDDIR=$(abs_builddir) #TESTS = $(GTKDOC_CHECK) endif dist-hook-local: gtk-docs-clean all-local gtk-docs-clean: clean -rm -rf xml tmpl html libgrip-0.3.9+15.10.20150729/doc/reference/libgrip-sections.txt0000644000015300001610000000315312556203475024246 0ustar pbuserpbgroup00000000000000
GripGestureManager GripGestureManager GripGestureManager GripGestureManagerClass grip_gesture_manager_get GripGestureCallback grip_gesture_manager_register_window grip_gesture_manager_unregister_window GRIP_TYPE_GESTURE_MANAGER GRIP_GESTURE_MANAGER GRIP_IS_GESTURE_MANAGER GRIP_GESTURE_MANAGER_CLASS GRIP_IS_GESTURE_MANAGER_CLASS GRIP_GESTURE_MANAGER_GET_CLASS GripGestureManagerPrivate grip_gesture_manager_get_type grip_device_type_get_type
GripGestureEvents Gesture Events GripGestureType GripDeviceType GRIP_DEVICE_ALL GripTimeType GripGestureEvent GripEventGestureAny GripEventGestureDrag GripEventGesturePinch GripEventGestureRotate GripEventGestureTap grip_gesture_event_new grip_gesture_event_free grip_gesture_event_copy GRIP_TYPE_GESTURE_TYPE grip_gesture_type_get_type grip_gesture_event_get_type GRIP_TYPE_TIME_TYPE grip_time_type_get_type
GripInputDevice Input Devices GripInputDevice GripInputDeviceClass GRIP_INPUT_DEVICE GRIP_INPUT_DEVICE_CLASS GRIP_INPUT_DEVICE_GET_CLASS GRIP_IS_INPUT_DEVICE GRIP_IS_INPUT_DEVICE_CLASS GRIP_TYPE_DEVICE_TYPE GRIP_TYPE_INPUT_DEVICE grip_input_device_get_id grip_input_device_get_name grip_input_device_is_direct grip_input_device_is_independent grip_input_device_get_x_extents grip_input_device_get_y_extents GripInputDevicePrivate grip_input_device_get_type
libgrip-0.3.9+15.10.20150729/doc/reference/libgrip.types0000644000015300001610000000021012556203475022735 0ustar pbuserpbgroup00000000000000grip_gesture_event_get_type grip_gesture_manager_get_type grip_gesture_type_get_type grip_input_device_get_type grip_time_type_get_type libgrip-0.3.9+15.10.20150729/doc/Makefile.am0000644000015300001610000000002512556203475020321 0ustar pbuserpbgroup00000000000000SUBDIRS = reference