Xxfdga only when available, beginnings of the new tX_mouse.
authorterminatorX <>
Mon, 24 Jan 2011 20:24:42 +0000 (20:24 +0000)
committerterminatorX <>
Mon, 24 Jan 2011 20:24:42 +0000 (20:24 +0000)
.cproject [deleted file]
configure.in
src/tX_engine.cc
src/tX_engine.h
src/tX_mastergui.cc
src/tX_mastergui.h
src/tX_mouse.cc
src/tX_mouse.h

diff --git a/.cproject b/.cproject
deleted file mode 100644 (file)
index 200ea3e..0000000
--- a/.cproject
+++ /dev/null
@@ -1,146 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<?fileVersion 4.0.0?>
-
-<cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
-<storageModule moduleId="org.eclipse.cdt.core.settings">
-<cconfiguration id="cdt.managedbuild.toolchain.gnu.base.1196139106">
-<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.toolchain.gnu.base.1196139106" moduleId="org.eclipse.cdt.core.settings" name="Default">
-<externalSettings/>
-<extensions>
-<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
-<extension id="org.eclipse.cdt.core.MakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
-<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
-<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
-<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
-</extensions>
-</storageModule>
-<storageModule moduleId="org.eclipse.cdt.core.pathentry"/>
-<storageModule moduleId="cdtBuildSystem" version="4.0.0">
-<configuration artifactName="terminatorX" buildProperties="" description="" id="cdt.managedbuild.toolchain.gnu.base.1196139106" name="Default" parent="org.eclipse.cdt.build.core.emptycfg">
-<folderInfo id="cdt.managedbuild.toolchain.gnu.base.1196139106.758771092" name="/" resourcePath="">
-<toolChain id="cdt.managedbuild.toolchain.gnu.base.1552158893" name="cdt.managedbuild.toolchain.gnu.base" superClass="cdt.managedbuild.toolchain.gnu.base">
-<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="cdt.managedbuild.target.gnu.platform.base.346223634" name="Debug Platform" osList="linux,hpux,aix,qnx" superClass="cdt.managedbuild.target.gnu.platform.base"/>
-<builder enableAutoBuild="true" id="cdt.managedbuild.target.gnu.builder.base.1348478782" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" parallelBuildOn="true" parallelizationNumber="3" superClass="cdt.managedbuild.target.gnu.builder.base"/>
-<tool id="cdt.managedbuild.tool.gnu.archiver.base.547009251" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/>
-<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.base.571220339" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.base">
-<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1848654247" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
-</tool>
-<tool id="cdt.managedbuild.tool.gnu.c.compiler.base.1817770539" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.base">
-<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.633270653" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
-</tool>
-<tool id="cdt.managedbuild.tool.gnu.c.linker.base.427780411" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.base"/>
-<tool id="cdt.managedbuild.tool.gnu.cpp.linker.base.695882077" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.base">
-<inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.1094970930" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
-<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
-<additionalInput kind="additionalinput" paths="$(LIBS)"/>
-</inputType>
-</tool>
-<tool id="cdt.managedbuild.tool.gnu.assembler.base.620242037" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.base">
-<inputType id="cdt.managedbuild.tool.gnu.assembler.input.1227953928" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
-</tool>
-</toolChain>
-</folderInfo>
-</configuration>
-</storageModule>
-<storageModule moduleId="scannerConfiguration">
-<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile"/>
-<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
-<buildOutputProvider>
-<openAction enabled="true" filePath=""/>
-<parser enabled="true"/>
-</buildOutputProvider>
-<scannerInfoProvider id="specsFile">
-<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
-<parser enabled="true"/>
-</scannerInfoProvider>
-</profile>
-<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile">
-<buildOutputProvider>
-<openAction enabled="true" filePath=""/>
-<parser enabled="true"/>
-</buildOutputProvider>
-<scannerInfoProvider id="makefileGenerator">
-<runAction arguments="-f ${project_name}_scd.mk" command="make" useDefault="true"/>
-<parser enabled="true"/>
-</scannerInfoProvider>
-</profile>
-<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
-<buildOutputProvider>
-<openAction enabled="true" filePath=""/>
-<parser enabled="true"/>
-</buildOutputProvider>
-<scannerInfoProvider id="specsFile">
-<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
-<parser enabled="true"/>
-</scannerInfoProvider>
-</profile>
-<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP">
-<buildOutputProvider>
-<openAction enabled="true" filePath=""/>
-<parser enabled="true"/>
-</buildOutputProvider>
-<scannerInfoProvider id="specsFile">
-<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
-<parser enabled="true"/>
-</scannerInfoProvider>
-</profile>
-<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC">
-<buildOutputProvider>
-<openAction enabled="true" filePath=""/>
-<parser enabled="true"/>
-</buildOutputProvider>
-<scannerInfoProvider id="specsFile">
-<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
-<parser enabled="true"/>
-</scannerInfoProvider>
-</profile>
-<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile">
-<buildOutputProvider>
-<openAction enabled="true" filePath=""/>
-<parser enabled="true"/>
-</buildOutputProvider>
-<scannerInfoProvider id="specsFile">
-<runAction arguments="-c 'gcc -E -P -v -dD &quot;${plugin_state_location}/${specs_file}&quot;'" command="sh" useDefault="true"/>
-<parser enabled="true"/>
-</scannerInfoProvider>
-</profile>
-<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP">
-<buildOutputProvider>
-<openAction enabled="true" filePath=""/>
-<parser enabled="true"/>
-</buildOutputProvider>
-<scannerInfoProvider id="specsFile">
-<runAction arguments="-c 'g++ -E -P -v -dD &quot;${plugin_state_location}/specs.cpp&quot;'" command="sh" useDefault="true"/>
-<parser enabled="true"/>
-</scannerInfoProvider>
-</profile>
-<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC">
-<buildOutputProvider>
-<openAction enabled="true" filePath=""/>
-<parser enabled="true"/>
-</buildOutputProvider>
-<scannerInfoProvider id="specsFile">
-<runAction arguments="-c 'gcc -E -P -v -dD &quot;${plugin_state_location}/specs.c&quot;'" command="sh" useDefault="true"/>
-<parser enabled="true"/>
-</scannerInfoProvider>
-</profile>
-</storageModule>
-<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
-<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets">
-<buildTargets>
-<target name="all" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
-<buildCommand>make</buildCommand>
-<buildArguments/>
-<buildTarget>all</buildTarget>
-<stopOnError>true</stopOnError>
-<useDefaultCommand>true</useDefaultCommand>
-<runAllBuilders>true</runAllBuilders>
-</target>
-</buildTargets>
-</storageModule>
-</cconfiguration>
-</storageModule>
-<storageModule moduleId="cdtBuildSystem" version="4.0.0">
-<project id="terminatorX.null.250977219" name="terminatorX"/>
-</storageModule>
-</cproject>
index 8fe66d1ca437661ff38de7e26aecbb5824e654d0..b3793b3214c13da7a13d6c30992f5a4bc5cbbbd4 100644 (file)
@@ -219,6 +219,16 @@ if test "$enable_mad" != "no"; then
        fi
 fi
 
