Skip to content

Commit

Permalink
--debug-level → --debug
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Friesel committed Jul 17, 2010
1 parent cb6b53e commit ae46674
Show file tree
Hide file tree
Showing 18 changed files with 182 additions and 186 deletions.
2 changes: 1 addition & 1 deletion config.mk
Expand Up @@ -21,7 +21,7 @@ xinerama = -DHAVE_LIBXINERAMA
xinerama_ld = -lXinerama

# Uncomment this for debug mode
# (Use feh -+ <level> or feh --debug-level <level> to see debug output)
# (Use feh -+ or feh --debug to see debug output)
#CFLAGS += -DDEBUG

# Uncomment this to use dmalloc
Expand Down
12 changes: 6 additions & 6 deletions src/collage.c
Expand Up @@ -50,7 +50,7 @@ void init_collage_mode(void)
trans_bg = 1;
else {

D(4, ("Time to apply a background to blend onto\n"));
D(("Time to apply a background to blend onto\n"));
if (feh_load_image_char(&bg_im, opt.bg_file) != 0) {
bg_w = gib_imlib_image_get_width(bg_im);
bg_h = gib_imlib_image_get_height(bg_im);
Expand Down Expand Up @@ -82,7 +82,7 @@ void init_collage_mode(void)

w = opt.limit_w;
h = opt.limit_h;
D(4, ("Limiting width to %d and height to %d\n", w, h));
D(("Limiting width to %d and height to %d\n", w, h));

im_main = imlib_create_image(w, h);

Expand Down Expand Up @@ -119,9 +119,9 @@ void init_collage_mode(void)
filelist = feh_file_remove_from_list(filelist, last);
last = NULL;
}
D(3, ("About to load image %s\n", file->filename));
D(("About to load image %s\n", file->filename));
if (feh_load_image(&im_temp, file) != 0) {
D(3, ("Successfully loaded %s\n", file->filename));
D(("Successfully loaded %s\n", file->filename));
if (opt.verbose)
feh_display_status('.');
www = opt.thumb_w;
Expand Down Expand Up @@ -150,7 +150,7 @@ void init_collage_mode(void)
/* pick random coords for thumbnail */
xxx = ((w - www) * ((double) rand() / RAND_MAX));
yyy = ((h - hhh) * ((double) rand() / RAND_MAX));
D(5, ("image going on at x=%d, y=%d\n", xxx, yyy));
D(("image going on at x=%d, y=%d\n", xxx, yyy));

im_thumb = gib_imlib_create_cropped_scaled_image(im_temp,
0, 0, ww, hh, www, hhh, 1);
Expand All @@ -159,7 +159,7 @@ void init_collage_mode(void)
if (opt.alpha) {
DATA8 atab[256];

D(4, ("Applying alpha options\n"));
D(("Applying alpha options\n"));
gib_imlib_image_set_has_alpha(im_thumb, 1);
memset(atab, opt.alpha_level, sizeof(atab));
gib_imlib_apply_color_modifier_to_rectangle(im_thumb,
Expand Down
30 changes: 14 additions & 16 deletions src/debug.h
Expand Up @@ -39,28 +39,26 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

#ifdef DEBUG
#ifdef __GNUC__
#define D(i, a) \
#define D(a) \
{ \
if(i <= opt.debug_level) \
{ \
printf("%-12s +%-4u %-20s : ",__FILE__,__LINE__,__FUNCTION__); \
printf a; \
fflush(stdout); \
} \
if (opt.debug) { \
printf("%-12s +%-4u %-20s : ",__FILE__,__LINE__,__FUNCTION__); \
printf a; \
fflush(stdout); \
} \
}
#else /* __GNUC__ */
#define D(i, a) \
#define D(a) \
{ \
if(i <= opt.debug_level) \
{ \
printf("%-12s +%-4u : ",__FILE__,__LINE__); \
printf a; \
} \
fflush(stdout); \
}
if (opt.debug) { \
printf("%-12s +%-4u : ",__FILE__,__LINE__); \
printf a; \
fflush(stdout); \
} \
}
#endif /* __GNUC__ */
#else /* DEBUG */
#define D(i,a)
#define D(a)
#endif /* DEBUG */

#endif /* DEBUG_H */
60 changes: 30 additions & 30 deletions src/events.c
Expand Up @@ -74,7 +74,7 @@ static void feh_event_handle_ButtonPress(XEvent * ev)
}

if (!opt.no_menus && EV_IS_MENU_BUTTON(ev)) {
D(3, ("Menu Button Press event\n"));
D(("Menu Button Press event\n"));
if (winwid != NULL) {
winwidget_show_menu(winwid);
}
Expand All @@ -84,33 +84,33 @@ static void feh_event_handle_ButtonPress(XEvent * ev)
if (winwid != NULL) {
opt.mode = MODE_ROTATE;
winwid->mode = MODE_ROTATE;
D(3, ("rotate starting at %d, %d\n", ev->xbutton.x, ev->xbutton.y));
D(("rotate starting at %d, %d\n", ev->xbutton.x, ev->xbutton.y));
}
} else if ((ev->xbutton.button == opt.blur_button)
&& ((opt.no_blur_ctrl_mask)
|| (ev->xbutton.state & ControlMask))) {
if (winwid != NULL) {
opt.mode = MODE_BLUR;
winwid->mode = MODE_BLUR;
D(3, ("blur starting at %d, %d\n", ev->xbutton.x, ev->xbutton.y));
D(("blur starting at %d, %d\n", ev->xbutton.x, ev->xbutton.y));
}
} else if (ev->xbutton.button == opt.pan_button) {
D(3, ("Pan Button Press event\n"));
D(("Pan Button Press event\n"));
if (winwid != NULL) {
D(3, ("Next button, but could be pan mode\n"));
D(("Next button, but could be pan mode\n"));
opt.mode = MODE_NEXT;
winwid->mode = MODE_NEXT;
D(3, ("click offset is %d,%d\n", ev->xbutton.x, ev->xbutton.y));
D(("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;
}
} else if (ev->xbutton.button == opt.zoom_button) {
D(3, ("Zoom Button Press event\n"));
D(("Zoom Button Press event\n"));
if (winwid != NULL) {
D(3, ("Zoom mode baby!\n"));
D(("Zoom mode baby!\n"));
opt.mode = MODE_ZOOM;
winwid->mode = MODE_ZOOM;
D(3, ("click offset is %d,%d\n", ev->xbutton.x, ev->xbutton.y));
D(("click offset is %d,%d\n", ev->xbutton.x, ev->xbutton.y));
winwid->click_offset_x = ev->xbutton.x;
winwid->click_offset_y = ev->xbutton.y;
winwid->old_zoom = winwid->zoom;
Expand All @@ -126,21 +126,21 @@ static void feh_event_handle_ButtonPress(XEvent * ev)
winwidget_render_image(winwid, 0, 0);
}
} else if (ev->xbutton.button == opt.reload_button) {
D(3, ("Reload Button Press event\n"));
D(("Reload Button Press event\n"));
if (winwid != NULL)
feh_reload_image(winwid, 0, 0);
} else if (ev->xbutton.button == opt.prev_button) {
D(3, ("Prev Button Press event\n"));
D(("Prev Button Press event\n"));
if ((winwid != NULL)
&& (winwid->type == WIN_TYPE_SLIDESHOW))
slideshow_change_image(winwid, SLIDE_PREV);
} else if (ev->xbutton.button == opt.next_button) {
D(3, ("Next Button Press event\n"));
D(("Next Button Press event\n"));
if ((winwid != NULL)
&& (winwid->type == WIN_TYPE_SLIDESHOW))
slideshow_change_image(winwid, SLIDE_NEXT);
} else {
D(3, ("Received other ButtonPress event\n"));
D(("Received other ButtonPress event\n"));
}
return;
}
Expand Down Expand Up @@ -182,7 +182,7 @@ static void feh_event_handle_ButtonRelease(XEvent * ev)
else if (ev->xbutton.button == opt.pan_button) {
if (opt.mode == MODE_PAN) {
if (winwid != NULL) {
D(3, ("Disabling pan mode\n"));
D(("Disabling pan mode\n"));
opt.mode = MODE_NORMAL;
winwid->mode = MODE_NORMAL;
winwidget_sanitise_offsets(winwid);
Expand Down Expand Up @@ -237,9 +237,9 @@ static void feh_event_handle_ButtonRelease(XEvent * ev)
}
} else if ((ev->xbutton.button == opt.rotate_button)
|| (ev->xbutton.button == opt.zoom_button)) {
D(3, ("Mode-based Button Release event\n"));
D(("Mode-based Button Release event\n"));
if (winwid != NULL) {
D(3, ("Disabling mode\n"));
D(("Disabling mode\n"));
opt.mode = MODE_NORMAL;
winwid->mode = MODE_NORMAL;
winwidget_sanitise_offsets(winwid);
Expand All @@ -248,9 +248,9 @@ static void feh_event_handle_ButtonRelease(XEvent * ev)
} else if ((ev->xbutton.button == opt.blur_button)
&& ((opt.no_blur_ctrl_mask)
|| (ev->xbutton.state & ControlMask))) {
D(3, ("Blur Button Release event\n"));
D(("Blur Button Release event\n"));
if (winwid != NULL) {
D(3, ("Disabling Blur mode\n"));
D(("Disabling Blur mode\n"));
opt.mode = MODE_NORMAL;
winwid->mode = MODE_NORMAL;
}
Expand All @@ -265,10 +265,10 @@ static void feh_event_handle_ConfigureNotify(XEvent * ev)
winwidget w = winwidget_get_from_window(ev->xconfigure.window);

if (w) {
D(3, ("configure size %dx%d\n", ev->xconfigure.width, ev->xconfigure.height));
D(("configure size %dx%d\n", ev->xconfigure.width, ev->xconfigure.height));
if ((w->w != ev->xconfigure.width)
|| (w->h != ev->xconfigure.height)) {
D(3, ("assigning size and rerendering\n"));
D(("assigning size and rerendering\n"));
w->w = ev->xconfigure.width;
w->h = ev->xconfigure.height;
w->had_resize = 1;
Expand All @@ -289,10 +289,10 @@ static void feh_event_handle_LeaveNotify(XEvent * ev)
if ((menu_root) && (ev->xcrossing.window == menu_root->win)) {
feh_menu_item *ii;

D(4, ("It is for a menu\n"));
D(("It is for a menu\n"));
for (ii = menu_root->items; ii; ii = ii->next) {
if (MENU_ITEM_IS_SELECTED(ii)) {
D(4, ("Unselecting menu\n"));
D(("Unselecting menu\n"));
MENU_ITEM_SET_NORMAL(ii);
menu_root->updates =
imlib_update_append_rect(menu_root->updates, ii->x, ii->y, ii->w, ii->h);
Expand Down Expand Up @@ -324,7 +324,7 @@ static void feh_event_handle_MotionNotify(XEvent * ev)
feh_menu *m;
feh_menu_item *selected_item, *mouseover_item;

D(3, ("motion notify with menus open\n"));
D(("motion notify with menus open\n"));
while (XCheckTypedWindowEvent(disp, ev->xmotion.window, MotionNotify, ev));

if (ev->xmotion.window == menu_cover) {
Expand All @@ -334,7 +334,7 @@ static void feh_event_handle_MotionNotify(XEvent * ev)
mouseover_item = feh_menu_find_at_xy(m, ev->xmotion.x, ev->xmotion.y);

if (selected_item != mouseover_item) {
D(4, ("selecting a menu item\n"));
D(("selecting a menu item\n"));
if (selected_item)
feh_menu_deselect_selected(m);
if ((mouseover_item)
Expand Down Expand Up @@ -411,7 +411,7 @@ static void feh_event_handle_MotionNotify(XEvent * ev)
opt.mode = MODE_PAN;
winwid->mode = MODE_PAN;
}
D(5, ("Panning\n"));
D(("Panning\n"));
orig_x = winwid->im_x;
orig_y = winwid->im_y;

Expand All @@ -420,7 +420,7 @@ static void feh_event_handle_MotionNotify(XEvent * ev)

winwidget_sanitise_offsets(winwid);

D(4, ("im_x %d, im_w %d, off %d, mx %d\n", winwid->im_x,
D(("im_x %d, im_w %d, off %d, mx %d\n", winwid->im_x,
winwid->im_w, winwid->click_offset_x, ev->xmotion.x));

/* XWarpPointer generates a MotionNotify event which we will
Expand Down Expand Up @@ -464,7 +464,7 @@ static void feh_event_handle_MotionNotify(XEvent * ev)
while (XCheckTypedWindowEvent(disp, ev->xmotion.window, MotionNotify, ev));
winwid = winwidget_get_from_window(ev->xmotion.window);
if (winwid) {
D(5, ("Rotating\n"));
D(("Rotating\n"));
if (!winwid->has_rotated) {
Imlib_Image temp;

Expand All @@ -477,7 +477,7 @@ static void feh_event_handle_MotionNotify(XEvent * ev)
winwid->has_rotated = 1;
}
winwid->im_angle = (ev->xmotion.x - winwid->w / 2) / ((double) winwid->w / 2) * 3.1415926535;
D(5, ("angle: %f\n", winwid->im_angle));
D(("angle: %f\n", winwid->im_angle));
winwidget_render_image(winwid, 0, 0);
}
} else if (opt.mode == MODE_BLUR) {
Expand All @@ -487,11 +487,11 @@ static void feh_event_handle_MotionNotify(XEvent * ev)
Imlib_Image temp, ptr;
signed int blur_radius;

D(5, ("Blurring\n"));
D(("Blurring\n"));

temp = gib_imlib_clone_image(winwid->im);
blur_radius = (((double) ev->xmotion.x / winwid->w) * 20) - 10;
D(5, ("angle: %d\n", blur_radius));
D(("angle: %d\n", blur_radius));
if (blur_radius > 0)
gib_imlib_image_sharpen(temp, blur_radius);
else
Expand Down

0 comments on commit ae46674

Please sign in to comment.