Commit Graph

418 Commits

Author SHA1 Message Date
Dmitry Bogatov cee8f0186c Check $HOME and home dir of $USER before getpwuid()->pw_dir
getpwnam(3) recommends to use $HOME instead of getpwuid()->pw_dir,
as it allows users to point programs to a different path.

Using getpwuid() also breaks namespaces-related use cases,
like `unshare -r`.

Patch was submitted by Dmitry Bogatov on the Debian bug tracker:
https://bugs.debian.org/825397

Signed-off-by: Christoph Lohmann <20h@r-36.net>
2016-07-05 13:01:56 +02:00
Quentin Rameau 3530d18d8e Fix url parsing in load() 2016-07-05 13:01:56 +02:00
Quentin Rameau 7ca9421a69 Apply domain parameters each time url is changed
Urls are only changed at load (initial requested one), or while
redirected. When the page is committed, url is already final.
2016-07-05 13:01:56 +02:00
Quentin Rameau 1206b2c587 Fix inspector toggling
Always get the inspector object, and let the user eventually close it
even if it's disabled for the current page.
2016-07-05 13:01:56 +02:00
Quentin Rameau c8fdd4d583 Rectify how parameters are handled in setparameter()
Access parameters through given Arg parameter instead of accessing
global parameters.
2016-07-05 13:01:56 +02:00
Quentin Rameau 6e019362c5 Fix parameter initialization and assignment 2016-07-05 13:01:56 +02:00
Quentin Rameau 75e3fe5b95 Adapting the whole surf structure to new settings 2016-07-05 13:01:56 +02:00
Quentin Rameau 2aa1c38aed Introduce new data structure for handling settings 2016-07-05 13:01:56 +02:00
Quentin Rameau af7522006b Get rid of JavaScript for scrolling in views
This is still a hack, until WebKitGTK gives us a more practical and
stable way to do that. Manipulating directly the DOM inside a
webextension is a pain and only usable with unstable API atm.
2016-03-02 14:46:14 +01:00
Quentin Rameau 934705c420 Fix title handling
Don't forget to always set the title to the current uri, this way it's
up to date when there is no title on the page (ie for local file
exploration).
Thanks to pickfire for reporting the issue.
2015-12-01 12:31:42 +01:00
Quentin Rameau ee04671220 Fix clickexternplayer(), no need to test the target again 2015-11-24 23:18:06 +01:00
Quentin Rameau c069b76f1b Fix user agent command-line parameter
Thanks to yui for seeing that!
2015-11-23 22:13:32 +01:00
Quentin Rameau 981ade6eeb Add webkit language settings
You can now set your prefered website languages in order.
It is also possible to enable spell checking in the same way.
2015-11-22 19:13:48 +01:00
Quentin Rameau 00f9dcdf43 Fix key handling
I had forgotten to compare configured key values against lowered pressed
key values.
Integrated keypress() into winevent().
2015-11-22 17:44:40 +01:00
Quentin Rameau 971856a579 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.
2015-11-22 16:45:22 +01:00
Quentin Rameau d0020bad4f Adapt togglestyle()
We can't apply an empty stylesheet anymore, instead remove any previous
stylesheet.
2015-11-22 15:31:15 +01:00
Quentin Rameau c3a827d621 Modify decideresource() and favicon handling
Return as soon as the request has been processed.
No need to modify the favicon uri, just ignore it.
2015-11-22 15:19:10 +01:00
Quentin Rameau b70a966aa6 Style change in newview(), sort signals order 2015-11-22 13:51:05 +01:00
Quentin Rameau cdc80731fb Fix error handling in spawn()
Be more specific about process name and exit with an error.
2015-11-22 13:44:31 +01:00
Quentin Rameau b87123ac9b Modify default handling of cookiepolicy functions
It's more obvious this way that the default is to always accept cookies
and not the other way around.
2015-11-22 13:33:28 +01:00
Quentin Rameau d4ac9fb6f4 Simplify handling of c->title 2015-11-22 13:24:24 +01:00
Quentin Rameau 10105c8b87 Fix pasteuri()
The uri check had been inverted.
2015-11-22 13:15:39 +01:00
Quentin Rameau 7c24c61ab2 Style fix in sigchld() 2015-11-22 12:22:23 +01:00
Quentin Rameau 890ab510ea Replace use of EXIT_* constants to 0 and 1 2015-11-22 12:17:05 +01:00
Quentin Rameau 3e017b1a89 Fix WM_CLASS and WM_WINDOW_ROLE properties
Instead of forcing class and instance names, which is what GTK does by
default anyway, allow the user to set the instance name, but keep the
general class as “Surf”.
Is we won't support a “-name” parameter and don't implement a parsing of
RESOURCE_NAME env variable, let's fallback on the third behaviour, use
the name of the calling executable.
That would let the user do things like 'ln -s ./surf ./surf-other;
./surf-other' and set different parameters for the two instances (in dwm
for example).
Try to generate a unique WM_WINDOW_ROLE (within the surf process)
composed of “Surf” and the view ID.
2015-11-22 11:53:19 +01:00
Quentin Rameau bd17d359d6 Remove window hints settings
Setting minimum size to 1x1 is not necessary as this is the default.
2015-11-22 03:00:03 +01:00
Quentin Rameau 60c58fbf17 Style indentation fix 2015-11-22 02:25:07 +01:00
Quentin Rameau 2fb122c012 Continue making chars const 2015-11-22 02:22:38 +01:00
Quentin Rameau 6e68af115d Correct and simplify buttonreleased() gdk event
The passed event is a GdkEvent (or GdkEventButton), but not a
GdkEventKey.
Access the struct directly.
2015-11-22 02:10:18 +01:00
Quentin Rameau fef80cd56c Un(g)boolify to separate GTK dependant code from the rest 2015-11-22 02:03:26 +01:00
Quentin Rameau 6124176b89 Use char instead of gchar and make them const when possible 2015-11-22 01:52:13 +01:00
Quentin Rameau 11fa5a7a4d Style update for indentation 2015-11-22 01:42:34 +01:00
Quentin Rameau 954a718197 Add mouse function to play medias in external player
Control + left click launches mpv with the target media url.
2015-11-21 19:53:29 +01:00
Quentin Rameau bc46e954f2 Style change in includes order 2015-11-21 19:22:11 +01:00
Quentin Rameau 432f3c6b53 Style change in functions ordering
Try to group and order functions in a logical manner.
Same thing for config keybindings.
2015-11-21 19:14:08 +01:00
Quentin Rameau 7e9a85a5cb Cleanup remaining unused variables and copystr() 2015-11-20 17:42:25 +01:00
Quentin Rameau adc650f399 Adapt newwindow()
Reorder cmdline options alphabetically and try to keep settings as they
have been toggled in this surf client.
2015-11-20 17:39:45 +01:00
Quentin Rameau 5bca222339 Adapt user agent handling
Now we can only append Surf version to the default WebKit user agent
instead of setting the whole string (while this remains possible to do).
2015-11-20 17:12:00 +01:00
Quentin Rameau e6cefa584e Adapt updatetitle()
Now always show loading progress, still print mouse over link uri before
page uri. Process simplyfied because we use const strings.
2015-11-20 16:59:15 +01:00
Quentin Rameau b5096b1c8f Adapt toggle statistics
Rename *togglestat to plural *togglestats, add frame flatenning
indicator, resize array in consequence.
Use a static index instead of a dynamic one as we always use all values
anyway.
2015-11-20 16:53:52 +01:00
Quentin Rameau 690118133d Adapt page statistics
Rename *pagestat to plural *pagestats, and resize array to reflect
missing proxy parameter.
2015-11-20 16:48:18 +01:00
Quentin Rameau 84611a5d29 Adapt loaduri()
Better handling of different URIs. Filter out “about:” scheme, dont
touch URI if it contains a complete scheme (we assume "://", denotes
one), else test if given path is an actual reachable file on the
filesystem, else prepend arbitrary http:// scheme.
2015-11-20 16:39:53 +01:00
Quentin Rameau 2d1e422368 Rename mouse functions to clickFUNCTION() 2015-11-20 16:27:02 +01:00
Quentin Rameau 82abf5154f Adapt toggle(), clean some config parameters
Regroup all toggles in an enum and handle them with a unique function
via a switch. That lets us take different actions for each toggle.
Add a frame flatenning and a dns preteching options.
2015-11-20 15:48:04 +01:00
Quentin Rameau 526b974c33 Adapt find()
Slightly new behaviour: searching again for the same string (via MOD+/)
resets the search (ie restarts search from document top).
Searching for an empty string stops the search (ie all highlights are
removed).
2015-11-20 01:12:28 +01:00
Quentin Rameau 320e4e4388 Adapt zoom() 2015-11-20 01:03:32 +01:00
Quentin Rameau acec16e685 Adapt navigate() 2015-11-20 01:00:38 +01:00
Quentin Rameau 42fdc77f5e Remove togglescrollbars()
We do not have access to scrollbars and will have to manipulate DOM to
do that.
2015-11-20 00:58:14 +01:00
Quentin Rameau a53dc90171 Adapt scrolling
In fact, we have a scrolling handle ersatz for now using JavaScript
calls as we don't have access anymore to scrollbars.
We'll have to manipulate the DOM directly (later).
2015-11-20 00:53:14 +01:00
Quentin Rameau c4f01cd18b Adapt inspector handling
The inspector is now easily manageable via API, there's no need for
keeping its state in the Client.
2015-11-20 00:46:11 +01:00
Quentin Rameau 0b5b798eb2 Adapt print() 2015-11-20 00:34:23 +01:00
Quentin Rameau 2c2a7b608e Simplify building of stylefiles path
We can directly use style file pointers instead of using temporary
string pointers.
2015-11-20 00:34:22 +01:00
Quentin Rameau ba8617e4ee Adapt setstyle()
We can't anymore pass a simple path to a stylefile, we have to read the
entire file to create a stylesheet and apply it to the view.
2015-11-20 00:34:22 +01:00
Quentin Rameau 701815a5f2 Adapt clipboard()
Replace linkhover with target uri and add some comments
2015-11-20 00:34:22 +01:00
Quentin Rameau d6794e0d75 Rename fullscreen() to togglefullscreen()
And handle c->fullscreen value in winevent(). This way we keep track of
fullscreen state even if we did not directly initiate the fullscreen.
2015-11-20 00:34:22 +01:00
Quentin Rameau b4e78555d0 Replace titlechangeleave() with catch-all winevent()
All GtkWidget events have the same function prototype with the generic
GdkEvent as parameter. This will let us handle everything in the switch.
2015-11-20 00:34:22 +01:00
Quentin Rameau d9cecc8932 Adapt JavaScript functions
Removed eval(), evalscript() is now sufficient and can directly execute
passed JavaScript string.
2015-11-20 00:34:22 +01:00
Quentin Rameau 72905b8bfc Remove windowobjectcleared(), execute scripts on load finished
The “window-object-cleared” signal is not directly accessible for
specific WebViews now. We'll have to use an Extension or rewrite the
JavaScript running functions.
2015-11-20 00:34:22 +01:00
Quentin Rameau bb1fc4195f Add createwindow() for GtkWindow creation
Move there window creation from showview().
2015-11-20 00:34:22 +01:00
Quentin Rameau 2e1fb87361 Add closeview() for JavaScript window closing
Simply call gtk_widget_destroy() on the window. Then GtkWindow closing
process will take care of the rest.
2015-11-20 00:34:21 +01:00
Quentin Rameau 04d46d1791 Remove (delete :>) deletion_interface() 2015-11-20 00:34:21 +01:00
Quentin Rameau 76940a9ab5 Integrate beforerequest() into decidepolicy() 2015-11-20 00:34:21 +01:00
Quentin Rameau d542773e75 Remove contextmenu() and menuactivate() for "context-menu" signal
Those were added because “right click menu to copy the link URI will now
work” (would not work) in 2013. It's been a while since that works without
intervention.
2015-11-20 00:34:21 +01:00
Quentin Rameau f6a35e5fbf Adapted buttonrelease()
Use the current hit test (c->mousepos) to determine where the mouse
pointer is.
It is possible to link an action to a click and still propagate the
event after that by setting the “stop event” parameter of a Button to 0.
2015-11-20 00:34:21 +01:00
Quentin Rameau 96188f83f0 Replace initdownload() and intercept global download requests.
Attach to download requests on WebKitContext, this way we can easily
manage all types of downloads (coming from views or not).
2015-11-20 00:34:21 +01:00
Quentin Rameau 26a2dbac65 Adapted progresschanged() 2015-11-20 00:34:21 +01:00
Quentin Rameau 58c4e18975 Manage ssl errors with GTlsCertificateFlags
Keep a GTlsCertificateFlags in Client for TLS errors.
If we don't use a ssl connection, set it to a value greater than maximum
error flag value (which is G_TLS_CERTIFICATE_VALIDATE_ALL for all
possible errors).
2015-11-20 00:34:20 +01:00
Quentin Rameau e9ec482049 Replace loadstatuschanged() with loadchanged() 2015-11-20 00:34:20 +01:00
Quentin Rameau bce814b30a Replace decidewindow() and decidedownload() with decidepolicy()
Now all the requests are triggered by one signal.
We then handle each type, resource download, navigation, newwindow, in
separate functions.
2015-11-20 00:34:20 +01:00
Quentin Rameau 1f99df029c Replace createwindow() with createview()
We can now perform some filtering before opening a new view (window)
when requested by JavaScript (either random or by a click).
2015-11-20 00:34:20 +01:00
Quentin Rameau 92d7ba7ed8 Replace geopolicyrequested() with permissionrequested()
The permission-request signal can now ask for than a geolocation
authorisation (though we only handle that for now).
2015-11-20 00:34:20 +01:00
Quentin Rameau 42c6c90366 Replace linkhover() with mousetargetchanged()
The “linkhover” can now be more than a simple link (image, video, etc.).
As we can't anymore perform a hit test when we want, we have to keep the
last known hit test to be able to know where the mouse is on the next
click event.
2015-11-20 00:34:20 +01:00
Quentin Rameau b9530ad5d1 Modify the context name of the hit tests
These relate more to the position of the pointer when an event occurs.
2015-11-20 00:34:20 +01:00
Quentin Rameau 60f574e4b7 Adapted titlechange()
Do not copy title strings, just carry over the const pointer.
2015-11-20 00:34:20 +01:00
Quentin Rameau 0f3e3bf669 Move all necessary initialisation to newview()
Most all the settings and callbacks are set before view creation.
Create a related view (with inherited settings) if asked to.
2015-11-20 00:34:19 +01:00
Quentin Rameau ad538bb00a Add newview() and forward related views
View creation is now done in a separate function.
That helps identifying the workflow and let us easily carry related
view (client) when asked by the WebKit for a new one.
2015-11-20 00:34:19 +01:00
Quentin Rameau 421486db18 Add showview()
Only show the window when and if the view is ready.
Move all the window rendering there.
2015-11-20 00:34:14 +01:00
Quentin Rameau f86977a6fa Separate the rendering engine process
Use one WebKitWebProcess per view instead of one for all views.
More information in the API documentation.
2015-11-20 00:23:59 +01:00
Quentin Rameau b0f35be17b No option to enforce 96DPI anymore on WebKit2 2015-11-20 00:23:59 +01:00
Quentin Rameau 42829cdad0 Scrolling is now handled through WebKit
We don't have access anymore to the scrolling process and have to rely
entirely on WebKit.
We could be able to manage scrolling and bars directly by manipulating
the DOM via a WebKitExtension. To be continued…
2015-11-20 00:23:59 +01:00
Quentin Rameau 94f2f2eace SSL policy is now handled through WebKit 2015-11-20 00:23:59 +01:00
Quentin Rameau e39b7e623c Disk cache is now handled through WebKit 2015-11-20 00:23:59 +01:00
Quentin Rameau 7c34b37786 Cookies are now handled through WebKit
Remove all soup cookie handling and use provided interface.
2015-11-20 00:23:54 +01:00
Quentin Rameau 4415c475f7 Remove source(), it has been removed from webkit2gtk
WebKit2GTK doesn't provide a direct way to view source anymore, we'll
have to do that ourselves with a GtkSourceView if we still need that.
2015-11-18 14:59:13 +01:00
Quentin Rameau b7cc1ae964 Remove proxy stuff, it's now handled by WebView 2015-11-18 14:59:13 +01:00
Quentin Rameau abcf5f06ed Switch headers to webkit2 2015-11-18 14:59:13 +01:00
Quentin Rameau 566b452b46 Port surf to gtk3 2015-11-17 17:05:05 +01:00
Quentin Rameau 9b1e1873b0 buildfile: don't forget to free temporary string bpath
Signed-off-by: Christoph Lohmann <20h@r-36.net>
2015-11-04 16:47:04 +01:00
Quentin Rameau 5333171961 Be more specific about what enablestyles parameter does.
The enablestyles configuration variable and parameter flag manages the
global application of styles, not just the site-specific styles.

