imlib.c (scrot-1.6.tar.bz2) | : | imlib.c (scrot-1.7.tar.bz2) | ||
---|---|---|---|---|
/* imlib.c | /* imlib.c | |||
Copyright 1999-2000 Tom Gilbert | Copyright 1999-2000 Tom Gilbert | |||
Copyright 2020 Daniel T. Borelli <daltomi@disroot.org> | Copyright 2020-2021 Daniel T. Borelli <danieltborelli@gmail.com> | |||
Copyright 2020 ideal <idealities@gmail.com> | Copyright 2020 ideal <idealities@gmail.com> | |||
Copyright 2020 Sean Brennan <zettix1@gmail.com> | Copyright 2020 Sean Brennan <zettix1@gmail.com> | |||
Copyright 2021 Christopher R. Nelson <christopher.nelson@languidnights.com> | Copyright 2021 Christopher R. Nelson <christopher.nelson@languidnights.com> | |||
Copyright 2021 Peter Wu <peterwu@hotmail.com> | ||||
Permission is hereby granted, free of charge, to any person obtaining a copy | Permission is hereby granted, free of charge, to any person obtaining a copy | |||
of this software and associated documentation files (the "Software"), to | of this software and associated documentation files (the "Software"), to | |||
deal in the Software without restriction, including without limitation the | deal in the Software without restriction, including without limitation the | |||
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or | 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 | sell copies of the Software, and to permit persons to whom the Software is | |||
furnished to do so, subject to the following conditions: | furnished to do so, subject to the following conditions: | |||
The above copyright notice and this permission notice shall be included in | The above copyright notice and this permission notice shall be included in | |||
all copies of the Software and its documentation and acknowledgment shall be | all copies of the Software and its documentation and acknowledgment shall be | |||
skipping to change at line 30 | skipping to change at line 31 | |||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | |||
THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | |||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | 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. | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |||
*/ | */ | |||
#include "scrot.h" | ||||
#include "options.h" | #include "options.h" | |||
#include "scrot.h" | ||||
Display *disp = NULL; | Display* disp = NULL; | |||
Visual *vis = NULL; | Visual* vis = NULL; | |||
Screen *scr = NULL; | Screen* scr = NULL; | |||
Colormap cm; | Colormap cm; | |||
int depth; | int depth; | |||
Window root = 0; | Window root = 0; | |||
void | void initXAndImlib(char* dispStr, int screenNumber) | |||
init_x_and_imlib(char *dispstr, int screen_num) | ||||
{ | { | |||
disp = XOpenDisplay(dispstr); | disp = XOpenDisplay(dispStr); | |||
if (!disp) { | if (!disp) { | |||
fprintf(stderr, "Can't open X display. It *is* running, yeah? ["); | ||||
fprintf(stderr, "%s", dispstr ? dispstr : | char const* const format = "Can't open X display. It *is* running, " | |||
(getenv("DISPLAY") ? getenv("DISPLAY") : "NULL")); | "yeah? [%s]"; | |||
fprintf(stderr, "]\n"); | ||||
exit(EXIT_FAILURE); | char const* env = NULL; | |||
} | ||||
char const* const value = dispStr ? dispStr : | ||||
if (screen_num) | (env = getenv("DISPLAY")) ? env : "NULL"; | |||
scr = ScreenOfDisplay(disp, screen_num); | ||||
else | errx(EXIT_FAILURE, format, value); | |||
scr = ScreenOfDisplay(disp, DefaultScreen(disp)); | } | |||
vis = DefaultVisual(disp, XScreenNumberOfScreen(scr)); | if (screenNumber) | |||
depth = DefaultDepth(disp, XScreenNumberOfScreen(scr)); | scr = ScreenOfDisplay(disp, screenNumber); | |||
cm = DefaultColormap(disp, XScreenNumberOfScreen(scr)); | else | |||
root = RootWindow(disp, XScreenNumberOfScreen(scr)); | scr = ScreenOfDisplay(disp, DefaultScreen(disp)); | |||
imlib_context_set_drawable(root); | vis = DefaultVisual(disp, XScreenNumberOfScreen(scr)); | |||
imlib_context_set_display(disp); | depth = DefaultDepth(disp, XScreenNumberOfScreen(scr)); | |||
imlib_context_set_visual(vis); | cm = DefaultColormap(disp, XScreenNumberOfScreen(scr)); | |||
imlib_context_set_colormap(cm); | root = RootWindow(disp, XScreenNumberOfScreen(scr)); | |||
imlib_context_set_color_modifier(NULL); | ||||
imlib_context_set_operation(IMLIB_OP_COPY); | imlib_context_set_drawable(root); | |||
imlib_context_set_display(disp); | ||||
imlib_context_set_visual(vis); | ||||
imlib_context_set_colormap(cm); | ||||
imlib_context_set_color_modifier(NULL); | ||||
imlib_context_set_operation(IMLIB_OP_COPY); | ||||
} | } | |||
End of changes. 7 change blocks. | ||||
32 lines changed or deleted | 37 lines changed or added |