static void curvewidgetgtk_grab_focus( GtkWidget *glow) { if ( !glow->window) return; GTK_WIDGET_CLASS( curvewidgetgtk_parent_class)->grab_focus( glow); gdk_window_focus( glow->window, GDK_CURRENT_TIME); }
JNIEXPORT void JNICALL Java_org_gnome_gdk_GdkWindow_gdk_1window_1focus ( JNIEnv* env, jclass cls, jlong _self, jint _timestamp ) { GdkWindow* self; guint32 timestamp; // convert parameter self self = (GdkWindow*) _self; // convert parameter timestamp timestamp = (guint32) _timestamp; // call function gdk_window_focus(self, timestamp); // cleanup parameter self // cleanup parameter timestamp }
void bring_to_top(GtkWidget *win){ #ifdef __WIN32__ HWND hWnd; int nTargetID, nForegroundID; BOOL res; hWnd = GDK_WINDOW_HWND (win->window); /* From http://techtips.belution.com/ja/vc/0012/ */ nForegroundID = GetWindowThreadProcessId(GetForegroundWindow(), NULL); nTargetID = GetWindowThreadProcessId(hWnd, NULL ); AttachThreadInput(nTargetID, nForegroundID, TRUE ); // SPI_GETFOREGROUNDLOCKTIMEOUT will be undefined. Why ? /* SystemParametersInfo( SPI_GETFOREGROUNDLOCKTIMEOUT,0,&sp_time,0); SystemParametersInfo( SPI_SETFOREGROUNDLOCKTIMEOUT,0,(LPVOID)0,0); SetForegroundWindow(hWnd); SystemParametersInfo( SPI_SETFOREGROUNDLOCKTIMEOUT,0,sp_time,0); */ res = SetForegroundWindow(hWnd); AttachThreadInput(nTargetID, nForegroundID, FALSE); if(!res){ SetFocus(hWnd); } #else gdk_window_show(GTK_WIDGET(win)->window); gdk_window_focus(GTK_WIDGET(win)->window, gtk_get_current_event_time()); #endif }
void iupdrvSetFocus(Ihandle *ih) { Ihandle* dialog = IupGetDialog(ih); if (!gtk_window_is_active((GtkWindow*)dialog->handle)) gdk_window_focus(iupgtkGetWindow(dialog->handle), gtk_get_current_event_time()); gtk_widget_grab_focus(ih->handle); }
void mainwindow_toggle(int sig) { if((!sig && GTK_WIDGET_VISIBLE(mainwindow)) || (sig && toggled)) { gdk_threads_enter(); gtk_widget_hide(GTK_WIDGET(mainwindow)); gdk_flush(); gdk_threads_leave(); toggled = FALSE; return; } toggled = TRUE; gdk_threads_enter(); /* reset the window position before displaying it to avoid flickering if the windos is moved */ mainwindow_reset_position(); if(gtk_window_is_active(GTK_WINDOW(mainwindow)) == FALSE) gtk_window_present(GTK_WINDOW(mainwindow)); else gtk_widget_show(mainwindow); gtk_window_stick(GTK_WINDOW(mainwindow)); gtk_window_set_keep_above(GTK_WINDOW(mainwindow), TRUE); gdk_window_focus(mainwindow->window, gtk_get_current_event_time()); gdk_flush(); gdk_threads_leave(); }
static void message_source_activated(MessagingMenuApp *app, const gchar *id, gpointer user_data) { gchar **sections = g_strsplit(id, ":", 0); PurpleConversation *conv = NULL; PurpleAccount *account; PidginConvWindow *purplewin = NULL; char *type = sections[0]; char *cname = sections[1]; char *aname = sections[2]; char *protocol = sections[3]; account = purple_accounts_find(aname, protocol); if (g_strcmp0(type, "im") == 0) conv = PURPLE_CONVERSATION(purple_conversations_find_im_with_account(cname, account)); else if (g_strcmp0(type, "chat") == 0) conv = PURPLE_CONVERSATION(purple_conversations_find_chat_with_account(cname, account)); else conv = purple_conversations_find_with_account(cname, account); if (conv) { unalert(conv); purplewin = PIDGIN_CONVERSATION(conv)->win; pidgin_conv_window_switch_gtkconv(purplewin, PIDGIN_CONVERSATION(conv)); gdk_window_focus(gtk_widget_get_window(purplewin->window), time(NULL)); } g_strfreev (sections); }
/** gul_gui_window_present: * @window: A #GtkWindow * @user_time: Time of the event that caused the window to * want to raise * * Like gtk_window_present, but doesn't have * http://bugzilla.gnome.org/show_bug.cgi?id=166379 **/ void gul_gui_window_present (GtkWindow *window, guint32 user_time) { GtkWidget *widget; g_return_if_fail (GTK_IS_WINDOW (window)); widget = GTK_WIDGET (window); if (gtk_widget_get_visual (widget)) { g_assert (widget->window != NULL); if (user_time == 0) { user_time = gtk_get_current_event_time (); } gdk_window_show (widget->window); /* note that gdk_window_focus() will also move the window to * the current desktop, for WM spec compliant window managers. */ gdk_window_focus (widget->window, user_time); } else { gtk_widget_show (widget); } }
/* Ensure the item gets focused (both globally, and local to Gtk) */ static void iti_ensure_focus (MateCanvasItem *item) { GtkWidget *toplevel; /* mate_canvas_item_grab_focus still generates focus out/in * events when focused_item == item */ if (MATE_CANVAS_ITEM (item)->canvas->focused_item != item) { mate_canvas_item_grab_focus (MATE_CANVAS_ITEM (item)); } toplevel = gtk_widget_get_toplevel (GTK_WIDGET (item->canvas)); if (toplevel != NULL && GTK_WIDGET_REALIZED (toplevel)) { gdk_window_focus (toplevel->window, GDK_CURRENT_TIME); } }
/* * Override the Window proc for top-level GTK windows that contain an embedded * XULRunnerBrowser. This is needed because GTK's focus model is much * different than XULRunner's. */ LRESULT CALLBACK ToplevelFocusHackWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { GdkWindow* window = gdk_window_lookup((GdkNativeWindow)hwnd); WNDPROC old_window_proc = (WNDPROC)GetProp(hwnd, "ToplevelFocusHackOldProc"); if(!window) { if(!old_window_proc) { return DefWindowProc(hwnd, uMsg, wParam, lParam); } else { return CallWindowProc(old_window_proc, hwnd, uMsg, wParam, lParam); } } switch(uMsg) { case WM_MOUSEACTIVATE: // Mouse click on a non-browser widget. Ensure that the top-level // window has the keyboard focus. // (We know it can't be a browser widget, because we handle // WM_MOUSEACTIVATE in BrowserFocusHackWndProc()). gdk_window_focus(window, 0); return MA_NOACTIVATE; case WM_KILLFOCUS: // GTK's toplevel window is losing focus to a child window. // This is probably a XULRunner window. Handle the event so that // the window doesn't think it's lost focus. if(wParam && IsChild(hwnd, (HWND)wParam)) { return 0; } break; case WM_DESTROY: case WM_NCDESTROY: // The Window is about to be destroyed -- Cleanup SetWindowLongPtr(hwnd, GWL_WNDPROC, (LONG_PTR)old_window_proc); RemoveProp(hwnd, "ToplevelFocusHackOldProc"); break; } return CallWindowProc(old_window_proc, hwnd, uMsg, wParam, lParam); }
static VALUE gdkwin_focus(VALUE self, VALUE timestamp) { gdk_window_focus(_SELF(self), NUM2UINT(timestamp)); return self; }
static void attr_focus_in_event( GtkWidget *w, GdkEvent *event, gpointer data) { SubGraphsGtk *subgraphs = (SubGraphsGtk *)data; gdk_window_focus( subgraphs->brow_widget->window, GDK_CURRENT_TIME); }
static void browwidgetgtk_grab_focus( GtkWidget *flow) { GTK_WIDGET_CLASS( browwidgetgtk_parent_class)->grab_focus( flow); gdk_window_focus( flow->window, GDK_CURRENT_TIME); }
static void focus_out_cb (GtkWidget* w, GdkEvent*e, gpointer user_data) { gdk_window_focus (gtk_widget_get_window (container), 0); }
int main (int argc, char **argv) { /* if (argc == 2 && 0 == g_strcmp0(argv[1], "-d")) */ g_setenv("G_MESSAGES_DEBUG", "all", FALSE); if (is_application_running(SHUTDOWN_ID_NAME)) { g_warning("another instance of application shutdown is running...\n"); return 0; } singleton(SHUTDOWN_ID_NAME); //remove option -f parse_cmd_line (&argc, &argv); check_version(); init_i18n (); gtk_init (&argc, &argv); gdk_window_set_cursor (gdk_get_default_root_window (), gdk_cursor_new (GDK_LEFT_PTR)); container = create_web_container (FALSE, TRUE); ensure_fullscreen (container); gtk_window_set_decorated (GTK_WINDOW (container), FALSE); gtk_window_set_skip_taskbar_hint (GTK_WINDOW (container), TRUE); gtk_window_set_skip_pager_hint (GTK_WINDOW (container), TRUE); /*gtk_window_set_keep_above (GTK_WINDOW (container), TRUE);*/ gtk_window_fullscreen (GTK_WINDOW (container)); gtk_widget_set_events (GTK_WIDGET (container), gtk_widget_get_events (GTK_WIDGET (container)) | GDK_POINTER_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_EXPOSURE_MASK | GDK_VISIBILITY_NOTIFY_MASK | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK); webview = d_webview_new_with_uri (SHUTDOWN_HTML_PATH); gtk_container_add (GTK_CONTAINER(container), GTK_WIDGET (webview)); /*g_signal_connect (container, "show", G_CALLBACK (show_cb), NULL);*/ /*g_signal_connect (webview, "focus-out-event", G_CALLBACK( focus_out_cb), NULL);*/ gtk_widget_realize (container); gtk_widget_realize (webview); GdkWindow* gdkwindow = gtk_widget_get_window (container); GdkRGBA rgba = { 0, 0, 0, 0.0 }; gdk_window_set_background_rgba (gdkwindow, &rgba); gdk_window_set_skip_taskbar_hint (gdkwindow, TRUE); gdk_window_set_cursor (gdkwindow, gdk_cursor_new(GDK_LEFT_PTR)); /*gdk_window_set_override_redirect (gdkwindow, TRUE);*/ /*select_popup_events ();*/ /*gdk_window_add_filter (NULL, (GdkFilterFunc)xevent_filter, gdkwindow);*/ dde_bg_g_settings = g_settings_new(SCHEMA_ID); set_background(gtk_widget_get_window(webview), dde_bg_g_settings, gdk_screen_width(), gdk_screen_height()); grab = gs_grab_new (); gtk_widget_show_all (container); gdk_window_focus (gtk_widget_get_window (container), 0); gdk_window_stick (gdkwindow); gtk_main (); return 0; }
GtkDialog* seahorse_passphrase_prompt_show (const gchar *title, const gchar *description, const gchar *prompt, const gchar *check, gboolean confirm) { GtkEntryBuffer *buffer; GtkEntry *entry; GtkDialog *dialog; GtkWidget *w; GtkWidget *box; GtkTable *table; GtkWidget *wvbox; GtkWidget *chbox; gchar *msg; if (!title) title = _("Passphrase"); if (!prompt) prompt = _("Password:"******"size-request", G_CALLBACK (constrain_size), NULL); g_signal_connect (G_OBJECT (dialog), "map-event", G_CALLBACK (grab_keyboard), NULL); g_signal_connect (G_OBJECT (dialog), "unmap-event", G_CALLBACK (ungrab_keyboard), NULL); g_signal_connect (G_OBJECT (dialog), "window-state-event", G_CALLBACK (window_state_changed), NULL); wvbox = gtk_vbox_new (FALSE, HIG_LARGE * 2); gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (dialog)), wvbox); gtk_container_set_border_width (GTK_CONTAINER (wvbox), HIG_LARGE); chbox = gtk_hbox_new (FALSE, HIG_LARGE); gtk_box_pack_start (GTK_BOX (wvbox), chbox, FALSE, FALSE, 0); /* The image */ w = gtk_image_new_from_stock (GTK_STOCK_DIALOG_AUTHENTICATION, GTK_ICON_SIZE_DIALOG); gtk_misc_set_alignment (GTK_MISC (w), 0.0, 0.0); gtk_box_pack_start (GTK_BOX (chbox), w, FALSE, FALSE, 0); box = gtk_vbox_new (FALSE, HIG_SMALL); gtk_box_pack_start (GTK_BOX (chbox), box, TRUE, TRUE, 0); /* The description text */ if (description) { msg = utf8_validate (description); w = gtk_label_new (msg); g_free (msg); gtk_misc_set_alignment (GTK_MISC (w), 0.0, 0.5); gtk_label_set_line_wrap (GTK_LABEL (w), TRUE); gtk_box_pack_start (GTK_BOX (box), w, TRUE, FALSE, 0); } /* Two entries (usually on is hidden) in a vbox */ table = GTK_TABLE (gtk_table_new (3, 2, FALSE)); gtk_table_set_row_spacings (table, HIG_SMALL); gtk_table_set_col_spacings (table, HIG_LARGE); gtk_box_pack_start (GTK_BOX (box), GTK_WIDGET (table), FALSE, FALSE, 0); /* The first entry if we have one */ if (confirm) { msg = utf8_validate (prompt); w = gtk_label_new (msg); g_free (msg); gtk_table_attach (table, w, 0, 1, 0, 1, GTK_FILL, 0, 0, 0); buffer = seahorse_secure_buffer_new (); entry = GTK_ENTRY (gtk_entry_new_with_buffer (buffer)); g_object_unref (buffer); gtk_entry_set_visibility (entry, FALSE); gtk_widget_set_size_request (GTK_WIDGET (entry), 200, -1); g_object_set_data (G_OBJECT (dialog), "confirm-entry", entry); g_signal_connect (G_OBJECT (entry), "activate", G_CALLBACK (confirm_callback), dialog); g_signal_connect (G_OBJECT (entry), "changed", G_CALLBACK (entry_changed), dialog); gtk_table_attach_defaults (table, GTK_WIDGET (entry), 1, 2, 0, 1); gtk_widget_grab_focus (GTK_WIDGET (entry)); } /* The second and main entry */ msg = utf8_validate (confirm ? _("Confirm:") : prompt); w = gtk_label_new (msg); g_free (msg); gtk_table_attach (table, w, 0, 1, 1, 2, GTK_FILL, 0, 0, 0); buffer = seahorse_secure_buffer_new (); entry = GTK_ENTRY (gtk_entry_new_with_buffer (buffer)); g_object_unref (buffer); gtk_widget_set_size_request (GTK_WIDGET (entry), 200, -1); gtk_entry_set_visibility (entry, FALSE); g_object_set_data (G_OBJECT (dialog), "secure-entry", entry); g_signal_connect (G_OBJECT (entry), "activate", G_CALLBACK (enter_callback), dialog); gtk_table_attach_defaults (table, GTK_WIDGET (entry), 1, 2, 1, 2); if (!confirm) gtk_widget_grab_focus (GTK_WIDGET (entry)); else g_signal_connect (G_OBJECT (entry), "changed", G_CALLBACK (entry_changed), dialog); /* The checkbox */ if (check) { w = gtk_check_button_new_with_mnemonic (check); gtk_table_attach_defaults (table, w, 1, 2, 2, 3); g_object_set_data (G_OBJECT (dialog), "check-option", w); } gtk_widget_show_all (GTK_WIDGET (table)); w = gtk_button_new_from_stock (GTK_STOCK_CANCEL); gtk_dialog_add_action_widget (dialog, w, GTK_RESPONSE_REJECT); gtk_widget_set_can_default (w, TRUE); w = gtk_button_new_from_stock (GTK_STOCK_OK); gtk_dialog_add_action_widget (dialog, w, GTK_RESPONSE_ACCEPT); gtk_widget_set_can_default (w, TRUE); g_signal_connect_object (G_OBJECT (entry), "focus_in_event", G_CALLBACK (gtk_widget_grab_default), G_OBJECT (w), 0); gtk_widget_grab_default (w); g_signal_connect (dialog, "key_press_event", G_CALLBACK (key_press), NULL); gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER); gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE); gtk_window_set_type_hint (GTK_WINDOW (dialog), GDK_WINDOW_TYPE_HINT_NORMAL); gtk_window_set_keep_above (GTK_WINDOW (dialog), TRUE); gtk_widget_show_all (GTK_WIDGET (dialog)); gdk_window_focus (gtk_widget_get_window (GTK_WIDGET (dialog)), GDK_CURRENT_TIME); if (confirm) entry_changed (NULL, dialog); return dialog; }