Signed-off-by: Christoph Lohmann <20h@r-36.net>
2015-11-03 19:45:50 +01:00
Quentin Rameau 2223e9ed22 Fix inspector handling when inspector is disabled.
Do not try to show the inspector window when the inspector is disabled.

Signed-off-by: Christoph Lohmann <20h@r-36.net>
2015-11-03 19:45:04 +01:00
Quentin Rameau 1ebb5c624e Fix usage(), -m and -M for styles were absent.
Signed-off-by: Christoph Lohmann <20h@r-36.net>
2015-11-03 19:44:20 +01:00
Quentin Rameau 9a2547230a Fix fullscreen handling
Handle the fullscreen in a more consistent way with other options:
-f disables fullscreen while -F enables fullscreen.

Signed-off-by: Christoph Lohmann <20h@r-36.net>
2015-11-03 19:44:05 +01:00
Quentin Rameau 0290066b31 Add setstyle()
Regroup style uri setting application calls under one function.

Signed-off-by: Christoph Lohmann <20h@r-36.net>
2015-10-31 17:50:06 +01:00
Quentin Rameau d84fe71094 Fix style files handling: stop leaking strings.
Everytime getstyle() was being called, we returned newly allocated
strings without ever freing them.
Now uri stylefiles only get allocated once at setup().

