Skip to content

Commit

Permalink
added relative positioning of media (see config)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jesse McClure committed Dec 23, 2014
1 parent 4b69420 commit 060b1ec
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 17 deletions.
25 changes: 17 additions & 8 deletions share/config
Expand Up @@ -25,6 +25,9 @@
*.Loop: false
*.Interleave: false
*.LockAspect: true
!! History is still experimental, see archlinux forum thread or wait for
!! documentation.
!*.History: true

!! VIEWS:
!! Views only apply when a second output is connected. One output
Expand Down Expand Up @@ -74,22 +77,22 @@ Note.View.02.Offset: 1
!! Media handlers can included any of the following specifiers:
!! %s target file or url
!! %x | %X x coordinate of the bounding box in the pdf
!! lower case is relative to slideshow window, upper is absolute
!! %y | %Y y coordinate of the bounding box in the pdf
!! lower case is relative to slideshow window, upper is absolute
!! %w | %W width of the bounding box in the pdf
!! %h | %H height of the bounding box in the pdf
!! %% produces a single percent sign
*.Media.Link: firefox %s > /dev/null 2>&1
*.Media.Movie: mplayer -noborder -nokeepaspect -geometry %Wx%H+%X+%Y %s >/dev/null 2>&1
!*.Media.Movie: mplayer -fs %s > /dev/null 2>&1
*.Media.Sound: mplayer %s > /dev/null 2>&1 &
*.Media.Widget: /home/jmcclure/code/slider/interro %W %H %X %Y %s

*.Media.Movie: mpv --noborder -ontop --screen 1 --geometry %Wx%H+%x+%x %s >/dev/null 2>&1
*.Media.Sound: mpv %s > /dev/null 2>&1 &
!*.Media.Widget: Coming Soon

!! CONTROLS & BINDINGS:
!! Each binding takes a single slider command.
!! For full documentation of commands, see `man slider`.
!! Examples for many common commands are provided below.
!
!!
!! Mouse Buttons:
!! Slider will recognize as many buttons as are provided by the X server
!! Generally, X will report events for 12 mouse buttons as follows:
Expand All @@ -116,7 +119,7 @@ Note.View.02.Offset: 1
*.Bind.00.Control: quit
*.Bind.01.Key: Return
*.Bind.01.None: redraw
! slide forward/back
!! slide forward/back
*.Bind.10.Key: Up
*.Bind.10.None: prev
*.Bind.11.Key: Down
Expand All @@ -127,7 +130,13 @@ Note.View.02.Offset: 1
*.Bind.13.None: next
*.Bind.14.Key: space
*.Bind.14.None: next
! sorter + muting
!*.Bind.15.Key: j
!*.Bind.15.None: history forward
!*.Bind.15.Shift: history end
!*.Bind.16.Key: k
!*.Bind.16.None: history back
!*.Bind.16.Shift: history start
!! sorter + muting
*.Bind.20.Key: Tab
*.Bind.20.None: sorter
*.Bind.20.Control: fullscreen
Expand Down
20 changes: 15 additions & 5 deletions src/actions.c
Expand Up @@ -7,14 +7,15 @@
#include "slider.h"
#include "xlib-actions.h"

static void history(const char *arg) {
static void history(const char *cmd) {
if (!conf.history) return;
static int *hist = NULL;
static int nhist = 0;
static int pos = -1;
char *cmd = strchr(arg,' ');
if (!(cmd && *(++cmd))) return;
char *arg = strchr(cmd,' ');
if (!(arg && *(++arg))) return;
int page = 0;
switch (*cmd) {
switch (*arg) {
case 'b': /* back */
if (hist && pos) page = hist[--pos];
else return;
Expand Down Expand Up @@ -119,7 +120,16 @@ static void move(const char *cmd) {
}

static void mute(const char *cmd) {
// TODO
char dir, *arg = strchr(cmd, ' ');
if (!(arg && *(++arg))) return;
if (arg[0] == 'w') cairo_set_source_rgb(show->target[0].ctx, 1, 1, 1);
else cairo_set_source_rgb(show->target[0].ctx, 0, 0, 0);
int i;
for (i = conf.fade; i; --i) {
cairo_paint_with_alpha(show->target[0].ctx, 1/(float)i);
XFlush(dpy);
usleep(5000);
}
}

static void pen(cairo_t *ctx, cairo_surface_t *buf,
Expand Down
5 changes: 4 additions & 1 deletion src/config.c
Expand Up @@ -74,7 +74,7 @@ int config_general(XrmDatabase xrdb, const char *base) {
char class[256], *type;
XrmValue val;
conf.mon = -1;
conf.launch = conf.interleave = conf.loop = conf.lock_aspect = False;
conf.launch = conf.interleave = conf.loop = conf.lock_aspect = conf.history = False;
sprintf(class,"%s.Font",base);
if (XrmGetResource(xrdb, class, class, &type, &val)) {
if (FT_New_Face(ftlib, val.addr, 0, &face) |
Expand All @@ -92,6 +92,9 @@ int config_general(XrmDatabase xrdb, const char *base) {
sprintf(class,"%s.Loop",base);
if (XrmGetResource(xrdb, class, class, &type, &val))
if (*val.addr == 'T' || *val.addr == 't') conf.loop = True;
sprintf(class,"%s.History",base);
if (XrmGetResource(xrdb, class, class, &type, &val))
if (*val.addr == 'T' || *val.addr == 't') conf.history = True;
sprintf(class,"%s.LockAspect",base);
if (XrmGetResource(xrdb, class, class, &type, &val))
if (*val.addr == 'T' || *val.addr == 't') conf.lock_aspect = True;
Expand Down
10 changes: 8 additions & 2 deletions src/media.c
Expand Up @@ -336,10 +336,16 @@ void spawn(PopplerAnnotType type, const char *s, PopplerRectangle *r) {
switch (fmt[i+1]) {
case '%': strcat(cmd, "%"); break;
case 's': strcat(cmd, s); break;
case 'x': case 'X':
case 'x':
sprintf(num, "%d", (int) (r->x1 + 0.5) - show->x);
strcat(cmd, num); break;
case 'X':
sprintf(num, "%d", (int) (r->x1 + 0.5));
strcat(cmd, num); break;
case 'y': case 'Y':
case 'y':
sprintf(num, "%d", (int) (r->y1 + 0.5) - show->y);
strcat(cmd, num); break;
case 'Y':
sprintf(num, "%d", (int) (r->y1 + 0.5));
strcat(cmd, num); break;
case 'w': case 'W':
Expand Down
2 changes: 1 addition & 1 deletion src/slider.h
Expand Up @@ -70,7 +70,7 @@ typedef struct Config {
int nviews, nkeys, font_size, fade, mon;
const char *button[NBUTTON];
const char *media_link[POPPLER_ANNOT_LAST];
Bool loop, interleave, lock_aspect, launch;
Bool history, interleave, lock_aspect, launch, loop;
} Config;

Show *show;
Expand Down

0 comments on commit 060b1ec

Please sign in to comment.