I am facing one Focus issue in my application. when i run my app with GTK-3.0.6 libs its working fine with Xorg-1.12.0 . But when i run my same App with GTK-3.4.1 libs events are not working .
plz check the attached code of my App. Please provide some light on this issue i will be very thankfull to you .
Thanks & Regards
Jagat Prakash Sharma
Mobile No.-- 91-09899967558
#include <gtk/gtk.h> #include <gdk/gdk.h> #include <gdk/gdkx.h> #include <gdk/gdkkeysyms.h> #include <stdlib.h> #include <string.h> GtkWidget *window; GtkWidget *Hack; gint count = 0; char buf[5]; void increase(GtkWidget *widget, gpointer label) { count++; sprintf(buf, "%d", count); gtk_label_set_text(GTK_LABEL(label), buf); } void decrease(GtkWidget *widget, gpointer label) { count--; sprintf(buf, "%d", count); gtk_label_set_text(GTK_LABEL(label), buf); } void SynthesizeKeyBoardEvent(int type, long keyval) { GdkEvent event; memset(&event, 0, sizeof(GdkEvent)); event.key.type = (GdkEventType)type; event.key.window = gtk_widget_get_window(window); event.key.keyval = keyval; event.key.send_event = TRUE; event.key.time = GDK_CURRENT_TIME; event.key.state = GDK_KEY_PRESS_MASK; GdkKeymapKey* keys; gint n_keys; if(gdk_keymap_get_entries_for_keyval(gdk_keymap_get_default(), keyval, &keys, &n_keys)) { event.key.hardware_keycode = keys[0].keycode; event.key.group = keys[0].group; } event.key.state = 0; gdk_event_put(&event); gdk_flush(); g_free(keys); } void SynthesizeMouseMoveEvent(int X,int Y) { gdk_display_warp_pointer( gdk_display_get_default (),gdk_display_get_default_screen (gdk_display_get_default ()),X,Y); } static void ontime(gpointer data) { static long keyVal = GDK_KEY_Up; static int once = 1; if(once) { SynthesizeMouseMoveEvent(100, 100); once = 0; } if(keyVal == GDK_KEY_Up) { SynthesizeKeyBoardEvent(GDK_KEY_PRESS, GDK_KEY_Up); //SynthesizeKeyBoardEvent(GDK_KEY_RELEASE, GDK_KEY_Up); fprintf(stderr, "KEY PRESSED ---- UP \n"); Hack=gtk_window_get_focus((GtkWindow *)window) ; const char *ptr =gtk_widget_get_name(Hack); printf("\n********value of ptr=%s************\n",ptr); keyVal = GDK_KEY_Down; } else if(keyVal == GDK_KEY_Return) { SynthesizeKeyBoardEvent(GDK_KEY_PRESS, GDK_KEY_Return); //SynthesizeKeyBoardEvent(GDK_KEY_RELEASE, GDK_KEY_Return); fprintf(stderr, "KEY PRESSED ---- ENTER \n"); keyVal = GDK_KEY_Down; } else if(keyVal == GDK_KEY_Down) { SynthesizeKeyBoardEvent(GDK_KEY_PRESS, GDK_KEY_Down); //SynthesizeKeyBoardEvent(GDK_KEY_RELEASE, GDK_KEY_Down); //SynthesizeKeyBoardEvent(GDK_KEY_PRESS, GDK_KEY_Return); fprintf(stderr, "KEY PRESSED ---- DOWN \n"); Hack=gtk_window_get_focus((GtkWindow *)window) ; const char *ptr =gtk_widget_get_name(Hack); printf("\n********value of ptr=%s************\n",ptr); keyVal = GDK_KEY_Up; } } int main(int argc, char *argv[]) { printf("[WebUI Browser] start main \n"); // XInitThreads(); gtk_init(&argc, &argv); if (!g_thread_supported()) g_thread_init(NULL); GtkWidget *label; // GtkWidget *window; GtkWidget *frame; GtkWidget *plus; GtkWidget *minus; window = gtk_window_new(GTK_WINDOW_TOPLEVEL); // gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); gtk_window_set_default_size(GTK_WINDOW(window), 250, 180); gtk_window_set_title(GTK_WINDOW(window), "+-"); frame = gtk_fixed_new(); gtk_container_add(GTK_CONTAINER(window), frame); plus = gtk_button_new_with_label("+"); gtk_widget_set_size_request(plus, 80, 35); gtk_widget_set_name(plus,"plus"); gtk_fixed_put(GTK_FIXED(frame), plus, 50, 20); minus = gtk_button_new_with_label("-"); gtk_widget_set_size_request(minus, 80, 35); gtk_widget_set_name(minus,"minus"); gtk_fixed_put(GTK_FIXED(frame), minus, 50, 80); label = gtk_label_new("0"); gtk_fixed_put(GTK_FIXED(frame), label, 190, 58); gtk_widget_grab_focus(minus); gtk_widget_show_all(window); g_signal_connect(window, "destroy", G_CALLBACK (gtk_main_quit), NULL); g_timeout_add(1000, (GSourceFunc) ontime, window) ; gtk_main(); return 0; }
_______________________________________________ gtk-list mailing list gtk-list@xxxxxxxxx https://mail.gnome.org/mailman/listinfo/gtk-list