1
0
mirror of git://projects.qi-hardware.com/vido.git synced 2024-12-23 00:59:52 +02:00

rest of development stuff

Signed-off-by: Mirko Lindner <mirko@sharism.cc>
This commit is contained in:
Mirko Lindner 2010-02-25 10:57:05 +01:00
parent 12b07510fb
commit d1a53711e7
3 changed files with 78 additions and 36 deletions

View File

@ -35,7 +35,8 @@
// } // }
log_define("vido.main_window"); log_define("vido.main_window");
int x=-1, y=-1;
int ctrl_state;
main_window::main_window() main_window::main_window()
{ {
sigc::connection press_id; sigc::connection press_id;
@ -45,19 +46,15 @@ main_window::main_window()
void main_window::connect_all() void main_window::connect_all()
{ {
// (*this).add_events( Gdk::BUTTON_PRESS_MASK ) ; (*this).add_events( Gdk::ALL_EVENTS_MASK ) ;
log_debug("connecting all"); log_debug("connecting all");
// (*this).press_id = signal_key_press_event().connect(sigc::mem_fun(*this,&main_window::on_my_key_press_event)); // (*this).press_id = signal_key_press_event().connect(sigc::mem_fun(*this,&main_window::on_my_key_press_event));
// (*this).release_id = signal_key_release_event().connect(sigc::mem_fun(*this,&main_window::on_my_key_release_event)); // (*this).release_id = signal_key_release_event().connect(sigc::mem_fun(*this,&main_window::on_my_key_release_event));
// (*this).press_id = // (*this).press_id =
(*this).add_events (Gdk::ALL_EVENTS_MASK);
(*this).press_id = (*this).signal_key_press_event().connect_notify(sigc::mem_fun(*this,&main_window::on_notify_key_press_event)); (*this).press_id = (*this).signal_key_press_event().connect_notify(sigc::mem_fun(*this,&main_window::on_notify_key_press_event));
(*this).release_id = (*this).signal_key_release_event().connect_notify(sigc::mem_fun(*this,&main_window::on_notify_key_release_event)); (*this).release_id = (*this).signal_key_release_event().connect_notify(sigc::mem_fun(*this,&main_window::on_notify_key_release_event));
// (*this).motion_id = (*this).signal_event().connect_notify(sigc::mem_fun(*this,&main_window::on_notify_motion_notify_event)); (*this).motion_id = (*this).signal_event().connect_notify(sigc::mem_fun(*this,&main_window::motion_notify_event));
log_debug((*this).press_id << " " << (*this).release_id); log_debug((*this).press_id << " " << (*this).release_id);
log_debug("event mask " << (*this).get_events());
} }
void main_window::disconnect_all() void main_window::disconnect_all()
@ -68,7 +65,7 @@ void main_window::disconnect_all()
log_debug((*this).press_id << " " << (*this).release_id); log_debug((*this).press_id << " " << (*this).release_id);
} }
void main_window::on_notify_motion_notify_event ( GdkEvent *event) void main_window::motion_notify_event ( GdkEvent *event)
{ {
// gdouble x, y; // gdouble x, y;
// gdouble pressure; // gdouble pressure;
@ -95,11 +92,11 @@ void main_window::on_notify_motion_notify_event ( GdkEvent *event)
void main_window::move_cursor(int direction){ void main_window::move_cursor(int direction){
int x=0, y=0, xadd=0, yadd=0; int xadd=0, yadd=0;
Glib::RefPtr<Gdk::Display> display; Glib::RefPtr<Gdk::Display> display;
display = display->get_default(); // display = display->get_default();
Glib::RefPtr<Gdk::Screen> screen = display->get_default_screen(); Glib::RefPtr<Gdk::Screen> screen = this->get_screen();
// screen = display->get_default_screen(); display = screen->get_display();
log_debug("display: " << display); log_debug("display: " << display);
log_debug("screen: " << screen); log_debug("screen: " << screen);
/* check for up/down/left/right arrow key press */ /* check for up/down/left/right arrow key press */
@ -161,27 +158,44 @@ void main_window::move_cursor(int direction){
// log_debug("unknown direction 6"); // log_debug("unknown direction 6");
// Gdk::ModifierType mask; // Gdk::ModifierType mask;
display->get_pointer(x, y, mask); // if ((x==-1) && (y==-1)){
// log_debug("pointer x: " << x << "pointer y: " << display->pointer_hooks); display->get_pointer(x, y, mask);
// }
log_debug("pointer x: " << x << "pointer y: " << y );
// display->warp_pointer( screen, x, y); // display->warp_pointer( screen, x, y);
// Gdk::Event event(); GdkEvent *event1 = display->peek_event();
if (event1 != NULL){
log_debug("event type: " << event1->type);
}else{
log_debug("no event");
}
// Gdk::Event event(gdk_event_new(GDK_MOTION_NOTIFY),true);
//
// // get_window_and_coordinates(event->button.window, event->button.x, event->button.y, event->button.x_root, event->button.y_root); // // get_window_and_coordinates(event->button.window, event->button.x, event->button.y, event->button.x_root, event->button.y_root);
// event.send_event = TRUE; // GdkEventType type;
// event.time = GDK_CURRENT_TIME; // GdkWindow *window;
// event.axes = 0; // gint8 send_event;
// event.state = 0; // guint32 time;
// event.motion.x = x; // gdouble x;
// event.motion.y = y; // gdouble y;
// gdouble *axes;
// guint state;
// gint16 is_hint;
// GdkDevice *device;
// gdouble x_root, y_root;
// event->type = Gdk::MOTION_NOTIFY;
// event.y = y;
// /* set new cusor position */ // /* set new cusor position */
x += xadd; x += xadd;
y += yadd; y += yadd;
// event.motion.x_root = x;
// event.motion.y_root = y;
// // event->button.button = Button; // // event->button.button = Button;
// // event->button.device = gdk_device_get_core_pointer(); // // event->button.device = gdk_device_get_core_pointer();
// //
@ -189,20 +203,33 @@ void main_window::move_cursor(int direction){
// event.put(); // event.put();
// handle_pending_events(); // handle_pending_events();
// gdk_event_free(event); // gdk_event_free(event);
Glib::RefPtr<Gdk::Device> pointer = display->get_core_pointer(); // Glib::RefPtr<Gdk::Device> pointer = display->get_core_pointer();
log_debug("type cursor: " << pointer->get_source()); // log_debug("type cursor: " << pointer->type);
log_debug("pointer xadd: " << xadd << "pointer yadd: " << yadd ); log_debug("pointer xadd: " << xadd << "pointer yadd: " << yadd );
if ((screen != 0) && (display!= 0)){ if ((screen != 0) && (display!= 0)){
display->warp_pointer( screen, x, y); display->warp_pointer( screen, x, y);
// GdkEvent *event = gdk_event_new(GDK_MOTION_NOTIFY);
// Glib::RefPtr<Gdk::Window> window = display->get_window_at_pointer(x, y);
// Glib::RefPtr<Gdk::Device> pointer = display->get_core_pointer ();
// event->motion.window = window->gobj();
// event->motion.send_event = 1;
// event->motion.time = GDK_CURRENT_TIME;
// event->motion.x = xadd;
// event->motion.y = yadd;
// event->motion.axes = 0;
// event->motion.state = 0;
// event->motion.is_hint = 0;
// event->motion.device = pointer->gobj();
// event->motion.x_root = xadd;
// event->motion.y_root = yadd;
// display->put_event(event);
// this->signal_motion_notify_event(); // this->signal_motion_notify_event();
// g_signal_emit (G_OBJECT(display->gobj()), GDK_MOTION_NOTIFY, NULL, x= x, y = y);
} }
} }
bool main_window::actions(int key) bool main_window::actions(int key)
{ {
// log_debug("in actions" << (*this).press_id << " " << (*this).release_id); log_debug("in actions " << (*this).press_id << " " << (*this).release_id << "control state " << ctrl_state);
static int key_b = 98; static int key_b = 98;
static int key_f = 102; static int key_f = 102;
static int key_h = 104; static int key_h = 104;
@ -228,7 +255,7 @@ bool main_window::actions(int key)
} }
else if(key == key_r) else if(key == key_r)
{ {
// log_debug("random"); log_debug("random");
show_random(); show_random();
} }
else if(key == key_s) else if(key == key_s)
@ -272,22 +299,24 @@ bool main_window::actions(int key)
void main_window::on_notify_key_press_event(GdkEventKey *Key) void main_window::on_notify_key_press_event(GdkEventKey *Key)
{ {
if (Key->keyval == gdk_keyval_from_name("Control_R")) if (Key->keyval == 65508)
{ {
log_debug("setting ctrl state 1");
ctrl_state = 1; ctrl_state = 1;
} }
else else
{ {
actions(Key->keyval); (*this).actions(Key->keyval);
} }
log_debug("Key Presssed is " << Key->keyval); log_debug("Key Presssed is " << Key->keyval);
} }
void main_window::on_notify_key_release_event(GdkEventKey *Key) void main_window::on_notify_key_release_event(GdkEventKey *Key)
{ {
if (Key->keyval == gdk_keyval_from_name("Control_R")) if (Key->keyval == 65508)
{ {
ctrl_state = 0; log_debug("setting ctrl state 0");
ctrl_state = 0;
} }
} }

View File

@ -29,15 +29,18 @@ class main_window : public Gtk::Window
main_window(); main_window();
sigc::connection press_id; sigc::connection press_id;
sigc::connection release_id; sigc::connection release_id;
sigc::connection motion_id;
void connect_all(); void connect_all();
void disconnect_all(); void disconnect_all();
private: private:
bool actions(int); bool actions(int);
int ctrl_state; int ctrl_state;
void move_cursor(int direction);
// bool on_my_key_press_event(GdkEventKey *event); // bool on_my_key_press_event(GdkEventKey *event);
void on_notify_key_press_event(GdkEventKey *event); void on_notify_key_press_event(GdkEventKey *event);
void on_notify_key_release_event(GdkEventKey *event); void on_notify_key_release_event(GdkEventKey *event);
void motion_notify_event(GdkEvent *event);
// bool on_my_key_release_event(GdkEventKey *event); // bool on_my_key_release_event(GdkEventKey *event);
bool quit(); bool quit();
}; };

View File

@ -438,6 +438,11 @@ bool on_link_clicked(GtkHTML *html, const gchar *url)
return true; return true;
} }
void motion( GdkEventMotion *event)
{
log_debug("motion");
}
bool scrolled(GtkHTML *cb_html, GtkOrientation orientation, GtkScrollType scroll_type, gfloat position) bool scrolled(GtkHTML *cb_html, GtkOrientation orientation, GtkScrollType scroll_type, gfloat position)
{ {
log_debug("scrolled"); log_debug("scrolled");
@ -461,6 +466,7 @@ int main(int argc, char **argv)
Gtk::Main kit(argc, argv); Gtk::Main kit(argc, argv);
main_window window; main_window window;
window.add_modal_grab();
window.set_title("Vido"); window.set_title("Vido");
// window.set_border_width(0); // window.set_border_width(0);
window.set_default_size(220, 240); window.set_default_size(220, 240);
@ -473,8 +479,12 @@ int main(int argc, char **argv)
g_signal_connect( G_OBJECT( html_wg ), "scroll", G_CALLBACK( scrolled ), NULL ); g_signal_connect( G_OBJECT( html_wg ), "scroll", G_CALLBACK( scrolled ), NULL );
gtk_html_set_caret_mode(GTK_HTML(html_wg),false); gtk_html_set_caret_mode(GTK_HTML(html_wg),false);
// gtk_html_adjust_cursor_position(GTK_HTML(html_wg)); // gtk_html_adjust_cursor_position(GTK_HTML(html_wg));
gtk_widget_set_events(html_wg, 0x3FFFFE);
gtk_signal_connect (GTK_OBJECT (html_wg), "motion_notify_event",
GTK_SIGNAL_FUNC (motion), NULL);
Gtk::ScrolledWindow scrolled_window; Gtk::ScrolledWindow scrolled_window;
scrolled_window2 = &scrolled_window; scrolled_window2 = &scrolled_window;
scrolled_window.set_resize_mode(Gtk::RESIZE_PARENT);
scrolled_window.add(*html); scrolled_window.add(*html);
scrolled_window.set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC); scrolled_window.set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);