Skip to content
Permalink
Browse files

Favicons for compact tab + autoscroll

FS#214 and #144.

Thanks to Stefan Bolte (dwb browser) for relicensing his
javascript code for autoscroll!

ok marco@
  • Loading branch information...
stevana committed Jan 3, 2012
1 parent 70d1199 commit cfd919ea2eb2fcfca2f2759cde43b1aeec539d84
Showing with 243 additions and 111 deletions.
  1. +129 −0 autoscroll.js
  2. +1 −1 js-merge-helper.pl
  3. +2 −2 linux/Makefile
  4. +30 −0 settings.c
  5. +18 −0 xxxterm.1
  6. +56 −108 xxxterm.c
  7. +3 −0 xxxterm.conf
  8. +4 −0 xxxterm.h
@@ -0,0 +1,129 @@
/* MIT/X Consortium License
*
* Copyright (c) 2011-2012 Stefan Bolte <portix@gmx.net>
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/

MouseAutoScroll = (function() {
const SCROLL_ICON="transparent url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6A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JLR0S5OrgWYAAAAAlwSFlzAAALEwAACxMBAJqcGAAAAUJJREFUOMuV0FNzREEQhuET27ZtOxvbtm3btm10bOfnBV0bnJ3Zqv1u3+diphlGsImIionz6xKSUiAtQ++ycvIAJwqKtK6krAJweqaqpk7MQhqaWgBwfnGpraNLAsJ6+p8drq5vbg0MjQjA2AS+d3f/8GhqZs7TLSyBu6fnFytrGzaw/enw+vYOdvZs4ODo5OyCwNXN3cPTiw28fXz9/BFwAgKDgkn/CAlFEBZOOVREJIKoaAqIiUUQF08BCYkIkpIpICUVQVo6BWRkIsjKpoCcXAR5+RRQUIigqJhUS0rLyisQVFZV19TygLr6hsYmBM0trW3tHWzQCf/W1c0GPb1/e18/7yMGBn/70PAI4ZmjY9w+PjFJ/ObUNPaZ2TnyHeYXFr/60vIK5VDM6to6wMbmFkPd9s4u7O0zfHZweHTMCLYPkhas1aCqNgQAAAAldEVYdGRhdGU6Y3JlYXRlADIwMTEtMDQtMDdUMTE6Mjk6MzcrMDI6MDB8AZWGAAAAJXRFWHRkYXRlOm1vZGlmeQAyMDExLTA0LTA3VDExOjI5OjM3KzAyOjAwDVwtOgAAAABJRU5ErkJggg==) no-repeat scroll center";
const SIZE = 32;
const OFFSET = 5;
var doc;
Math.sign = function(x) { return x >=0 ? 1 : -1; };
var span = null;
var x = 0;
var y = 0;
var ev = null;
var timerId = 0;
var cursorStyle = null;
function startTimer() {
timerId = window.setInterval(timer, 40);
}
function stopTimer () {
window.clearInterval(timerId);
timerId = 0;
}
function timer () {
if (ev) {
var scrollY = (ev.y - y);
var scrollX = (ev.x - x);
var b = scrollY > 0
&& doc.documentElement.scrollHeight == (window.innerHeight + window.pageYOffset);
var r = scrollX > 0
&& doc.documentElement.scrollWidth == (window.innerWidth + window.pageXOffset);
var l = scrollX < 0 && window.pageXOffset == 0;
var t = scrollY < 0 && window.pageYOffset == 0;
var offX = Math.abs(scrollX) < OFFSET;
var offY = Math.abs(scrollY) < OFFSET;
if ( timerId != 0
&& (( b && r ) || ( b && l) || ( b && offX )
|| ( t && r ) || ( t && l) || ( t && offX )
|| (offY && r) || (offY && l) )) {
stopTimer();
return;
}
window.scrollBy(scrollX - Math.sign(scrollX) * OFFSET,
scrollY - Math.sign(scrollY) * OFFSET);
}
}
function mouseMove (e) {
if (timerId == 0) {
startTimer();
}
ev = e;
}
function init (e) {
doc = e.target.ownerDocument;
if (window.innerHeight >= doc.documentElement.scrollHeight
&& window.innerWidth >= doc.documentElement.scrollWidth) {
return;
}
span = doc.createElement("div");
span.style.width = SIZE + "px";
span.style.height = SIZE + "px";
span.style.background = SCROLL_ICON;
span.style.left = e.x - (SIZE / 2) + "px";
span.style.top = e.y - (SIZE / 2) + "px";
span.style.position = "fixed";
span.style.fontSize = SIZE + "px";
span.style.opacity = 0.6;
cursorStyle = doc.defaultView.getComputedStyle(doc.body, null).cursor;
doc.body.style.cursor = "move";
doc.body.appendChild(span);
doc.addEventListener('mousemove', mouseMove, false);
span = span;
}
function clear (e) {
doc.body.style.cursor = cursorStyle;
span.parentNode.removeChild(span);
doc.removeEventListener('mousemove', mouseMove, false);
stopTimer();
if (span)
span = null;
if (ev)
ev = null;
}
function mouseUp (e) { /* Simulate click, click event does not work during scrolling */
if (Math.abs(e.x - x) < 5 && Math.abs(e.y - y) < 5) {
init(e);
window.removeEventListener('mouseup', mouseUp, false);
}
}
function mouseDown (e) {
var t = e.target;
if (ev.button == 0) {
if (_span) {
clear();
}
} else if (ev.button == 1) {
if (span) {
clear();
}
else if (!t.hasAttribute("href")
&& !t.hasAttribute("onmousedown")
&& !(t.hasAttribute("onclick"))) {
x = e.x;
y = e.y;
window.addEventListener('mouseup', mouseUp, false);
}
}
}
window.addEventListener('mousedown', mouseDown, false);
})();
@@ -50,7 +50,7 @@ sub escape_c_string {
my @fn = split /\//, $jsfile;
my $fn = pop @fn;
$fn =~ /^(.*)\.js$/;

$define = "JS_".uc($1);
$define =~ s/\-/_/;

@@ -19,8 +19,8 @@ CC?= gcc
all: javascript.h xxxterm

javascript.h: ../js-merge-helper.pl ../hinting.js
perl ../js-merge-helper.pl ../hinting.js ../input-focus.js > \
javascript.h
perl ../js-merge-helper.pl ../hinting.js ../input-focus.js \
../autoscroll.js > javascript.h

xxxterm: $(OBJS)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $+ $(LDADD)
@@ -92,6 +92,9 @@ int js_autorun_enabled = 1;
int edit_mode = XT_EM_HYBRID;
int userstyle_global = 0;
int auto_load_images = 1;
int enable_autoscroll = 0;
int enable_favicon_entry = 1;
int enable_favicon_tabs = 0;

char *cmd_font_name = NULL;
char *oops_font_name = NULL;
@@ -120,6 +123,9 @@ int set_tab_style(struct settings *, char *);
int set_edit_mode(struct settings *, char *);
int set_work_dir(struct settings *, char *);
int set_auto_load_images(char *value);
int set_enable_autoscroll(char *value);
int set_enable_favicon_entry(char *value);
int set_enable_favicon_tabs(char *value);

void walk_mime_type(struct settings *, void (*)(struct settings *,
char *, void *), void *);
@@ -315,6 +321,9 @@ struct settings rs[] = {
{ "work_dir", XT_S_STR, 0, NULL, NULL,&s_work_dir },
{ "xterm_workaround", XT_S_INT, 0, &xterm_workaround, NULL, NULL },
{ "auto_load_images", XT_S_INT, 0, &auto_load_images, NULL, NULL, NULL, set_auto_load_images },
{ "enable_autoscroll", XT_S_INT, 0, &enable_autoscroll, NULL, NULL, NULL, set_enable_autoscroll },
{ "enable_favicon_entry", XT_S_INT, 0, &enable_favicon_entry, NULL, NULL, NULL, set_enable_favicon_entry },
{ "enable_favicon_tabs", XT_S_INT, 0, &enable_favicon_tabs, NULL, NULL, NULL, set_enable_favicon_tabs },

/* font settings */
{ "cmd_font", XT_S_STR, 0, NULL, &cmd_font_name, NULL },
@@ -1030,6 +1039,27 @@ set_auto_load_images(char *value)
return (0);
}

int
set_enable_autoscroll(char *value)
{
enable_autoscroll = atoi(value);
return (0);
}

int
set_enable_favicon_entry(char *value)
{
enable_favicon_entry = atoi(value);
return (0);
}

int
set_enable_favicon_tabs(char *value)
{
enable_favicon_tabs = atoi(value);
return (0);
}

void
setup_proxy(char *uri)
{
@@ -995,10 +995,28 @@ Locations where files are downloaded to.
This directory must exist and
.Nm
validates that during startup.
.It Cm enable_autoscroll
When enabled clicking MB3 will spawn the autoscroll ball, scrolling can
then proceed by dragging the mouse away from the ball.
.It Cm enable_cookie_whitelist
When enabled all cookies must be in the whitelist or they are rejected.
Additionally whitelisted cookies also enable HTML5 local storage for the
domain.
.It Cm enable_favicon_entry
When enabled (the default)
.Nm
displays the favicon of the web page at the URI entry. This setting
affects both
.Cm normal
and
.Cm compact
tabs.
.It Cm enable_favicon_tabs
When enabled (disabled by default)
.Nm
displays favicons at each tab. This setting only affects
.Cm compact
tabs.
.It Cm enable_js_whitelist
When enabled all domains must be in the js whitelist in order to run Java
Script.
Oops, something went wrong.

0 comments on commit cfd919e

Please sign in to comment.
You can’t perform that action at this time.