Date:2010-02-25 10:34:04 (10 years 5 months ago)
Author:Mirko Lindner
Commit:8f2d9951e0e1916e601855f749489480cf0588d7
Message: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 (5 diffs)

Change Details

src/main_window.cc
2828#include "vido.hh"
2929#include <cxxtools/log.h>
3030
31// extern "C" {
32// #include <directfb/directfb.h>
33// #include <gtk-2.0/gdk/gdkdisplay-directfb.h>
34// #include <gtk-2.0/gdk/gdkdirectfb.h>
35// }
36
3137log_define("vido.main_window");
3238
3339main_window::main_window()
...... 
3945
4046void main_window::connect_all()
4147{
42        (*this).add_events( Gdk::BUTTON_PRESS_MASK ) ;
48// (*this).add_events( Gdk::BUTTON_PRESS_MASK ) ;
4349        log_debug("connecting all");
4450// (*this).press_id = signal_key_press_event().connect(sigc::mem_fun(*this,&main_window::on_my_key_press_event));
4551// (*this).release_id = signal_key_release_event().connect(sigc::mem_fun(*this,&main_window::on_my_key_release_event));
4652// (*this).press_id =
53
54        (*this).add_events (Gdk::ALL_EVENTS_MASK);
55
4756        (*this).press_id = (*this).signal_key_press_event().connect_notify(sigc::mem_fun(*this,&main_window::on_notify_key_press_event));
48    (*this).release_id = (*this).signal_key_press_event().connect_notify(sigc::mem_fun(*this,&main_window::on_notify_key_release_event));
57    (*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));
4959        log_debug((*this).press_id << " " << (*this).release_id);
60        log_debug("event mask " << (*this).get_events());
5061}
5162
5263void main_window::disconnect_all()
...... 
5768        log_debug((*this).press_id << " " << (*this).release_id);
5869}
5970
71void main_window::on_notify_motion_notify_event ( GdkEvent *event)
72{
73// gdouble x, y;
74// gdouble pressure;
75// GdkModifierType state;
76//
77// if (event->is_hint)
78// gdk_input_window_get_pointer (event->window, event->deviceid,
79// &x, &y, &pressure, NULL, NULL, &state);
80// else
81// {
82// x = event->x;
83// y = event->y;
84// pressure = event->pressure;
85// state = event->state;
86// }
87//
88// if (state & GDK_BUTTON1_MASK && pixmap != NULL)
89// draw_brush (widget, event->source, x, y, pressure);
90//
91    log_debug("event here " << event->type);
92// return TRUE;
93}
94
95
96void main_window::move_cursor(int direction){
97
98        int x=0, y=0, xadd=0, yadd=0;
99    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();
103   log_debug("display: " << display);
104     log_debug("screen: " << screen);
105    /* check for up/down/left/right arrow key press */
106        log_debug("moving " << direction);
107    switch (direction)
108    {
109        case 65361:
110            xadd -= 5;
111            break;
112        case 65363:
113            xadd += 5;
114            break;
115        case 65362:
116            yadd -= 5;
117            break;
118        case 65364:
119            yadd += 5;
120            break;
121        default:
122                        log_debug("unknown direction");
123                        break;
124// return FALSE; /* propogate event */
125    }
126
127    /* get default display and screen */
128// display = Gdk::Display::get_default();
129// screen =Gdk::Display::get_default_screen();
130// screen = gdk_display_get_default_screen (display);
131
132    /* get cursor position */
133// GdkWindow* ;
134// IDirectFBWindow *gdk_directfb_window_lookup(gtk_widget_get_root_window(scrolled_window2));
135// GdkDisplay gdk_display_open((const gchar) display->get_name());
136        Gdk::ModifierType mask;
137// display->get_pointer(x, y, mask);
138// log_debug("unknown direction 2");
139
140    /* set new cusor position */
141// x += xadd;
142// y += yadd;
143// IDirectFB *directfb;
144// log_debug("unknown direction 3");
145
146
147// GType _gdk_display = g_object_new (GDK_TYPE_DISPLAY_DFB, NULL);
148// display->directfb = directfb;
149
150// IDirectFBDisplayLayer *layer;
151// int ret = directfb->GetDisplayLayer (directfb, DLID_PRIMARY, &layer);
152// log_debug("unknown direction 4");
153
154// int ret = directfb->GetDisplayLayer (directfb, DLID_PRIMARY, &layer);
155
156
157// DFBResult result;
158// log_debug("unknown direction 5");
159//
160// result = layer->WarpCursor(layer, x, y);
161// log_debug("unknown direction 6");
162
163// Gdk::ModifierType mask;
164    display->get_pointer(x, y, mask);
165// log_debug("pointer x: " << x << "pointer y: " << display->pointer_hooks);
166
167// display->warp_pointer( screen, x, y);
168
169// Gdk::Event event();
170
171// Gdk::Event event(gdk_event_new(GDK_MOTION_NOTIFY),true);
172//
173// // 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;
180// /* set new cusor position */
181    x += xadd;
182    y += yadd;
183// event.motion.x_root = x;
184// event.motion.y_root = y;
185// // event->button.button = Button;
186// // event->button.device = gdk_device_get_core_pointer();
187//
188// // g_object_ref(event->screen.window);
189// event.put();
190// handle_pending_events();
191// gdk_event_free(event);
192        Glib::RefPtr<Gdk::Device> pointer = display->get_core_pointer();
193        log_debug("type cursor: " << pointer->get_source());
194        log_debug("pointer xadd: " << xadd << "pointer yadd: " << yadd );
195    if ((screen != 0) && (display!= 0)){
196            display->warp_pointer( screen, x, y);
197            this->signal_motion_notify_event();
198// g_signal_emit (G_OBJECT(display->gobj()), GDK_MOTION_NOTIFY, NULL, x= x, y = y);
199
200        }
201}
202
60203bool main_window::actions(int key)
61204{
62205// log_debug("in actions" << (*this).press_id << " " << (*this).release_id);
...... 
68211    static int key_s = 115;
69212    static int key_t = 116;
70213        static int key_f1 = 65470;
71        static int left = 65361;
72        static int top = 65362;
73        static int right = 65363;
74        static int bottom = 65364;
214        static int key_left = 65361;
215        static int key_up = 65362;
216        static int key_right = 65363;
217        static int key_down = 65364;
75218
76219
77220        // key commands only available if ctrl pressed
...... 
81224                if (key == key_q)
82225                {
83226// log_debug("quit requested");
84                        quit();
227                        (*this).quit();
85228                }
86229                else if(key == key_r)
87230                {
...... 
100243                        history_jump(1);
101244                }else if(key == key_b){
102245                        history_jump(-1);
103                }else{
246                }
247                else{
104248                    (*this).connect_all();
105249// log_debug("key pressed: " << key);
106250                }
...... 
109253            if(key == key_f1){
110254                (*this).disconnect_all();
111255                show_help();
112            }
256            }else if(key == 65361){
257                        log_debug("key is left");
258                        (*this).move_cursor(key);
259                }else if(key == key_right){
260                        (*this).move_cursor(key);
261                }else if(key == key_up){
262                        (*this).move_cursor(key);
263                }else if(key == key_down){
264                        (*this).move_cursor(key);
265                }
113266        }
267
114268        return true;
115269
116270}
...... 
164318
165319bool main_window::quit()
166320{
167    hide();
321    (*this).destroy_();
168322    return false;
169323}
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 on_notify_motion_notify_event(GdkEvent *event);
4144// bool on_my_key_release_event(GdkEventKey *event);
4245      bool quit();
4346};
src/vido.cc
155155
156156    }
157157// gtk_html_get_selection_html(GTK_HTML(html_wg), )
158        window2->resize(320,240);
158159        while( Gtk::Main::events_pending() ){
159160                Gtk::Main::iteration();
160161        }
...... 
233234// window2->disconnect_all();
234235
235236        screenblock(1);
236// log_debug("random called. window all disconnected");
237    log_debug("random called. window all disconnected");
237238    zim::File m = get_file();
238239        zim::Article article;
239240    do
...... 
445446  //static void gtk_html_adjust_cursor_position (GtkHTML *html)
446447}
447448
449void motion( GdkEventMotion *event)
450{
451  log_debug("motion");
452}
448453// // main function
449454int main(int argc, char **argv)
450455{
...... 
472477      g_signal_connect( G_OBJECT( html_wg ), "link_clicked", G_CALLBACK( on_link_clicked ), NULL );
473478      g_signal_connect( G_OBJECT( html_wg ), "scroll", G_CALLBACK( scrolled ), NULL );
474479      gtk_html_set_caret_mode(GTK_HTML(html_wg),false);
480            gtk_widget_set_events(html_wg, 0x3FFFFE);
481            gtk_signal_connect (GTK_OBJECT (html_wg), "resize",
482                        GTK_SIGNAL_FUNC (motion), NULL);
483// g_signal_connect( G_OBJECT( html_wg ), "event", G_CALLBACK( motion ), NULL );
484
475485// gtk_html_adjust_cursor_position(GTK_HTML(html_wg));
476486      Gtk::ScrolledWindow scrolled_window;
477487            scrolled_window2 = &scrolled_window;
488            scrolled_window.set_resize_mode(Gtk::RESIZE_PARENT);
478489      scrolled_window.add(*html);
479490      scrolled_window.set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
480491
...... 
483494            position = 0;
484495      show_random();
485496      gtk_html_edit_make_cursor_visible(GTK_HTML(html_wg));
497// html.add_events (Gdk::ALL_EVENTS_MASK);
498// html.signal_motion_notify_event().connect_notify(sigc::ptr_fun(motion));
486499      Gtk::Main::run(window);
487500    }
488501    else

Archive Download the corresponding diff file

Branches:
development
master



interactive