# HG changeset patch # User John Tsiombikas # Date 1299761926 -7200 # Node ID 8555f3aabbc79d09c4679b0b859a9abd1e34b761 created hg repository for xresize, useful little bugger diff -r 000000000000 -r 8555f3aabbc7 Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Makefile Thu Mar 10 14:58:46 2011 +0200 @@ -0,0 +1,13 @@ +obj = xresize.o +bin = xresize + +CC = gcc +CFLAGS = -pedantic -Wall -g -I/usr/X11R6/include -DUSE_XRANDR -DUSE_XF86VM +LDFLAGS = -L/usr/X11R6/lib -lX11 -lXrandr -lXxf86vm + +$(bin): $(obj) + $(CC) -o $@ $(obj) $(LDFLAGS) + +.PHONY: clean +clean: + rm -f $(obj) $(bin) diff -r 000000000000 -r 8555f3aabbc7 xresize.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/xresize.c Thu Mar 10 14:58:46 2011 +0200 @@ -0,0 +1,261 @@ +#include +#include +#include +#include +#include + +#ifdef USE_XRANDR +#include + +char *randr_err_msg[] = { + "RRSetConfigSuccess", + "RRSetConfigInvalidConfigTime", + "RRSetConfigInvalidTime", + "RRSetConfigFailed" +}; +#endif + +#ifdef USE_XF86VM +#include +#endif + +int get_size(Display *dpy, int scr, int *xsz, int *ysz); +int set_size(Display *dpy, int scr, int xsz, int ysz); + +const char *usage = "usage: %s [options]\n" + "options:\n" + " -s x set specified screen size\n" + " -f force size change without current size detection\n" + " -h this usage information\n"; + +int use_xrandr = 1; +int use_xf86vm = 1; + +int main(int argc, char **argv) +{ + int i, cur_xres, cur_yres, xres = -1, yres = -1; + int force = 0; + Display *dpy; + int scr; + + for(i=1; ihdisplay == xsz && modes[i]->vdisplay == ysz) { + break; + } + } + if(i == mode_count) { + fprintf(stderr, "requested size unsuppored by the X server configuration\n"); + XFree(modes); + return -1; + } + + if(!XF86VidModeSwitchToMode(dpy, scr, modes[i])) { + fprintf(stderr, "failed to set requested size with xf86vm\n"); + XFree(modes); + return -1; + } + XF86VidModeSetViewPort(dpy, scr, 0, 0); + + XFree(modes); + return 0; + } +#endif + + fprintf(stderr, "not possible to change display size\n"); + return -1; +}