From 77dcee2aa32ca9ac348043b617b9722846adc9c1 Mon Sep 17 00:00:00 2001 From: Paul Colomiets Date: Sat, 2 Jul 2011 17:59:12 +0300 Subject: Implemented setting UZBL_URI window property This property is set for all uzbl windows unconditionally. This allows window managers and other tools organize windows more carefully. --- src/callbacks.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/callbacks.c b/src/callbacks.c index 360b0c4..862f608 100644 --- a/src/callbacks.c +++ b/src/callbacks.c @@ -492,11 +492,20 @@ load_error_cb (WebKitWebView* page, WebKitWebFrame* frame, gchar *uri, gpointer void uri_change_cb (WebKitWebView *web_view, GParamSpec param_spec) { - (void) param_spec; + (void) param_spec; - g_free (uzbl.state.uri); - g_object_get (web_view, "uri", &uzbl.state.uri, NULL); - g_setenv("UZBL_URI", uzbl.state.uri, TRUE); + g_free (uzbl.state.uri); + g_object_get (web_view, "uri", &uzbl.state.uri, NULL); + g_setenv("UZBL_URI", uzbl.state.uri, TRUE); + + gdk_property_change( + gtk_widget_get_window (GTK_WIDGET (uzbl.gui.main_window)), + gdk_atom_intern_static_string("UZBL_URI"), + gdk_atom_intern_static_string("STRING"), + 8, + GDK_PROP_MODE_REPLACE, + (unsigned char *)uzbl.state.uri, + strlen(uzbl.state.uri)); } void -- cgit v1.2.3 From cd54fab7778c11606e915d2eebceeba8bc9a46fa Mon Sep 17 00:00:00 2001 From: Paul Colomiets Date: Sat, 2 Jul 2011 18:51:58 +0300 Subject: Ensures that UZBL_URI is set when window is mapped This will help window manager to sort windows when they are mapped, instead of moving them back and forth when they are already shown. This is theoretically incurs tiny delay of showing window, but it's shown before main loop is started anyway, and you can't see anything useful before, so the delay is negligible. --- src/uzbl-core.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/uzbl-core.c b/src/uzbl-core.c index 1820623..91729f9 100644 --- a/src/uzbl-core.c +++ b/src/uzbl-core.c @@ -1545,7 +1545,7 @@ settings_init () { State* s = &uzbl.state; Network* n = &uzbl.net; int i; - + /* Load default config */ for (i = 0; default_config[i].command != NULL; i++) { parse_cmd_line(default_config[i].command, NULL); @@ -1751,7 +1751,7 @@ initialize(int argc, char** argv) { fprintf(stderr, "uzbl: error hooking %d: %s\n", SIGALRM, strerror(errno)); event_buffer_timeout(10); - + /* HTTP client */ uzbl.net.soup_session = webkit_get_default_session(); uzbl.net.soup_cookie_jar = uzbl_cookie_jar_new(); @@ -1810,6 +1810,15 @@ load_uri_imp(gchar *uri) { soup_uri_free(soup_uri); } + gdk_property_change( + gtk_widget_get_window (GTK_WIDGET (uzbl.gui.main_window)), + gdk_atom_intern_static_string("UZBL_URI"), + gdk_atom_intern_static_string("STRING"), + 8, + GDK_PROP_MODE_REPLACE, + (unsigned char *)newuri->str, + newuri->len); + /* if we do handle cookies, ask our handler for them */ webkit_web_view_load_uri (uzbl.gui.web_view, newuri->str); g_string_free (newuri, TRUE); @@ -1826,7 +1835,6 @@ main (int argc, char* argv[]) { if (uzbl.state.plug_mode) { uzbl.gui.plug = create_plug(); gtk_container_add (GTK_CONTAINER (uzbl.gui.plug), uzbl.gui.vbox); - gtk_widget_show_all (GTK_WIDGET (uzbl.gui.plug)); /* in xembed mode the window has no unique id and thus * socket/fifo names aren't unique either. * we use a custom randomizer to create a random id @@ -1836,12 +1844,13 @@ main (int argc, char* argv[]) { srand((unsigned int)tv.tv_sec*tv.tv_usec); uzbl.xwin = rand(); } - + /* Windowed mode */ else { uzbl.gui.main_window = create_window(); gtk_container_add (GTK_CONTAINER (uzbl.gui.main_window), uzbl.gui.vbox); - gtk_widget_show_all (uzbl.gui.main_window); + /* We need to ensure there is a window, before we can get XID */ + gtk_widget_realize (GTK_WIDGET (uzbl.gui.main_window)); uzbl.xwin = GDK_WINDOW_XID (gtk_widget_get_window (GTK_WIDGET (uzbl.gui.main_window))); @@ -1910,6 +1919,13 @@ main (int argc, char* argv[]) { g_free(uri_override); } + /* Finally show the window */ + if (uzbl.gui.main_window) { + gtk_widget_show_all (uzbl.gui.main_window); + } else { + gtk_widget_show_all (GTK_WIDGET (uzbl.gui.plug)); + } + /* Verbose feedback */ if (uzbl.state.verbose) { printf("Uzbl start location: %s\n", argv[0]); -- cgit v1.2.3 From 1037a6371e2b8f4f111676851034193318a68726 Mon Sep 17 00:00:00 2001 From: Paul Colomiets Date: Sat, 2 Jul 2011 19:05:31 +0300 Subject: Added window_role variable to set WM_WINDOW_ROLE Another feature for easier integrating with window managers --- src/callbacks.c | 6 ++++++ src/callbacks.h | 3 +++ src/uzbl-core.c | 1 + src/uzbl-core.h | 1 + 4 files changed, 11 insertions(+) diff --git a/src/callbacks.c b/src/callbacks.c index 862f608..4c927bc 100644 --- a/src/callbacks.c +++ b/src/callbacks.c @@ -79,6 +79,12 @@ set_icon() { } } +void +set_window_role() { + if (uzbl.gui.main_window) + gtk_window_set_role(GTK_WINDOW (uzbl.gui.main_window), uzbl.gui.window_role); +} + void cmd_set_geometry() { int ret=0, x=0, y=0; diff --git a/src/callbacks.h b/src/callbacks.h index d34b9fa..654c116 100644 --- a/src/callbacks.h +++ b/src/callbacks.h @@ -21,6 +21,9 @@ set_status_background(); void set_icon(); +void +set_window_role(); + void move_statusbar(); diff --git a/src/uzbl-core.c b/src/uzbl-core.c index 91729f9..0b43df9 100644 --- a/src/uzbl-core.c +++ b/src/uzbl-core.c @@ -91,6 +91,7 @@ const struct var_name_to_ptr_t { { "title_format_long", PTR_V_STR(uzbl.behave.title_format_long, 1, NULL)}, { "title_format_short", PTR_V_STR(uzbl.behave.title_format_short, 1, NULL)}, { "icon", PTR_V_STR(uzbl.gui.icon, 1, set_icon)}, + { "window_role", PTR_V_STR(uzbl.gui.window_role, 1, set_window_role)}, { "forward_keys", PTR_V_INT(uzbl.behave.forward_keys, 1, NULL)}, { "authentication_handler", PTR_V_STR(uzbl.behave.authentication_handler, 1, set_authentication_handler)}, { "scheme_handler", PTR_V_STR(uzbl.behave.scheme_handler, 1, NULL)}, diff --git a/src/uzbl-core.h b/src/uzbl-core.h index affd334..4d7a9b8 100644 --- a/src/uzbl-core.h +++ b/src/uzbl-core.h @@ -77,6 +77,7 @@ typedef struct { WebKitWebView* web_view; gchar* main_title; gchar* icon; + gchar* window_role; /* WebInspector */ GtkWidget* inspector_window; -- cgit v1.2.3 From c55250b607f2d979c281d901342323c0065fa3f9 Mon Sep 17 00:00:00 2001 From: Paul Colomiets Date: Sat, 2 Jul 2011 19:27:51 +0300 Subject: Added documentation for `window_role` --- README | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README b/README index 6709bf5..d6473bf 100644 --- a/README +++ b/README @@ -297,6 +297,8 @@ file). expanded). * `title_format_short`: titlebar string when statusbar shown (will be expanded). * `icon`: path to icon for Gtk. +* `window_role`: Window role string. By default there is no role. This string + is only used by some advanced window managers. * `forward_keys`: Whether `uzbl-core` should send key events to the webkit view. * `cookie_handler`: Handler called when the page requests a cookie to be retrieved or set. Appends the following arguments to the standard handler @@ -616,7 +618,7 @@ The EM allows: * Many fine-grained events (`hover_over_link`, `key_press`, `key_release`,..) * See example `uzbl-event-manager`. -**Note**: Cookie events are sent in addition to (optionally) being handled by +**Note**: Cookie events are sent in addition to (optionally) being handled by the cookie handler (set by the cookie_handler var). If using a handler it will take precedence before the internal state configured by (add|delete)_cookie commands. -- cgit v1.2.3 From c08cce6f0a92c42c71da012dd38b9f54078a0b06 Mon Sep 17 00:00:00 2001 From: Paul Colomiets Date: Sat, 2 Jul 2011 19:44:39 +0300 Subject: Added documentation for the changes in this branch --- README | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/README b/README index d6473bf..37259c6 100644 --- a/README +++ b/README @@ -297,8 +297,7 @@ file). expanded). * `title_format_short`: titlebar string when statusbar shown (will be expanded). * `icon`: path to icon for Gtk. -* `window_role`: Window role string. By default there is no role. This string - is only used by some advanced window managers. +* `window_role`: Window role string. By default there is no role. * `forward_keys`: Whether `uzbl-core` should send key events to the webkit view. * `cookie_handler`: Handler called when the page requests a cookie to be retrieved or set. Appends the following arguments to the standard handler @@ -602,6 +601,21 @@ This script tries to authenticate as user alice with password wonderland once and never retries authentication. See examples for more sofisticated, interactive authentication handler. +### WINDOW MANAGER INTEGRATION + +As mentined before, the contents of the window title can be customized by +setting the `title_format_short` variable and the `title_format_long` variable +(see above to figure out when each of them is used). You can also set `icon` +variable to path of the icon file. Some advanced window managers can also take +`WM_WINDOW_ROLE` in account, which can be set by modifying `window_role` +variable. + +There is currently no support of updating window icon automatically to site's +favicon, but there are some scripts for that at wiki pages. + +Uzbl sets special X window property UZBL_URI which is always the uri of the +page loaded into uzbl, except for web inspector windows which has no UZBL_URI. + ### EVENTS Unlike commands, events are not handled in `uzbl` itself, but are propagated -- cgit v1.2.3