Date:2010-02-25 10:57:05 (10 years 5 months ago)
Author:Mirko Lindner
Commit:d1a53711e7ce1451aea44ee75dfd52df9376510c
Message:rest of development stuff

Signed-off-by: Mirko Lindner <mirko@sharism.cc>
Files: src/main_window.cc (8 diffs)
src/main_window.hh (1 diff)
src/vido.cc (3 diffs)

Change Details

src/main_window.cc
3535// }
3636
3737log_define("vido.main_window");
38
38int x=-1, y=-1;
39int ctrl_state;
3940main_window::main_window()
4041{
4142    sigc::connection press_id;
...... 
4546
4647void main_window::connect_all()
4748{
48// (*this).add_events( Gdk::BUTTON_PRESS_MASK ) ;
49        (*this).add_events( Gdk::ALL_EVENTS_MASK ) ;
4950        log_debug("connecting all");
5051// (*this).press_id = signal_key_press_event().connect(sigc::mem_fun(*this,&main_window::on_my_key_press_event));
5152// (*this).release_id = signal_key_release_event().connect(sigc::mem_fun(*this,&main_window::on_my_key_release_event));
5253// (*this).press_id =
53
54        (*this).add_events (Gdk::ALL_EVENTS_MASK);
55
5654        (*this).press_id = (*this).signal_key_press_event().connect_notify(sigc::mem_fun(*this,&main_window::on_notify_key_press_event));
5755    (*this).release_id = (*this).signal_key_release_event().connect_notify(sigc::mem_fun(*this,&main_window::on_notify_key_release_event));
58// (*this).motion_id = (*this).signal_event().connect_notify(sigc::mem_fun(*this,&main_window::on_notify_motion_notify_event));
56        (*this).motion_id = (*this).signal_event().connect_notify(sigc::mem_fun(*this,&main_window::motion_notify_event));
5957        log_debug((*this).press_id << " " << (*this).release_id);
60        log_debug("event mask " << (*this).get_events());
6158}
6259
6360void main_window::disconnect_all()
...... 
6865        log_debug((*this).press_id << " " << (*this).release_id);
6966}
7067
71void main_window::on_notify_motion_notify_event ( GdkEvent *event)
68void main_window::motion_notify_event ( GdkEvent *event)
7269{
7370// gdouble x, y;
7471// gdouble pressure;
...... 
9592
9693void main_window::move_cursor(int direction){
9794
98        int x=0, y=0, xadd=0, yadd=0;
95        int xadd=0, yadd=0;
9996    Glib::RefPtr<Gdk::Display> display;
100        display = display->get_default();
101    Glib::RefPtr<Gdk::Screen> screen = display->get_default_screen();
102// screen = display->get_default_screen();
97// display = display->get_default();
98    Glib::RefPtr<Gdk::Screen> screen = this->get_screen();
99        display = screen->get_display();
103100   log_debug("display: " << display);
104101     log_debug("screen: " << screen);
105102    /* check for up/down/left/right arrow key press */
...... 
161158// log_debug("unknown direction 6");
162159
163160// Gdk::ModifierType mask;
164    display->get_pointer(x, y, mask);
165// log_debug("pointer x: " << x << "pointer y: " << display->pointer_hooks);
161// if ((x==-1) && (y==-1)){
162            display->get_pointer(x, y, mask);
163// }
164
165        log_debug("pointer x: " << x << "pointer y: " << y );
166166
167167// display->warp_pointer( screen, x, y);
168168
169// Gdk::Event event();
170
171// Gdk::Event event(gdk_event_new(GDK_MOTION_NOTIFY),true);
172//
169        GdkEvent *event1 = display->peek_event();
170        if (event1 != NULL){
171            log_debug("event type: " << event1->type);
172        }else{
173            log_debug("no event");
174        }
175
176
173177// // get_window_and_coordinates(event->button.window, event->button.x, event->button.y, event->button.x_root, event->button.y_root);
174// event.send_event = TRUE;
175// event.time = GDK_CURRENT_TIME;
176// event.axes = 0;
177// event.state = 0;
178// event.motion.x = x;
179// event.motion.y = y;
178// GdkEventType type;
179// GdkWindow *window;
180// gint8 send_event;
181// guint32 time;
182// gdouble x;
183// gdouble y;
184// gdouble *axes;
185// guint state;
186// gint16 is_hint;
187// GdkDevice *device;
188// gdouble x_root, y_root;
189
190// event->type = Gdk::MOTION_NOTIFY;
191
192
193// event.y = y;
180194// /* set new cusor position */
195
196
181197    x += xadd;
182198    y += yadd;
183// event.motion.x_root = x;
184// event.motion.y_root = y;
185199// // event->button.button = Button;
186200// // event->button.device = gdk_device_get_core_pointer();
187201//
...... 
189203// event.put();
190204// handle_pending_events();
191205// gdk_event_free(event);
192        Glib::RefPtr<Gdk::Device> pointer = display->get_core_pointer();
193        log_debug("type cursor: " << pointer->get_source());
206// Glib::RefPtr<Gdk::Device> pointer = display->get_core_pointer();
207// log_debug("type cursor: " << pointer->type);
194208        log_debug("pointer xadd: " << xadd << "pointer yadd: " << yadd );
195209    if ((screen != 0) && (display!= 0)){
196210            display->warp_pointer( screen, x, y);
211// GdkEvent *event = gdk_event_new(GDK_MOTION_NOTIFY);
212// Glib::RefPtr<Gdk::Window> window = display->get_window_at_pointer(x, y);
213// Glib::RefPtr<Gdk::Device> pointer = display->get_core_pointer ();
214// event->motion.window = window->gobj();
215// event->motion.send_event = 1;
216// event->motion.time = GDK_CURRENT_TIME;
217// event->motion.x = xadd;
218// event->motion.y = yadd;
219// event->motion.axes = 0;
220// event->motion.state = 0;
221// event->motion.is_hint = 0;
222// event->motion.device = pointer->gobj();
223// event->motion.x_root = xadd;
224// event->motion.y_root = yadd;
225// display->put_event(event);
197226// this->signal_motion_notify_event();
198// g_signal_emit (G_OBJECT(display->gobj()), GDK_MOTION_NOTIFY, NULL, x= x, y = y);
199
200227        }
201228}
202229
203230bool main_window::actions(int key)
204231{
205// log_debug("in actions" << (*this).press_id << " " << (*this).release_id);
232        log_debug("in actions " << (*this).press_id << " " << (*this).release_id << "control state " << ctrl_state);
206233    static int key_b = 98;
207234    static int key_f = 102;
208235    static int key_h = 104;
...... 
228255                }
229256                else if(key == key_r)
230257                {
231// log_debug("random");
258                        log_debug("random");
232259                        show_random();
233260                }
234261                else if(key == key_s)
...... 
272299void main_window::on_notify_key_press_event(GdkEventKey *Key)
273300{
274301
275    if (Key->keyval == gdk_keyval_from_name("Control_R"))
302    if (Key->keyval == 65508)
276303    {
304                log_debug("setting ctrl state 1");
277305        ctrl_state = 1;
278306    }
279307    else
280308    {
281            actions(Key->keyval);
309            (*this).actions(Key->keyval);
282310    }
283311    log_debug("Key Presssed is " << Key->keyval);
284312}
285313
286314void main_window::on_notify_key_release_event(GdkEventKey *Key)
287315{
288    if (Key->keyval == gdk_keyval_from_name("Control_R"))
316    if (Key->keyval == 65508)
289317    {
290        ctrl_state = 0;
318        log_debug("setting ctrl state 0");
319                ctrl_state = 0;
291320    }
292321
293322}
src/main_window.hh
2929      main_window();
3030            sigc::connection press_id;
3131            sigc::connection release_id;
32            sigc::connection motion_id;
3233            void connect_all();
3334            void disconnect_all();
3435
3536    private:
3637      bool actions(int);
3738      int ctrl_state;
39            void move_cursor(int direction);
3840// bool on_my_key_press_event(GdkEventKey *event);
3941            void on_notify_key_press_event(GdkEventKey *event);
4042            void on_notify_key_release_event(GdkEventKey *event);
43            void motion_notify_event(GdkEvent *event);
4144// bool on_my_key_release_event(GdkEventKey *event);
4245      bool quit();
4346};
src/vido.cc
438438    return true;
439439}
440440
441void motion( GdkEventMotion *event)
442{
443  log_debug("motion");
444}
445
441446bool scrolled(GtkHTML *cb_html, GtkOrientation orientation, GtkScrollType scroll_type, gfloat position)
442447{
443448  log_debug("scrolled");
...... 
461466      Gtk::Main kit(argc, argv);
462467
463468      main_window window;
469            window.add_modal_grab();
464470      window.set_title("Vido");
465471  // window.set_border_width(0);
466472      window.set_default_size(220, 240);
...... 
473479      g_signal_connect( G_OBJECT( html_wg ), "scroll", G_CALLBACK( scrolled ), NULL );
474480      gtk_html_set_caret_mode(GTK_HTML(html_wg),false);
475481// gtk_html_adjust_cursor_position(GTK_HTML(html_wg));
482            gtk_widget_set_events(html_wg, 0x3FFFFE);
483            gtk_signal_connect (GTK_OBJECT (html_wg), "motion_notify_event",
484                        GTK_SIGNAL_FUNC (motion), NULL);
476485      Gtk::ScrolledWindow scrolled_window;
477486            scrolled_window2 = &scrolled_window;
487            scrolled_window.set_resize_mode(Gtk::RESIZE_PARENT);
478488      scrolled_window.add(*html);
479489      scrolled_window.set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
480490

Archive Download the corresponding diff file

Branches:
development
master



interactive