Signed-off-by: Christoph Lohmann <20h@r-36.net>
2015-10-31 17:50:03 +01:00
Quentin Rameau c65c8d422b Continue style fixing: function declarations, code alignement
Here are the changes we discussed on the mailing-list.
Alignement is pushed to the first parameter of the function, which seems
to be what people agrees on.

Signed-off-by: Christoph Lohmann <20h@r-36.net>
2015-10-20 17:52:54 +02:00
Markus Teich 9f5c6ff8d7 style fixes: space after keywords, () with sizeof
Signed-off-by: Christoph Lohmann <20h@r-36.net>
2015-10-18 23:01:56 +02:00
Markus Teich c2bb8d0325 whitespace fixes
Signed-off-by: Christoph Lohmann <20h@r-36.net>
2015-10-18 23:01:52 +02:00
Markus Teich 6a65dcb394 fix style path generation
Signed-off-by: Christoph Lohmann <20h@r-36.net>
2015-10-18 16:34:11 +02:00
Christoph Lohmann c81fbbaf43 Style cleanup. 2015-10-13 21:48:38 +02:00
Quentin Rameau 8a898ec4df Fix the way system files are handled at surf startup.
1. Do not chmod existing directories.
2. Fix the handling of tilde expansion in paths, don't expand ~foo to
   $HOME/foo but to foo's home directory.
3. Separate the creation of files and directories. We don't have to
   worry anymore about pathnames having to end with a '/' to be correctly
   handled.

Signed-off-by: Christoph Lohmann <20h@r-36.net>
2015-10-13 21:45:14 +02:00