Skip to content
This repository has been archived by the owner on Sep 2, 2021. It is now read-only.

Commit

Permalink
Workaround for focus-at-start bug
Browse files Browse the repository at this point in the history
  • Loading branch information
pritambaral committed Dec 5, 2012
1 parent c883bde commit 74e4a77
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions appshell/cefclient_gtk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
char szWorkingDir[512]; // The current working directory
std:: string szInitialUrl;
std:: string szRunningDir;
int add_handler_id;
bool isReallyClosing = false;

// The global ClientHandler reference.
Expand All @@ -33,6 +34,18 @@ void destroy(void) {
void TerminationSignalHandler(int signatl) {
destroy();
}
void HandleAdd(GtkContainer *container,
GtkWidget *widget,
gpointer user_data) {
g_signal_handler_disconnect(container, add_handler_id);
if(gtk_widget_get_can_focus(widget)) {
gtk_widget_grab_focus(widget);
}
else {
add_handler_id = g_signal_connect(G_OBJECT(widget), "add",
G_CALLBACK(HandleAdd), NULL);
}
}

static gboolean HandleQuit(int signatl) {
if (!isReallyClosing && g_handler.get() && g_handler->GetBrowserId()) {
Expand Down Expand Up @@ -161,6 +174,8 @@ int main(int argc, char* argv[]) {
G_CALLBACK(HandleQuit), NULL);
g_signal_connect(G_OBJECT(window), "destroy",
G_CALLBACK(gtk_widget_destroyed), &window);
add_handler_id = g_signal_connect(G_OBJECT(window), "add",
G_CALLBACK(HandleAdd), NULL);
// g_signal_connect(G_OBJECT(window), "destroy",
// G_CALLBACK(destroy), NULL);

Expand Down

0 comments on commit 74e4a77

Please sign in to comment.