+AC_CHECK_HEADERS(X11/extensions/Xxf86dga.h,newDgaHeader=yes,newDgaHeader=no, [#include <X11/Xlib.h>])
+
+if test "$newDgaHeader" = "no"; then
+       AC_CHECK_HEADERS(X11/extensions/xf86dga.h,oldDgaHeader=yes,oldDgaHeader=no, [#include <X11/Xlib.h>])
+       
+       if test "$oldDgaHeader" = "no"; then
+               AC_MSG_ERROR([** couldn't find xf86dga.h header - Install X11 headers first. **])
+       fi
+fi
+
 if test "$enable_vorbis" != "no"; then
        AC_CHECK_HEADERS(vorbis/codec.h vorbis/vorbisfile.h,vorbis_headers=yes,vorbis_headers="no")
        if test "$vorbis_headers" = "yes"; then
index 5ef589803e0c92a7b87460aa31621289768ef6fc..00add7e680dc7f1f7638e5c70e71f6da76963d7a 100644 (file)
@@ -66,42 +66,7 @@ tX_engine *tX_engine::get_instance() {
        return engine;
 }
 
-void tX_engine::set_grab_request() {
-       grab_request=true;
-}
-
 int16_t* tX_engine::render_cycle() {
-       /* Checking whether to grab or not  */
-       if (grab_request!=grab_active) {
-               if (grab_request) {
-                       /* Activating grab... */
-                       int result=mouse->grab(); 
-                       if (result!=0) {
-                               tX_error("tX_engine::render_cycle(): failed to grab mouse - error %i", result);
-                               grab_active=false;
-                               /* Reseting grab_request, too - doesn't help keeping it, does it ? ;) */
-                               grab_request=false;
-                               mouse->ungrab();
-                               grab_off();
-                       } else {
-                               grab_active=true;
-                       }
-               } else {
-                       /* Deactivating grab... */
-                       mouse->ungrab();
-                       grab_active=false;
-                       grab_off();
-               }
-       }
-
-       /* Handling input events... */
-       if (grab_active) {
-               if (mouse->check_event()) {
-                       /* If we're here the user pressed ESC */
-                       grab_request=false;
-               }
-       }
-
        /* Forward the sequencer... */
        sequencer.step();
 
@@ -161,11 +126,11 @@ void tX_engine::loop() {
 
                // in case we got kicked out by jack we might have
                // to kill the mouse grab
-               if (grab_active) {
+/*             if (grab_active) {
                        mouse->ungrab();
                        grab_active=false;
                        grab_off();
-               }
+               } */
                
                if (!stop_flag) {
                        runtime_error=true;
@@ -235,7 +200,6 @@ tX_engine :: tX_engine() {
                exit(1);
        }
        
-       mouse=new tx_mouse();
 #ifdef USE_ALSA_MIDI_IN        
        midi=new tX_midiin();
 #endif 
@@ -245,8 +209,6 @@ tX_engine :: tX_engine() {
        recording=false;
        recording_request=false;
        loop_is_active=false;
-       grab_request=false;
-       grab_active=false;
 }
 
 void tX_engine :: set_recording_request (bool recording) {
@@ -362,7 +324,6 @@ tX_engine :: ~tX_engine() {
        tX_debug("~tX_engine() - Waiting for engine thread to terminate.");
        pthread_join(thread, &dummy);   
        
-       delete mouse;
 #ifdef USE_ALSA_MIDI_IN                
        delete midi;
 #endif 
index c543126037bf8b8d423a3aa37b0bea3dd7cf0880..b46799c355407b25431ebc14ef1b27508065d74c 100644 (file)
@@ -25,7 +25,6 @@
 #define _TX_ENGINE_H_
 
 #include "tX_tape.h"
-#include "tX_mouse.h"
 #include "tX_audiodevice.h"
 #include "tX_midiin.h"
 #include <sys/types.h>
@@ -41,8 +40,8 @@
 #define ENG_ERR_DGA 6
 #define ENG_ERR_SOUND 7
 #define ENG_ERR_THREAD 8
-#define ENG_ERR_GRABMOUSE 9
-#define ENG_ERR_GRABKEY 10
+/* #define ENG_ERR_GRABMOUSE 9
+   #define ENG_ERR_GRABKEY 10 */
 #define ENG_ERR_BUSY 11
 
 #include <pthread.h>
@@ -65,15 +64,14 @@ class tX_engine {
        pthread_t thread;
        pthread_mutex_t start;
        bool thread_terminate;
-       tx_mouse *mouse;
        tX_audiodevice *device;
        tx_tapedeck *tape;
        bool recording;
        bool recording_request;
        bool stop_flag;
        bool loop_is_active;
-       bool grab_request;
-       bool grab_active;
+/*     bool grab_request;
+       bool grab_active; */
        bool runtime_error;
        bool overload_error;
        int cycles_ctr;
@@ -102,7 +100,7 @@ class tX_engine {
        bool is_recording() { return recording; }
        int16_t* render_cycle();
        
-       void set_grab_request();
+/*     void set_grab_request(); */
        bool is_stopped() { return stop_flag; }
 };
 #endif
index 36c89efb81cccf7c42986b850f9eb0877bd6a647..8380f10eaceb919a725f907782ed1ba88befaaef 100644 (file)
@@ -47,6 +47,7 @@
 #include <sys/time.h>
 #include <sys/wait.h>
 #include "tX_midiin.h"
+#include "tX_mouse.h"
 
 #ifdef USE_SCHEDULER
 #include <sys/resource.h>
@@ -62,6 +63,7 @@ int audioon=0;
 int sequencer_ready=1;
 
 bool tX_shutdown=false;
+tx_mouse mouse;
 
 GtkWidget *tt_parent;
 GtkWidget *control_parent;
@@ -103,7 +105,8 @@ gint update_tag;
 #define connect_adj(wid, func, ptr); g_signal_connect(G_OBJECT(wid), "value_changed", (GtkSignalFunc) func, (void *) ptr);
 #define connect_button(wid, func, ptr); g_signal_connect(G_OBJECT(wid), "clicked", (GtkSignalFunc) func, (void *) ptr);
 
-Window xwindow;
+Window x_window;
+GdkWindow* top_window;
 #define WID_DYN TRUE, TRUE, 0
 #define WID_FIX FALSE, FALSE, 0
 extern void add_vtt(GtkWidget *ctrl, GtkWidget *audio, char *fn);
@@ -868,7 +871,10 @@ GtkSignalFunc tape_on(GtkWidget *w, void *d)
 void grab_on(GtkWidget *w, void *d)
 {
        if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w))) {
-               tX_engine::get_instance()->set_grab_request();
+               if (mouse.grab() != 0) {
+                       //tX_engine::get_instance()->set_grab_request();
+                       // TODO: handle error
+               }
        }
        grab_status=1;
 }
@@ -1401,10 +1407,6 @@ void create_master_menu()
        g_signal_connect(menu_item, "activate", (GCallback) display_browser, NULL);
 }
 
-void motion_notify(GtkWidget *widget, GdkEventMotion *eventMotion) {
-       printf("Move: %lf, %lf\n", eventMotion->x, eventMotion->y);
-}
-
 void create_mastergui(int x, int y)
 {
        GtkWidget *mother_of_all_boxen;
@@ -1429,7 +1431,12 @@ void create_mastergui(int x, int y)
 
        gtk_widget_realize(main_window);
        
-//     g_signal_connect(G_OBJECT(main_window), "motion_notify_event", G_CALLBACK(motion_notify), NULL);
+       g_signal_connect(G_OBJECT(main_window), "motion_notify_event", G_CALLBACK(tx_mouse::motion_notify_wrap), &mouse);
+       g_signal_connect(G_OBJECT(main_window), "button_press_event", G_CALLBACK(tx_mouse::button_press_wrap), &mouse);
+       g_signal_connect(G_OBJECT(main_window), "button_release_event", G_CALLBACK(tx_mouse::button_release_wrap), &mouse);
+       g_signal_connect(G_OBJECT(main_window), "key_press_event", G_CALLBACK(tx_mouse::key_press_wrap), &mouse);
+       g_signal_connect(G_OBJECT(main_window), "key_release_event", G_CALLBACK(tx_mouse::key_release_wrap), &mouse);
+
 
        wrapbox=gtk_vbox_new(FALSE, 5);
        gtk_container_add(GTK_CONTAINER(main_window), wrapbox);
@@ -1792,7 +1799,8 @@ void display_mastergui()
        gtk_widget_show(main_window);
        fullscreen_setup();     
        top=gtk_widget_get_toplevel(main_window);
-       xwindow=GDK_WINDOW_XWINDOW(top->window);
+       top_window=GDK_WINDOW(top->window);
+       x_window=GDK_WINDOW_XWINDOW(top->window);
 }
 
 pid_t help_child=0;
index cacc157fd7539e6748a549b91fd3cbfe2016ac9e..ec4ab7c91d61561c0dc6017142d2298560b40caf 100644 (file)
@@ -30,7 +30,9 @@
 #include "tX_seqpar.h"
 
 extern int audioon;
-extern Window xwindow;
+extern Window x_window;
+extern GdkWindow* top_window;
+
 extern GtkWidget *main_window;
 
 extern GtkAdjustment *volume_adj;
index 05bfee374facbf258b9e2bec861223cb21b618a7..c23f377e6d579c21ab6934c087f540f0c17c3dbd 100644 (file)
 
 #include <sys/wait.h>
 #include <X11/Xlib.h>
+
+#include <config.h>
+
+#ifdef HAVE_X11_EXTENSIONS_XXF86DGA_H
 #include <X11/extensions/Xxf86dga.h>
+#endif
+
+#ifdef HAVE_X11_EXTENSIONS_XF86DGA_H
+#include <X11/extensions/xf86dga.h>
+#endif
+
+#include <gdk/gdkx.h>
+#include <gtk/gtk.h>
 
 #include "tX_mouse.h"
 #include "tX_mastergui.h"
@@ -60,12 +72,13 @@ int tx_mouse :: grab()
        XDGAMode *mode;
 #endif 
 
-       if (grabbed) return(0);
+       if (grabbed) return 0;
 
        warp_override=false;
-       
-       dpy=XOpenDisplay(NULL);
-       if (!dpy) {
+       dpy = gdk_x11_get_default_xdisplay();
+//     GdkDisplay* gdk_dpy = gdk_display_get_default();
+
+       if (!dpy/* && !gdk_dpy*/) {
                fputs("GrabMode Error: couldn't connect to XDisplay.", stderr);
                return(ENG_ERR_XOPEN);
        }
@@ -80,47 +93,55 @@ int tx_mouse :: grab()
        }
        XFree(mode);
 #endif 
-                               
-       XSelectInput(dpy, xwindow, mask);       
 
-       XSetInputFocus(dpy, xwindow, None, CurrentTime);
+       savedEventMask = gdk_window_get_events(top_window);
+       GdkEventMask newEventMask = GdkEventMask (GDK_POINTER_MOTION_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_BUTTON_RELEASE_MASK | GDK_BUTTON_RELEASE_MASK);
+       gdk_window_set_events(top_window, newEventMask);
+       gtk_window_present(GTK_WINDOW(main_window));
+
+//     if (globals.xinput_enable) {
+//             if (set_xinput()) {
+//                     XCloseDisplay(dpy);
+//                     fputs("GrabMode Error: failed to setup XInput.", stderr);
+//                     return(ENG_ERR_XINPUT);
+//             }
+//     }
 
-       if (globals.xinput_enable) {
-               if (set_xinput()) {
-                       XCloseDisplay(dpy);
-                       fputs("GrabMode Error: failed to setup XInput.", stderr);
-                       return(ENG_ERR_XINPUT);
-               }
-       }
 
-       if (GrabSuccess != XGrabPointer(dpy, xwindow, False, ButtonPressMask|ButtonReleaseMask|PointerMotionMask, GrabModeAsync,GrabModeAsync,None,None,CurrentTime)) {
-               reset_xinput();
-               XCloseDisplay(dpy);
-               fputs("GrabMode Error: XGrabPointer failed.", stderr);
-               return(ENG_ERR_GRABMOUSE);
+       GdkGrabStatus grab_status =gdk_pointer_grab(top_window, FALSE, GdkEventMask (GDK_POINTER_MOTION_MASK | GDK_BUTTON_RELEASE_MASK | GDK_BUTTON_RELEASE_MASK), NULL, NULL, GDK_CURRENT_TIME);
+
+       if (grab_status != GDK_GRAB_SUCCESS) {
+               //reset_xinput();
+               //XCloseDisplay(dpy);
+               //fputs("GrabMode Error: XGrabPointer failed.", stderr);
+               return(-1);
        }       
        
-       if (GrabSuccess != XGrabKeyboard(dpy, xwindow, False, GrabModeAsync,GrabModeAsync,CurrentTime)) {
-               XUngrabPointer (dpy, CurrentTime);
-               reset_xinput();         
-               XCloseDisplay(dpy);
-               fputs("GrabMode Error: XGrabKeyboard failed.", stderr);
-               return(ENG_ERR_GRABKEY);
+       grab_status = gdk_keyboard_grab(top_window, FALSE, GDK_CURRENT_TIME);
+
+       if (grab_status != GDK_GRAB_SUCCESS) {
+               GdkDisplay* display = gdk_display_get_default();
+               gdk_display_pointer_ungrab(display, GDK_CURRENT_TIME);
+               //XUngrabPointer (dpy, CurrentTime);
+               //reset_xinput();
+               //XCloseDisplay(dpy);
+               //fputs("GrabMode Error: XGrabKeyboard failed.", stderr);
+               return(-2);
        }
        
 
 #ifdef USE_DGA2
        if (!XDGASetMode(dpy, DefaultScreen(dpy), 1)) {
 #else  
-       if (!XF86DGADirectVideo(dpy,DefaultScreen(dpy),XF86DGADirectMouse)) {
+//     if (!XF86DGADirectVideo(dpy,DefaultScreen(dpy),XF86DGADirectMouse)) {
 #endif
-               XUngrabKeyboard(dpy, CurrentTime);                              
-               XUngrabPointer (dpy, CurrentTime);
-               reset_xinput();         
-               XCloseDisplay(dpy);
-               fputs("GrabMode Error: Failed to enable XF86DGA.", stderr);             
-               return(ENG_ERR_DGA);
-       }
+//             XUngrabKeyboard(dpy, CurrentTime);
+//             XUngrabPointer (dpy, CurrentTime);
+//             reset_xinput();
+//             XCloseDisplay(dpy);
+//             fputs("GrabMode Error: Failed to enable XF86DGA.", stderr);
+//             return(ENG_ERR_DGA);
+//     }
 
 #ifdef USE_DGA2
        XDGASelectInput(dpy, DefaultScreen(dpy), mask);
@@ -157,15 +178,15 @@ void tx_mouse :: ungrab()
 #ifdef USE_DGA2        
        XDGASetMode(dpy, DefaultScreen(dpy), 0);
 #else
-       XF86DGADirectVideo(dpy,DefaultScreen(dpy),0);
+//     XF86DGADirectVideo(dpy,DefaultScreen(dpy),0);
 #endif 
 
-       XUngrabKeyboard(dpy, CurrentTime);              
-       XUngrabPointer (dpy, CurrentTime);
+       GdkDisplay *gdk_dpy = gdk_display_get_default();
+       gdk_display_keyboard_ungrab(gdk_dpy, GDK_CURRENT_TIME);
+       gdk_display_pointer_ungrab(gdk_dpy, GDK_CURRENT_TIME);
+
        XAutoRepeatOn(dpy);
        
-       XCloseDisplay(dpy);
-
        if (globals.xinput_enable) {
                reset_xinput(); 
        }
@@ -269,9 +290,83 @@ void tx_mouse :: reset_xinput()
 
 #define vtt vtt_class::focused_vtt
 
+
+void tx_mouse::motion_notify(GtkWidget *widget, GdkEventMotion *eventMotion) {
+       //eventMotion->x_root, eventMotion->y_root
+       if (vtt) {
+               if (warp_override) {
+                       f_prec value=(abs(eventMotion->x_root)>abs(eventMotion->y_root)) ? eventMotion->x_root : eventMotion->y_root;
+                       vtt->sp_speed.handle_mouse_input(value*globals.mouse_speed*warp);
+               } else {
+                       vtt->xy_input((f_prec) eventMotion->x_root*warp, (f_prec) eventMotion->y_root*warp);
+               }
+       }
+}
+
+void tx_mouse::button_press(GtkWidget *widget, GdkEventButton *eventButton) {
+       if (vtt) {
+               switch(eventButton->button) {
+                       case 1: if (vtt->is_playing)
+                                       vtt->set_scratch(1);
+                               else
+                                       vtt->sp_trigger.receive_input_value(1);
+                               break;
+                       case 2: vtt->sp_mute.receive_input_value(1); break;
+                       case 3: vtt_class::focus_next(); break;
+               }
+       }
+}
+
+void tx_mouse::button_release(GtkWidget *widget, GdkEventButton *eventButton) {
+       if (vtt) {
+               switch (eventButton->button) {
+                       case 1: vtt->set_scratch(0); break;
+                       case 2: vtt->sp_mute.receive_input_value(0); break;
+               }
+       }
+}
+
+void tx_mouse::key_press(GtkWidget *widget, GdkEventKey *eventKey) {
+       if (vtt) {
+       }
+
+}
+
+void tx_mouse::key_release(GtkWidget *widget, GdkEventKey *eventKey) {
+       if (vtt) {
+
+       }
+
+}
+
+void tx_mouse::motion_notify_wrap(GtkWidget *widget, GdkEventMotion *eventMotion, void *data) {
+       tx_mouse* mouse = (tx_mouse *) data;
+       mouse->motion_notify(widget, eventMotion);
+}
+
+void tx_mouse::button_press_wrap(GtkWidget *widget, GdkEventButton *eventButton, void *data) {
+       tx_mouse* mouse = (tx_mouse *) data;
+       mouse->button_press(widget, eventButton);
+}
+
+void tx_mouse::button_release_wrap(GtkWidget *widget, GdkEventButton *eventButton, void *data) {
+       tx_mouse* mouse = (tx_mouse *) data;
+       mouse->button_release(widget, eventButton);
+}
+
+void tx_mouse::key_press_wrap(GtkWidget *widget, GdkEventKey *eventKey, void *data) {
+       tx_mouse* mouse = (tx_mouse *) data;
+       mouse->key_press(widget, eventKey);
+}
+
+void tx_mouse::key_release_wrap(GtkWidget *widget, GdkEventKey *eventKey, void *data) {
+       tx_mouse* mouse = (tx_mouse *) data;
+       mouse->key_release(widget, eventKey);
+}
+
 int tx_mouse :: check_event()
 {
-       if (XCheckWindowEvent(dpy, xwindow, mask, &xev) && vtt) {
+       if (XCheckWindowEvent(dpy, x_window, mask, &xev) && vtt) {
 #ifdef USE_DGA2
                puts("Got an event");
 #endif         
index d7a176a499cf7fa73d002ae9a0bf321c7c5bad28..7686c92df66a2be11a18d931ad4f9b73ec2248a4 100644 (file)
@@ -47,6 +47,7 @@ class tx_mouse
        XKeyEvent *xkey;
        XButtonEvent *xbut;
        bool warp_override;
+       GdkEventMask savedEventMask;
 
 #ifdef USE_DGA2        
        XEvent xev_copy;
@@ -73,6 +74,18 @@ class tx_mouse
        void ungrab();
        tx_mouse();
        
+       void motion_notify(GtkWidget *widget, GdkEventMotion *eventMotion);
+       void button_press(GtkWidget *widget, GdkEventButton *eventButton);
+       void button_release(GtkWidget *widget, GdkEventButton *eventButton);
+       void key_press(GtkWidget *widget, GdkEventKey *eventKey);
+       void key_release(GtkWidget *widget, GdkEventKey *eventKey);
+
+       static void motion_notify_wrap(GtkWidget *widget, GdkEventMotion *eventMotion, void *data);
+       static void button_press_wrap(GtkWidget *widget, GdkEventButton *eventButton, void *data);
+       static void button_release_wrap(GtkWidget *widget, GdkEventButton *eventButton, void *data);
+       static void key_press_wrap(GtkWidget *widget, GdkEventKey *eventKey, void *data);
+       static void key_release_wrap(GtkWidget *widget, GdkEventKey *eventKey, void *data);
+
        private:
        void set_x_pointer(char*);
 };