2 * Copyright (c) 2011 Conformal Systems LLC <info@conformal.com>
3 * Copyright (c) 2011 Marco Peereboom <marco@peereboom.us>
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
32 #include <sys/types.h>
34 #if defined(__linux__)
35 #include "linux/util.h"
36 #include "linux/tree.h"
37 #include <bsd/stdlib.h>
38 # if !defined(sane_libbsd_headers)
39 void arc4random_buf(void *, size_t);
41 #elif defined(__FreeBSD__)
43 #include "freebsd/util.h"
49 #include <sys/queue.h>
50 #include <sys/resource.h>
51 #include <sys/socket.h>
57 #include <gdk/gdkkeysyms.h>
59 #if GTK_CHECK_VERSION(3,0,0)
60 /* we still use GDK_* instead of GDK_KEY_* */
61 #include <gdk/gdkkeysyms-compat.h>
64 #include <webkit/webkit.h>
65 #include <libsoup/soup.h>
66 #include <JavaScriptCore/JavaScript.h>
67 #include <gnutls/gnutls.h>
68 #include <gnutls/x509.h>
70 /* comment if you don't want to use threads */
79 #include "javascript.h"
81 javascript.h borrowed from vimprobable2 under the following license:
83 Copyright (c) 2009 Leon Winter
84 Copyright (c) 2009-2011 Hannes Schueller
85 Copyright (c) 2009-2010 Matto Fransen
86 Copyright (c) 2010-2011 Hans-Peter Deifel
87 Copyright (c) 2010-2011 Thomas Adam
88 Copyright (c) 2011 Albert Kim
89 Copyright (c) 2011 Daniel Carl
91 Permission is hereby granted, free of charge, to any person obtaining a copy
92 of this software and associated documentation files (the "Software"), to deal
93 in the Software without restriction, including without limitation the rights
94 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
95 copies of the Software, and to permit persons to whom the Software is
96 furnished to do so, subject to the following conditions:
98 The above copyright notice and this permission notice shall be included in
99 all copies or substantial portions of the Software.
101 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
102 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
103 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
104 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
105 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
106 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
112 #define DPRINTF(x...) do { if (swm_debug) fprintf(stderr, x); } while (0)
113 #define DNPRINTF(n,x...) do { if (swm_debug & n) fprintf(stderr, x); } while (0)
114 #define XT_D_MOVE 0x0001
115 #define XT_D_KEY 0x0002
116 #define XT_D_TAB 0x0004
117 #define XT_D_URL 0x0008
118 #define XT_D_CMD 0x0010
119 #define XT_D_NAV 0x0020
120 #define XT_D_DOWNLOAD 0x0040
121 #define XT_D_CONFIG 0x0080
122 #define XT_D_JS 0x0100
123 #define XT_D_FAVORITE 0x0200
124 #define XT_D_PRINTING 0x0400
125 #define XT_D_COOKIE 0x0800
126 #define XT_D_KEYBINDING 0x1000
127 #define XT_D_CLIP 0x2000
128 #define XT_D_BUFFERCMD 0x4000
129 extern u_int32_t swm_debug
;
131 #define DPRINTF(x...)
132 #define DNPRINTF(n,x...)
135 #define LENGTH(x) (sizeof x / sizeof x[0])
136 #define CLEAN(mask) (mask & ~(GDK_MOD2_MASK) & \
137 ~(GDK_BUTTON1_MASK) & \
138 ~(GDK_BUTTON2_MASK) & \
139 ~(GDK_BUTTON3_MASK) & \
140 ~(GDK_BUTTON4_MASK) & \
143 #define XT_NOMARKS (('z' - 'a' + 1) * 2 + 10)
146 TAILQ_ENTRY(tab
) entry
;
148 GtkWidget
*tab_content
;
157 GtkWidget
*uri_entry
;
158 GtkWidget
*search_entry
;
160 GtkWidget
*browser_win
;
161 GtkWidget
*statusbar_box
;
163 GtkWidget
*statusbar
;
164 GtkWidget
*buffercmd
;
175 GtkWidget
*js_toggle
;
176 GtkEntryCompletion
*completion
;
180 WebKitWebHistoryItem
*item
;
181 WebKitWebBackForwardList
*bfl
;
184 WebKitNetworkRequest
*icon_request
;
185 WebKitDownload
*icon_download
;
186 gchar
*icon_dest_uri
;
188 /* adjustments for browser */
191 GtkAdjustment
*adjust_h
;
192 GtkAdjustment
*adjust_v
;
198 int xtp_meaning
; /* identifies dls/favorites */
200 int popup
; /* 1 if cmd_entry has popup visible */
202 /* https thread stuff */
210 /* custom stylesheet */
220 WebKitWebSettings
*settings
;
224 double mark
[XT_NOMARKS
];
226 TAILQ_HEAD(tab_list
, tab
);
228 GtkWidget
*create_window(const gchar
*);
230 WebKitWebView
* inspector_inspect_web_view_cb(WebKitWebInspector
*,
231 WebKitWebView
*, struct tab
*);