Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
feh
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
derf
feh
Commits
8821ce80
Commit
8821ce80
authored
15 years ago
by
Birte Kristina Friesel
Browse files
Options
Downloads
Patches
Plain Diff
Partially fix zoom mode
Does not yet work with initial zoom value != 100%
parent
ab405711
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/events.c
+28
-25
28 additions, 25 deletions
src/events.c
src/winwidget.c
+4
-6
4 additions, 6 deletions
src/winwidget.c
src/winwidget.h
+16
-9
16 additions, 9 deletions
src/winwidget.h
with
48 additions
and
40 deletions
src/events.c
+
28
−
25
View file @
8821ce80
...
...
@@ -126,11 +126,16 @@ static void feh_event_handle_ButtonPress(XEvent * ev)
opt
.
mode
=
MODE_ZOOM
;
winwid
->
mode
=
MODE_ZOOM
;
D
(
3
,
(
"click offset is %d,%d
\n
"
,
ev
->
xbutton
.
x
,
ev
->
xbutton
.
y
));
winwid
->
click_offset_x
=
ev
->
xbutton
.
x
-
winwid
->
im_x
;
winwid
->
click_offset_y
=
ev
->
xbutton
.
y
-
winwid
->
im_y
;
winwid
->
im_click_offset_x
=
winwid
->
click_offset_x
/
winwid
->
zoom
;
winwid
->
im_click_offset_y
=
winwid
->
click_offset_y
/
winwid
->
zoom
;
winwid
->
click_offset_x
=
ev
->
xbutton
.
x
;
winwid
->
click_offset_y
=
ev
->
xbutton
.
y
;
winwid
->
old_zoom
=
winwid
->
zoom
;
winwid
->
zoom
=
1
.
0
;
/* required to adjust the image position in zoom mode */
winwid
->
orig_im_x
=
winwid
->
im_x
;
winwid
->
orig_im_y
=
winwid
->
im_y
;
/* center the image */
if
(
winwid
->
full_screen
)
{
winwid
->
im_x
=
(
scr_width
-
winwid
->
im_w
)
>>
1
;
winwid
->
im_y
=
(
scr_height
-
winwid
->
im_h
)
>>
1
;
...
...
@@ -146,17 +151,9 @@ static void feh_event_handle_ButtonPress(XEvent * ev)
winwid
->
im_y
=
0
;
}
}
if
(
winwid
->
im_click_offset_x
<
30
)
winwid
->
im_click_offset_x
=
30
;
if
(
winwid
->
im_click_offset_y
<
0
)
winwid
->
im_click_offset_y
=
0
;
if
(
winwid
->
im_click_offset_x
>
winwid
->
im_w
)
winwid
->
im_click_offset_x
=
winwid
->
im_w
;
if
(
winwid
->
im_click_offset_y
>
winwid
->
im_h
)
winwid
->
im_click_offset_y
=
winwid
->
im_h
;
if
(
winwid
->
click_offset_x
<
30
)
winwid
->
click_offset_x
=
30
;
if
(
winwid
->
click_offset_x
<
0
)
winwid
->
click_offset_x
=
0
;
if
(
winwid
->
click_offset_y
<
0
)
winwid
->
click_offset_y
=
0
;
if
(
winwid
->
click_offset_x
>
winwid
->
w
)
...
...
@@ -425,21 +422,27 @@ static void feh_event_handle_MotionNotify(XEvent * ev)
winwid
=
winwidget_get_from_window
(
ev
->
xmotion
.
window
);
if
(
winwid
)
{
winwid
->
zoom
=
((
double
)
ev
->
xmotion
.
x
-
(
double
)
winwid
->
click_offset_x
)
/
64
.
0
;
if
(
winwid
->
zoom
<
0
)
winwid
->
zoom
=
1
.
0
+
((
winwid
->
zoom
*
64
.
0
)
/
((
double
)
(
winwid
->
click_offset_x
+
1
)));
if
(
ev
->
xmotion
.
x
>
winwid
->
click_offset_x
)
winwid
->
zoom
=
winwid
->
old_zoom
+
(
((
double
)
ev
->
xmotion
.
x
-
(
double
)
winwid
->
click_offset_x
)
/
128
.
0
);
/*/ ((double) (winwid->click_offset_x + 1)));*/
else
winwid
->
zoom
+=
1
.
0
;
winwid
->
zoom
=
winwid
->
old_zoom
-
(
((
double
)
winwid
->
click_offset_x
-
(
double
)
ev
->
xmotion
.
x
)
/
128
.
0
);
/*/ ((double) (winwid->click_offset_x + 1)));*/
if
(
winwid
->
zoom
<
0
.
01
)
winwid
->
zoom
=
0
.
01
;
/* calculate change in zoom and move im_x and im_y respectively to
enable zooming to the clicked spot... */
/* for now, center around im_click_offset_x and im_click_offset_y */
winwid
->
im_x
=
(
winwid
->
w
/
2
)
-
(
winwid
->
im_click_offset_x
*
winwid
->
zoom
);
winwid
->
im_y
=
(
winwid
->
h
/
2
)
-
(
winwid
->
im_click_offset_y
*
winwid
->
zoom
);
/* center around click_offset */
winwid
->
im_x
=
winwid
->
click_offset_x
-
(
winwid
->
click_offset_x
*
winwid
->
zoom
);
/*+ (winwid->orig_im_x * winwid->zoom);*/
winwid
->
im_y
=
winwid
->
click_offset_y
-
(
winwid
->
click_offset_y
*
winwid
->
zoom
);
/*+ (winwid->orig_im_y * winwid->zoom);*/
winwidget_render_image
(
winwid
,
0
,
0
);
}
...
...
This diff is collapsed.
Click to expand it.
src/winwidget.c
+
4
−
6
View file @
8821ce80
...
...
@@ -69,11 +69,10 @@ static winwidget winwidget_allocate(void)
ret
->
im_x
=
0
;
ret
->
im_y
=
0
;
ret
->
zoom
=
1
.
0
;
ret
->
old_zoom
=
1
.
0
;
ret
->
click_offset_x
=
0
;
ret
->
click_offset_y
=
0
;
ret
->
im_click_offset_x
=
0
;
ret
->
im_click_offset_y
=
0
;
ret
->
has_rotated
=
0
;
D_RETURN
(
4
,
ret
);
...
...
@@ -911,14 +910,13 @@ void feh_debug_print_winwid(winwidget w)
"h = %d
\n
"
"im_w = %d
\n
"
"im_h = %d
\n
"
"im_angle = %f
\n
"
"type = %d
\n
"
"had_resize = %d
\n
"
"im = %p
\n
"
"GC = %p
\n
"
"pixmap = %ld
\n
"
"name = %s
\n
"
"file = %p
\n
"
"mode = %d
\n
"
"im_x = %d
\n
"
"im_y = %d
\n
"
"zoom = %f
\n
"
"im_x = %d
\n
"
"im_y = %d
\n
"
"zoom = %f
\n
"
"old_zoom = %f
\n
"
"click_offset_x = %d
\n
"
"click_offset_y = %d
\n
"
"im_click_offset_x = %d
\n
"
"im_click_offset_y = %d
\n
"
"has_rotated = %d
\n
"
,
(
void
*
)
w
,
w
->
win
,
w
->
w
,
w
->
h
,
w
->
im_w
,
w
->
im_h
,
w
->
im_angle
,
w
->
type
,
w
->
had_resize
,
w
->
im
,
(
void
*
)
w
->
gc
,
w
->
bg_pmap
,
w
->
name
,
(
void
*
)
w
->
file
,
w
->
mode
,
w
->
im_x
,
w
->
im_y
,
w
->
zoom
,
w
->
click_offset_x
,
w
->
click_offset_y
,
w
->
im_click_offset_x
,
w
->
im_click_offset_y
,
w
->
has_rotated
);
w
->
zoom
,
w
->
old_zoom
,
w
->
click_offset_x
,
w
->
click_offset_y
,
w
->
has_rotated
);
}
void
winwidget_reset_image
(
winwidget
winwid
)
...
...
This diff is collapsed.
Click to expand it.
src/winwidget.h
+
16
−
9
View file @
8821ce80
...
...
@@ -92,20 +92,27 @@ struct __winwidget {
gib_list
*
file
;
unsigned
char
visible
;
/*
Stuff for
zooming */
/*
panning,
zooming
, etc.
*/
unsigned
char
mode
;
unsigned
char
caption_entry
;
/* are we in caption entry mode? */
unsigned
char
caption_entry
;
/* image offset from window top left */
int
im_x
;
int
im_y
;
/* same, as cache for zoom mode */
int
orig_im_x
;
int
orig_im_y
;
/* From 0 (not visible) to 1.00 (actual size)
* all the way up to INT_MAX (eww)
*/
double
zoom
;
double
old_zoom
;
/* New stuff */
int
im_x
;
/* image offset from window top left */
int
im_y
;
/* image offset from window top left */
double
zoom
;
/* From 0 (not visible) to 1.00 (actual size)
all the way up to INT_MAX (ouch) */
int
click_offset_x
;
int
click_offset_y
;
int
im_click_offset_x
;
int
im_click_offset_y
;
unsigned
char
has_rotated
;
};
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment