summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQuentin Rameau <quinq@fifth.space>2015-11-18 16:13:27 +0100
committerQuentin Rameau <quinq@fifth.space>2015-11-20 00:34:14 +0100
commit421486db18ce2de31de71bf0372b6f5c049eb970 (patch)
tree0c1c8984b5bb6a04adeb08fc745c378bde52b871
parentf86977a6fab8ed51bd1208b843b9f53db0cdd058 (diff)
downloadsurf-421486db18ce2de31de71bf0372b6f5c049eb970.tar.gz
surf-421486db18ce2de31de71bf0372b6f5c049eb970.tar.bz2
surf-421486db18ce2de31de71bf0372b6f5c049eb970.zip
Add showview()
Only show the window when and if the view is ready. Move all the window rendering there.
-rw-r--r--surf.c129
1 files changed, 68 insertions, 61 deletions
diff --git a/surf.c b/surf.c
index 70d4eb8..08245b6 100644
--- a/surf.c
+++ b/surf.c
@@ -156,6 +156,7 @@ static void loadstatuschange(WebKitWebView *view, GParamSpec *pspec,
static void loaduri(Client *c, const Arg *arg);
static void navigate(Client *c, const Arg *arg);
static Client *newclient(void);
+static void showview(WebKitWebView *v, Client *c);
static void newwindow(Client *c, const Arg *arg, gboolean noembed);
static void pasteuri(GtkClipboard *clipboard, const char *text, gpointer d);
static gboolean contextmenu(WebKitWebView *view, GtkWidget *menu,
@@ -778,9 +779,6 @@ newclient(void)
{
Client *c;
WebKitWebSettings *settings;
- GdkGeometry hints = { 1, 1 };
- GdkScreen *screen;
- GdkWindow *gwin;
gdouble dpi;
char *ua;
@@ -790,37 +788,6 @@ newclient(void)
c->title = NULL;
c->progress = 100;
- /* Window */
- if (embed) {
- c->win = gtk_plug_new(embed);
- } else {
- c->win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
-
- /* TA: 20091214: Despite what the GNOME docs say, the ICCCM
- * is always correct, so we should still call this function.
- * But when doing so, we *must* differentiate between a
- * WM_CLASS and a resource on the window. By convention, the
- * window class (WM_CLASS) is capped, while the resource is in
- * lowercase. Both these values come as a pair.
- */
- gtk_window_set_wmclass(GTK_WINDOW(c->win), "surf", "Surf");
-
- /* TA: 20091214: And set the role here as well -- so that
- * sessions can pick this up.
- */
- gtk_window_set_role(GTK_WINDOW(c->win), "Surf");
- }
- gtk_window_set_default_size(GTK_WINDOW(c->win), 800, 600);
- g_signal_connect(G_OBJECT(c->win),
- "destroy",
- G_CALLBACK(destroywin), c);
- g_signal_connect(G_OBJECT(c->win),
- "leave_notify_event",
- G_CALLBACK(titlechangeleave), c);
-
- if (!kioskmode)
- addaccelgroup(c);
-
/* Webview */
c->view = WEBKIT_WEB_VIEW(webkit_web_view_new());
@@ -836,6 +803,8 @@ newclient(void)
g_signal_connect(G_OBJECT(c->view),
"create-web-view",
G_CALLBACK(createwindow), c);
+ g_signal_connect(G_OBJECT(v), "ready-to-show",
+ G_CALLBACK(showview), c);
g_signal_connect(G_OBJECT(c->view),
"new-window-policy-decision-requested",
G_CALLBACK(decidewindow), c);
@@ -867,23 +836,6 @@ newclient(void)
"should-show-delete-interface-for-element",
G_CALLBACK(deletion_interface), c);
- /* Arranging */
- gtk_container_add(GTK_CONTAINER(c->win), GTK_WIDGET(c->view));
-
- /* Setup */
- gtk_widget_grab_focus(GTK_WIDGET(c->view));
- gtk_widget_show(GTK_WIDGET(c->view));
- gtk_widget_show(c->win);
- gwin = gtk_widget_get_window(GTK_WIDGET(c->win));
- c->xid = gdk_x11_window_get_xid(gwin);
- gtk_window_set_geometry_hints(GTK_WINDOW(c->win), NULL, &hints,
- GDK_HINT_MIN_SIZE);
- gdk_window_set_events(gwin, GDK_ALL_EVENTS_MASK);
- gdk_window_add_filter(gwin, processx, c);
- webkit_web_view_set_full_content_zoom(c->view, TRUE);
-
- runscript(frame);
-
settings = webkit_web_view_get_settings(c->view);
if (!(ua = getenv("SURF_USERAGENT")))
ua = useragent;
@@ -907,10 +859,6 @@ newclient(void)
if (enablestyle)
setstyle(c, getstyle("about:blank"));
- /* This might conflict with _zoomto96dpi_. */
- if (zoomlevel != 1.0)
- webkit_web_view_set_zoom_level(c->view, zoomlevel);
-
if (enableinspector) {
c->inspector = webkit_web_view_get_inspector(c->view);
g_signal_connect(G_OBJECT(c->inspector), "inspect-web-view",
@@ -924,16 +872,77 @@ newclient(void)
c->isinspecting = false;
}
+ c->next = clients;
+ clients = c;
+
+ return c;
+}
+
+void
+showview(WebKitWebView *v, Client *c)
+{
+ GdkGeometry hints = { 1, 1 };
+ GdkRGBA bgcolor = { 0 };
+ GdkWindow *gwin;
+
+ /* Window */
+ if (embed) {
+ c->win = gtk_plug_new(embed);
+ } else {
+ c->win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+
+ /* TA: 20091214: Despite what the GNOME docs say, the ICCCM
+ * is always correct, so we should still call this function.
+ * But when doing so, we *must* differentiate between a
+ * WM_CLASS and a resource on the window. By convention, the
+ * window class (WM_CLASS) is capped, while the resource is in
+ * lowercase. Both these values come as a pair.
+ */
+ gtk_window_set_wmclass(GTK_WINDOW(c->win), "surf", "Surf");
+
+ /* TA: 20091214: And set the role here as well -- so that
+ * sessions can pick this up.
+ */
+ gtk_window_set_role(GTK_WINDOW(c->win), "Surf");
+ }
+ gtk_window_set_default_size(GTK_WINDOW(c->win), 800, 600);
+ g_signal_connect(G_OBJECT(c->win),
+ "destroy",
+ G_CALLBACK(destroywin), c);
+ g_signal_connect(G_OBJECT(c->win),
+ "leave_notify_event",
+ G_CALLBACK(titlechangeleave), c);
+
+ if (!kioskmode)
+ addaccelgroup(c);
+
+ /* Arranging */
+ gtk_container_add(GTK_CONTAINER(c->win), GTK_WIDGET(c->view));
+
+ /* Setup */
+ gtk_widget_grab_focus(GTK_WIDGET(c->view));
+ gtk_widget_show(GTK_WIDGET(c->view));
+ gtk_widget_show(c->win);
+ gwin = gtk_widget_get_window(GTK_WIDGET(c->win));
+ c->xid = gdk_x11_window_get_xid(gwin);
+ gtk_window_set_geometry_hints(GTK_WINDOW(c->win), NULL, &hints,
+ GDK_HINT_MIN_SIZE);
+ gdk_window_set_events(gwin, GDK_ALL_EVENTS_MASK);
+ gdk_window_add_filter(gwin, processx, c);
+
+ runscript(frame);
+
+ /* This might conflict with _zoomto96dpi_. */
+ if (zoomlevel != 1.0)
+ webkit_web_view_set_zoom_level(c->view, zoomlevel);
+
if (runinfullscreen)
fullscreen(c, NULL);
setatom(c, AtomFind, "");
setatom(c, AtomUri, "about:blank");
if (hidebackground)
- webkit_web_view_set_transparent(c->view, TRUE);
-
- c->next = clients;
- clients = c;
+ webkit_web_view_set_background_color(c->view, &bgcolor);
if (showxid) {
gdk_display_sync(gtk_widget_get_display(c->win));
@@ -943,8 +952,6 @@ newclient(void)
die("Error closing stdout");
}
}
-
- return c;
}
void