Misc #204: Add glx_take_screenshot() & others
- Add glx_take_screenshot() for taking a screenshot. With ImageMagick
the output data could be viewed in this way:
display -size [SCREEN-WIDTH]x[SCREEN-HEIGHT] -depth 8 -flip
rgb:[PATH]
(#204)
- Add D-Bus command `opts_get string:paint_on_overlay_id` to get X
Composite overlay window ID. (#204)
- Code cleanup.
This commit is contained in:
25
src/common.h
25
src/common.h
@@ -2208,6 +2208,9 @@ glx_render_(session_t *ps, const glx_texture_t *ptex,
|
||||
void
|
||||
glx_swap_copysubbuffermesa(session_t *ps, XserverRegion reg);
|
||||
|
||||
unsigned char *
|
||||
glx_take_screenshot(session_t *ps, int *out_length);
|
||||
|
||||
#ifdef CONFIG_VSYNC_OPENGL_GLSL
|
||||
GLuint
|
||||
glx_create_shader(GLenum shader_type, const char *shader_str);
|
||||
@@ -2484,6 +2487,28 @@ c2_matchd(session_t *ps, win *w, const c2_lptr_t *condlst,
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Dump the given data to a file.
|
||||
*/
|
||||
static inline bool
|
||||
write_binary_data(const char *path, const unsigned char *data, int length) {
|
||||
if (!data)
|
||||
return false;
|
||||
FILE *f = fopen(path, "wb");
|
||||
if (!f) {
|
||||
printf_errf("(\"%s\"): Failed to open file for writing.", path);
|
||||
return false;
|
||||
}
|
||||
int wrote_len = fwrite(data, sizeof(unsigned char), length, f);
|
||||
fclose(f);
|
||||
if (wrote_len != length) {
|
||||
printf_errf("(\"%s\"): Failed to write all blocks: %d / %d", path,
|
||||
wrote_len, length);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Dump raw bytes in HEX format.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user