mirror of
git://projects.qi-hardware.com/vido.git
synced 2024-12-22 14:23:19 +02:00
development stuff
Signed-off-by: Mirko Lindner <mirko@sharism.cc>
This commit is contained in:
parent
7a95279f5e
commit
8f2d9951e0
@ -28,6 +28,12 @@
|
||||
#include "vido.hh"
|
||||
#include <cxxtools/log.h>
|
||||
|
||||
// extern "C" {
|
||||
// #include <directfb/directfb.h>
|
||||
// #include <gtk-2.0/gdk/gdkdisplay-directfb.h>
|
||||
// #include <gtk-2.0/gdk/gdkdirectfb.h>
|
||||
// }
|
||||
|
||||
log_define("vido.main_window");
|
||||
|
||||
main_window::main_window()
|
||||
@ -39,14 +45,19 @@ main_window::main_window()
|
||||
|
||||
void main_window::connect_all()
|
||||
{
|
||||
(*this).add_events( Gdk::BUTTON_PRESS_MASK ) ;
|
||||
// (*this).add_events( Gdk::BUTTON_PRESS_MASK ) ;
|
||||
log_debug("connecting all");
|
||||
// (*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).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).release_id = (*this).signal_key_press_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));
|
||||
log_debug((*this).press_id << " " << (*this).release_id);
|
||||
log_debug("event mask " << (*this).get_events());
|
||||
}
|
||||
|
||||
void main_window::disconnect_all()
|
||||
@ -57,6 +68,138 @@ void main_window::disconnect_all()
|
||||
log_debug((*this).press_id << " " << (*this).release_id);
|
||||
}
|
||||
|
||||
void main_window::on_notify_motion_notify_event ( GdkEvent *event)
|
||||
{
|
||||
// gdouble x, y;
|
||||
// gdouble pressure;
|
||||
// GdkModifierType state;
|
||||
//
|
||||
// if (event->is_hint)
|
||||
// gdk_input_window_get_pointer (event->window, event->deviceid,
|
||||
// &x, &y, &pressure, NULL, NULL, &state);
|
||||
// else
|
||||
// {
|
||||
// x = event->x;
|
||||
// y = event->y;
|
||||
// pressure = event->pressure;
|
||||
// state = event->state;
|
||||
// }
|
||||
//
|
||||
// if (state & GDK_BUTTON1_MASK && pixmap != NULL)
|
||||
// draw_brush (widget, event->source, x, y, pressure);
|
||||
//
|
||||
log_debug("event here " << event->type);
|
||||
// return TRUE;
|
||||
}
|
||||
|
||||
|
||||
void main_window::move_cursor(int direction){
|
||||
|
||||
int x=0, y=0, xadd=0, yadd=0;
|
||||
Glib::RefPtr<Gdk::Display> display;
|
||||
display = display->get_default();
|
||||
Glib::RefPtr<Gdk::Screen> screen = display->get_default_screen();
|
||||
// screen = display->get_default_screen();
|
||||
log_debug("display: " << display);
|
||||
log_debug("screen: " << screen);
|
||||
/* check for up/down/left/right arrow key press */
|
||||
log_debug("moving " << direction);
|
||||
switch (direction)
|
||||
{
|
||||
case 65361:
|
||||
xadd -= 5;
|
||||
break;
|
||||
case 65363:
|
||||
xadd += 5;
|
||||
break;
|
||||
case 65362:
|
||||
yadd -= 5;
|
||||
break;
|
||||
case 65364:
|
||||
yadd += 5;
|
||||
break;
|
||||
default:
|
||||
log_debug("unknown direction");
|
||||
break;
|
||||
// return FALSE; /* propogate event */
|
||||
}
|
||||
|
||||
/* get default display and screen */
|
||||
// display = Gdk::Display::get_default();
|
||||
// screen =Gdk::Display::get_default_screen();
|
||||
// screen = gdk_display_get_default_screen (display);
|
||||
|
||||
/* get cursor position */
|
||||
// GdkWindow* ;
|
||||
// IDirectFBWindow *gdk_directfb_window_lookup(gtk_widget_get_root_window(scrolled_window2));
|
||||
// GdkDisplay gdk_display_open((const gchar) display->get_name());
|
||||
Gdk::ModifierType mask;
|
||||
// display->get_pointer(x, y, mask);
|
||||
// log_debug("unknown direction 2");
|
||||
|
||||
/* set new cusor position */
|
||||
// x += xadd;
|
||||
// y += yadd;
|
||||
// IDirectFB *directfb;
|
||||
// log_debug("unknown direction 3");
|
||||
|
||||
|
||||
// GType _gdk_display = g_object_new (GDK_TYPE_DISPLAY_DFB, NULL);
|
||||
// display->directfb = directfb;
|
||||
|
||||
// IDirectFBDisplayLayer *layer;
|
||||
// int ret = directfb->GetDisplayLayer (directfb, DLID_PRIMARY, &layer);
|
||||
// log_debug("unknown direction 4");
|
||||
|
||||
// int ret = directfb->GetDisplayLayer (directfb, DLID_PRIMARY, &layer);
|
||||
|
||||
|
||||
// DFBResult result;
|
||||
// log_debug("unknown direction 5");
|
||||
//
|
||||
// result = layer->WarpCursor(layer, x, y);
|
||||
// log_debug("unknown direction 6");
|
||||
|
||||
// Gdk::ModifierType mask;
|
||||
display->get_pointer(x, y, mask);
|
||||
// log_debug("pointer x: " << x << "pointer y: " << display->pointer_hooks);
|
||||
|
||||
// display->warp_pointer( screen, x, y);
|
||||
|
||||
// Gdk::Event 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);
|
||||
// event.send_event = TRUE;
|
||||
// event.time = GDK_CURRENT_TIME;
|
||||
// event.axes = 0;
|
||||
// event.state = 0;
|
||||
// event.motion.x = x;
|
||||
// event.motion.y = y;
|
||||
// /* set new cusor position */
|
||||
x += xadd;
|
||||
y += yadd;
|
||||
// event.motion.x_root = x;
|
||||
// event.motion.y_root = y;
|
||||
// // event->button.button = Button;
|
||||
// // event->button.device = gdk_device_get_core_pointer();
|
||||
//
|
||||
// // g_object_ref(event->screen.window);
|
||||
// event.put();
|
||||
// handle_pending_events();
|
||||
// gdk_event_free(event);
|
||||
Glib::RefPtr<Gdk::Device> pointer = display->get_core_pointer();
|
||||
log_debug("type cursor: " << pointer->get_source());
|
||||
log_debug("pointer xadd: " << xadd << "pointer yadd: " << yadd );
|
||||
if ((screen != 0) && (display!= 0)){
|
||||
display->warp_pointer( screen, x, y);
|
||||
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)
|
||||
{
|
||||
// log_debug("in actions" << (*this).press_id << " " << (*this).release_id);
|
||||
@ -68,10 +211,10 @@ bool main_window::actions(int key)
|
||||
static int key_s = 115;
|
||||
static int key_t = 116;
|
||||
static int key_f1 = 65470;
|
||||
static int left = 65361;
|
||||
static int top = 65362;
|
||||
static int right = 65363;
|
||||
static int bottom = 65364;
|
||||
static int key_left = 65361;
|
||||
static int key_up = 65362;
|
||||
static int key_right = 65363;
|
||||
static int key_down = 65364;
|
||||
|
||||
|
||||
// key commands only available if ctrl pressed
|
||||
@ -81,7 +224,7 @@ bool main_window::actions(int key)
|
||||
if (key == key_q)
|
||||
{
|
||||
// log_debug("quit requested");
|
||||
quit();
|
||||
(*this).quit();
|
||||
}
|
||||
else if(key == key_r)
|
||||
{
|
||||
@ -100,7 +243,8 @@ bool main_window::actions(int key)
|
||||
history_jump(1);
|
||||
}else if(key == key_b){
|
||||
history_jump(-1);
|
||||
}else{
|
||||
}
|
||||
else{
|
||||
(*this).connect_all();
|
||||
// log_debug("key pressed: " << key);
|
||||
}
|
||||
@ -109,8 +253,18 @@ bool main_window::actions(int key)
|
||||
if(key == key_f1){
|
||||
(*this).disconnect_all();
|
||||
show_help();
|
||||
}else if(key == 65361){
|
||||
log_debug("key is left");
|
||||
(*this).move_cursor(key);
|
||||
}else if(key == key_right){
|
||||
(*this).move_cursor(key);
|
||||
}else if(key == key_up){
|
||||
(*this).move_cursor(key);
|
||||
}else if(key == key_down){
|
||||
(*this).move_cursor(key);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
@ -164,6 +318,6 @@ void main_window::on_notify_key_release_event(GdkEventKey *Key)
|
||||
|
||||
bool main_window::quit()
|
||||
{
|
||||
hide();
|
||||
(*this).destroy_();
|
||||
return false;
|
||||
}
|
||||
|
@ -29,15 +29,18 @@ class main_window : public Gtk::Window
|
||||
main_window();
|
||||
sigc::connection press_id;
|
||||
sigc::connection release_id;
|
||||
sigc::connection motion_id;
|
||||
void connect_all();
|
||||
void disconnect_all();
|
||||
|
||||
private:
|
||||
bool actions(int);
|
||||
int ctrl_state;
|
||||
void move_cursor(int direction);
|
||||
// bool on_my_key_press_event(GdkEventKey *event);
|
||||
void on_notify_key_press_event(GdkEventKey *event);
|
||||
void on_notify_key_release_event(GdkEventKey *event);
|
||||
void on_notify_motion_notify_event(GdkEvent *event);
|
||||
// bool on_my_key_release_event(GdkEventKey *event);
|
||||
bool quit();
|
||||
};
|
||||
|
15
src/vido.cc
15
src/vido.cc
@ -155,6 +155,7 @@ void fill_gtkhtml(std::string& html_str, std::string url, std::string title){
|
||||
|
||||
}
|
||||
// gtk_html_get_selection_html(GTK_HTML(html_wg), )
|
||||
window2->resize(320,240);
|
||||
while( Gtk::Main::events_pending() ){
|
||||
Gtk::Main::iteration();
|
||||
}
|
||||
@ -233,7 +234,7 @@ void show_random()
|
||||
// window2->disconnect_all();
|
||||
|
||||
screenblock(1);
|
||||
// log_debug("random called. window all disconnected");
|
||||
log_debug("random called. window all disconnected");
|
||||
zim::File m = get_file();
|
||||
zim::Article article;
|
||||
do
|
||||
@ -445,6 +446,10 @@ bool scrolled(GtkHTML *cb_html, GtkOrientation orientation, GtkScrollType scroll
|
||||
//static void gtk_html_adjust_cursor_position (GtkHTML *html)
|
||||
}
|
||||
|
||||
void motion( GdkEventMotion *event)
|
||||
{
|
||||
log_debug("motion");
|
||||
}
|
||||
// // main function
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
@ -472,9 +477,15 @@ int main(int argc, char **argv)
|
||||
g_signal_connect( G_OBJECT( html_wg ), "link_clicked", G_CALLBACK( on_link_clicked ), NULL );
|
||||
g_signal_connect( G_OBJECT( html_wg ), "scroll", G_CALLBACK( scrolled ), NULL );
|
||||
gtk_html_set_caret_mode(GTK_HTML(html_wg),false);
|
||||
gtk_widget_set_events(html_wg, 0x3FFFFE);
|
||||
gtk_signal_connect (GTK_OBJECT (html_wg), "resize",
|
||||
GTK_SIGNAL_FUNC (motion), NULL);
|
||||
// g_signal_connect( G_OBJECT( html_wg ), "event", G_CALLBACK( motion ), NULL );
|
||||
|
||||
// gtk_html_adjust_cursor_position(GTK_HTML(html_wg));
|
||||
Gtk::ScrolledWindow scrolled_window;
|
||||
scrolled_window2 = &scrolled_window;
|
||||
scrolled_window.set_resize_mode(Gtk::RESIZE_PARENT);
|
||||
scrolled_window.add(*html);
|
||||
scrolled_window.set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
|
||||
|
||||
@ -483,6 +494,8 @@ int main(int argc, char **argv)
|
||||
position = 0;
|
||||
show_random();
|
||||
gtk_html_edit_make_cursor_visible(GTK_HTML(html_wg));
|
||||
// html.add_events (Gdk::ALL_EVENTS_MASK);
|
||||
// html.signal_motion_notify_event().connect_notify(sigc::ptr_fun(motion));
|
||||
Gtk::Main::run(window);
|
||||
}
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user