Created
October 25, 2011 16:59
-
-
Save ropery/1313489 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/main.c b/src/main.c | |
index 544715e..bba3273 100644 | |
--- a/src/main.c | |
+++ b/src/main.c | |
@@ -54,8 +54,10 @@ main(int argc, | |
scrot_do_delay(); | |
if (opt.multidisp) { | |
image = scrot_grab_shot_multi(); | |
+ } else if (opt.geometry) { | |
+ image = scrot_grab_shot(opt.x, opt.y, opt.width, opt.height); | |
} else { | |
- image = scrot_grab_shot(); | |
+ image = scrot_grab_shot(0, 0, scr->width, scr->height); | |
} | |
} | |
@@ -148,14 +150,14 @@ scrot_do_delay(void) | |
} | |
Imlib_Image | |
-scrot_grab_shot(void) | |
+scrot_grab_shot(int x, int y, int width, int height) | |
{ | |
Imlib_Image im; | |
XBell(disp, 0); | |
im = | |
- gib_imlib_create_image_from_drawable(root, 0, 0, 0, scr->width, | |
- scr->height, 1); | |
+ gib_imlib_create_image_from_drawable(root, 0, x, y, width, | |
+ height, 1); | |
return im; | |
} | |
@@ -565,7 +567,7 @@ scrot_grab_shot_multi(void) | |
screens = ScreenCount(disp); | |
if (screens < 2) | |
- return scrot_grab_shot(); | |
+ return scrot_grab_shot(0, 0, scr->width, scr->height); | |
dispstr = DisplayString(disp); | |
diff --git a/src/options.c b/src/options.c | |
index dcf2539..9720960 100644 | |
--- a/src/options.c | |
+++ b/src/options.c | |
@@ -44,7 +44,7 @@ init_parse_options(int argc, char **argv) | |
static void | |
scrot_parse_option_array(int argc, char **argv) | |
{ | |
- static char stropts[] = "bcd:e:hmq:st:v+:"; | |
+ static char stropts[] = "bcd:e:g:hmq:st:v+:"; | |
static struct option lopts[] = { | |
/* actions */ | |
{"help", 0, 0, 'h'}, /* okay */ | |
@@ -54,6 +54,7 @@ scrot_parse_option_array(int argc, char **argv) | |
{"border", 0, 0, 'b'}, | |
{"multidisp", 0, 0, 'm'}, | |
/* toggles */ | |
+ {"geometry", 1, 0, 'g'}, | |
{"thumb", 1, 0, 't'}, | |
{"delay", 1, 0, 'd'}, | |
{"quality", 1, 0, 'q'}, | |
@@ -86,6 +87,9 @@ scrot_parse_option_array(int argc, char **argv) | |
case 'e': | |
opt.exec = gib_estrdup(optarg); | |
break; | |
+ case 'g': | |
+ options_parse_geometry(optarg); | |
+ break; | |
case 'm': | |
opt.multidisp = 1; | |
break; | |
@@ -158,6 +162,21 @@ name_thumbnail(char *name) | |
} | |
void | |
+options_parse_geometry(char *optarg) | |
+{ | |
+ int x = 0, y = 0; | |
+ unsigned int w = 0, h = 0; | |
+ | |
+ XParseGeometry(optarg, &x, &y, &w, &h); | |
+ | |
+ opt.geometry = 1; | |
+ opt.x = x; | |
+ opt.y = y; | |
+ opt.width = w; | |
+ opt.height = h; | |
+} | |
+ | |
+void | |
options_parse_thumbnail(char *optarg) | |
{ | |
char *tok; | |
diff --git a/src/options.h b/src/options.h | |
index ae33b52..f36ed44 100644 | |
--- a/src/options.h | |
+++ b/src/options.h | |
@@ -32,6 +32,11 @@ struct __scrotoptions | |
int delay; | |
int countdown; | |
int select; | |
+ int geometry; | |
+ unsigned int width; | |
+ unsigned int height; | |
+ int x; | |
+ int y; | |
int quality; | |
int border; | |
int multidisp; | |
@@ -45,6 +50,7 @@ struct __scrotoptions | |
void init_parse_options(int argc, char **argv); | |
char *name_thumbnail(char *name); | |
+void options_parse_geometry(char *optarg); | |
void options_parse_thumbnail(char *optarg); | |
extern scrotoptions opt; | |
diff --git a/src/scrot.h b/src/scrot.h | |
index c9557ee..c908512 100644 | |
--- a/src/scrot.h | |
+++ b/src/scrot.h | |
@@ -67,7 +67,7 @@ void show_version(void); | |
void show_mini_usage(void); | |
void init_x_and_imlib(char *dispstr, int screen_num); | |
char *chop_file_from_full_path(char *str); | |
-Imlib_Image scrot_grab_shot(void); | |
+Imlib_Image scrot_grab_shot(int x, int y, int width, int height); | |
void scrot_exec_app(Imlib_Image image, struct tm *tm, | |
char *filename_im, char *filename_thumb); | |
void scrot_do_delay(void); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment