[hackers] [surf] Fix target uri handling when leaving window || Quentin Rameau

From: <git_AT_suckless.org>
Date: Sun, 22 Nov 2015 17:46:12 +0100 (CET)

commit 971856a579889de5ee6d427c3f7374969b872cbc
Author: Quentin Rameau <quinq_AT_fifth.space>
AuthorDate: Sun Nov 22 16:45:22 2015 +0100
Commit: Quentin Rameau <quinq_AT_fifth.space>
CommitDate: Sun Nov 22 16:45:22 2015 +0100

    Fix target uri handling when leaving window
    
    Introduce a new string pointer overtitle in Client to be able to keep
    the targeturi intact while modifying the former for overriding or not
    the window title.
    Connect to GDK_ENTER_NOTIFY to restore overtitle when refocusing on
    window.

diff --git a/surf.c b/surf.c
index 30464d5..05c22ec 100644
--- a/surf.c
+++ b/surf.c
_AT_@ -70,7 +70,7 @@ typedef struct Client {
         GTlsCertificateFlags tlsflags;
         Window xid;
         int progress, fullscreen;
- const char *title, *targeturi;
+ const char *title, *overtitle, *targeturi;
         const char *needle;
         struct Client *next;
 } Client;
_AT_@ -433,7 +433,7 @@ void
 updatetitle(Client *c)
 {
         char *title;
- const char *name = c->targeturi ? c->targeturi :
+ const char *name = c->overtitle ? c->overtitle :
                            c->title ? c->title : "";
 
         if (showindicators) {
_AT_@ -879,22 +879,25 @@ gboolean
 winevent(GtkWidget *w, GdkEvent *e, Client *c)
 {
         switch (e->type) {
+ case GDK_ENTER_NOTIFY:
+ c->overtitle = c->targeturi;
+ updatetitle(c);
+ break;
         case GDK_LEAVE_NOTIFY:
- c->targeturi = NULL;
+ c->overtitle = NULL;
                 updatetitle(c);
                 break;
- case GDK_WINDOW_STATE: /* fallthrough */
+ case GDK_WINDOW_STATE:
                 if (e->window_state.changed_mask ==
- GDK_WINDOW_STATE_FULLSCREEN) {
+ GDK_WINDOW_STATE_FULLSCREEN)
                         c->fullscreen = e->window_state.new_window_state &
                                         GDK_WINDOW_STATE_FULLSCREEN;
- break;
- }
+ break;
         default:
- return FALSE;
+ break;
         }
 
- return TRUE;
+ return FALSE;
 }
 
 void
_AT_@ -965,6 +968,8 @@ createwindow(Client *c)
 
         g_signal_connect(G_OBJECT(w), "destroy",
                          G_CALLBACK(destroywin), c);
+ g_signal_connect(G_OBJECT(w), "enter-notify-event",
+ G_CALLBACK(winevent), c);
         g_signal_connect(G_OBJECT(w), "leave-notify-event",
                          G_CALLBACK(winevent), c);
         g_signal_connect(G_OBJECT(w), "window-state-event",
_AT_@ -1037,6 +1042,8 @@ mousetargetchanged(WebKitWebView *v, WebKitHitTestResult *h, guint modifiers,
                 c->targeturi = webkit_hit_test_result_get_media_uri(h);
         else
                 c->targeturi = NULL;
+
+ c->overtitle = c->targeturi;
         updatetitle(c);
 }
 
Received on Sun Nov 22 2015 - 17:46:12 CET

This archive was generated by hypermail 2.3.0 : Sun Nov 22 2015 - 17:48:13 CET