File xmset-1.2.dif of Package xmset
--- Makefile
+++ Makefile 2006/09/08 14:20:02
@@ -3,6 +3,7 @@
man_prefix= ${buildroot}/usr/share/man
MANVZ = ${man_prefix}/man1
+CFLAGS=-Wall
all:mouse.o monitor.o xmset.o string.o remote.o ifaddrs.o
gcc -o xmset mouse.o monitor.o xmset.o string.o remote.o ifaddrs.o \
@@ -10,22 +11,22 @@
-L/usr/X11R6/lib -L/usr/X11R6/lib64 -lX11 -lXext -lXxf86misc -lhd
mouse.o:mouse.c
- gcc -c mouse.c
+ gcc -c ${CFLAGS} mouse.c
monitor.o:monitor.c
- gcc -c monitor.c
+ gcc -c ${CFLAGS} monitor.c
xmset.o:xmset.c
- gcc -c xmset.c
+ gcc -c ${CFLAGS} xmset.c
string.o:string.c
- gcc -c string.c
+ gcc -c ${CFLAGS} string.c
remote.o:remote.c remote.h
- gcc -c remote.c
+ gcc -c ${CFLAGS} remote.c
ifaddrs.o:ifaddrs.c ifaddrs.h
- gcc -c ifaddrs.c
+ gcc -c ${CFLAGS} ifaddrs.c
install:
install -d -m 755 ${bindir}
--- hwdata.h
+++ hwdata.h 2006/09/08 14:20:02
@@ -83,6 +83,6 @@
//-----------------------------------
char *vend_id2str(unsigned vend);
MouseData* MouseGetData (void);
-MsgDetect MonitorGetData (void);
+MsgDetect* MonitorGetData (void);
#endif
--- ifaddrs.c
+++ ifaddrs.c 2006/09/08 14:20:02
@@ -401,7 +401,6 @@
pid_t pid = getpid();
int seq;
- int result;
int build ; /* 0 or 1 */
/* ---------------------------------- */
@@ -454,12 +453,10 @@
*ifap = (ifdata != NULL) ? ifa : NULL;
else{
free_data(data, ifdata);
- result = 0;
break;
}
if (data == NULL || ifdata == NULL){
free_data(data, ifdata);
- result = -1;
break;
}
ifl = NULL;
--- monitor.c
+++ monitor.c 2006/09/08 14:20:02
@@ -27,8 +27,8 @@
//===================================
// MonitorGetData...
//-----------------------------------
-MsgDetect MonitorGetData (void) {
- MsgDetect display;
+MsgDetect* MonitorGetData (void) {
+ MsgDetect* display = (MsgDetect*)malloc (sizeof(MsgDetect));
hd_data_t* hd_data;
hd_res_t* res;
hd_t *hd;
@@ -43,12 +43,12 @@
hd = hd_list(hd_data, hw_monitor, 1, NULL);
if (! hd) {
- return (display);
+ return 0;
}
- sprintf(display.model,hd->model);
- sprintf(display.vendor,vend_id2str(hd->vendor.id));
- if (strcmp (display.vendor,"0000") == 0) {
- sprintf(display.vendor,"Generic");
+ sprintf(display->model,hd->model);
+ sprintf(display->vendor,vend_id2str(hd->vendor.id));
+ if (strcmp (display->vendor,"0000") == 0) {
+ sprintf(display->vendor,"Generic");
}
//printf("+++ %s\n",hd->id);
// ...
@@ -56,9 +56,9 @@
// BIOS. Note not all display can be detected here
// ---
#if HD_VERSION >= 5
- sprintf(display.displaytype,"CRT");
+ sprintf(display->displaytype,"CRT");
if (strstr (dumpHID (&hd->device, buf, sizeof buf),"LCD")) {
- sprintf(display.displaytype,"LCD/TFT");
+ sprintf(display->displaytype,"LCD/TFT");
}
#endif
#if HD_VERSION >= 5
@@ -68,13 +68,13 @@
#endif
for(di = di0, i = 0; di; di = di->next, i++) {
if (di->any.type == di_display) {
- display.hsync_max = 0;
- display.vsync_max = 0;
+ display->hsync_max = 0;
+ display->vsync_max = 0;
if (di->display.max_hsync) {
- display.hsync_max = (int)di->display.max_hsync;
+ display->hsync_max = (int)di->display.max_hsync;
}
if (di->display.max_vsync) {
- display.vsync_max = (int)di->display.max_vsync;
+ display->vsync_max = (int)di->display.max_vsync;
}
if (di->display.width) {
bestX = di->display.width;
@@ -85,19 +85,19 @@
}
for(; hd; hd = hd->next) {
- sprintf(display.ddc,"%c",'\0');
+ sprintf(display->ddc,"%c",'\0');
#ifdef DDC_SUPPORT
#if HD_VERSION >= 5
- snprintf(display.ddc, strlen(display.ddc) - 1, "%s%04x",
+ snprintf(display->ddc, strlen(display.ddc) - 1, "%s%04x",
vend_id2str(hd->vendor.id),ID_VALUE(hd->device.id)
);
#else
- snprintf(display.ddc, strlen(display.ddc) - 1, "%s%04x",
+ snprintf(display->ddc, strlen(display->ddc) - 1, "%s%04x",
vend_id2str(hd->vend),ID_VALUE(hd->dev)
);
#endif
- toUpper (display.ddc);
+ toUpper (display->ddc);
#endif
int count = 0;
@@ -105,11 +105,11 @@
switch (res->any.type) {
case res_size:
if (res->size.unit == size_unit_cm) {
- display.dpix = 0;
- display.dpiy = 0;
+ display->dpix = 0;
+ display->dpiy = 0;
if ((res->size.val1) && (res->size.val2)) {
- display.dpix = (int)res->size.val1;
- display.dpiy = (int)res->size.val2;
+ display->dpix = (int)res->size.val1;
+ display->dpiy = (int)res->size.val2;
}
}
break;
@@ -125,17 +125,17 @@
// ---
break;
}
- display.vmodes[count].x = res->monitor.width;
- display.vmodes[count].y = res->monitor.height;
- display.vmodes[count].vsync = res->monitor.vfreq;
- display.vmodes[count].hsync = (int)(
+ display->vmodes[count].x = res->monitor.width;
+ display->vmodes[count].y = res->monitor.height;
+ display->vmodes[count].vsync = res->monitor.vfreq;
+ display->vmodes[count].hsync = (int)(
(res->monitor.height*res->monitor.vfreq)/1000
);
- if (display.vmodes[count].hsync > display.hsync_max) {
- display.vmodes[count].hsync = display.hsync_max;
+ if (display->vmodes[count].hsync > display->hsync_max) {
+ display->vmodes[count].hsync = display->hsync_max;
}
count++;
- display.vesacount = count;
+ display->vesacount = count;
break;
default:
@@ -143,12 +143,12 @@
}
}
if ((bestX > 0) && (bestY > 0)) {
- display.vmodes[count].x = bestX;
- display.vmodes[count].y = bestY;
- display.vmodes[count].hsync = display.hsync_max;
- display.vmodes[count].vsync = display.vsync_max;
+ display->vmodes[count].x = bestX;
+ display->vmodes[count].y = bestY;
+ display->vmodes[count].hsync = display->hsync_max;
+ display->vmodes[count].vsync = display->vsync_max;
count++;
- display.vesacount = count;
+ display->vesacount = count;
}
// ...
// save only the first data block
--- xmset.c
+++ xmset.c 2007/09/04 09:36:05
@@ -374,11 +374,9 @@
char option [256] = "";
char left [256] = "";
struct mouse *pointer;
- struct devnode *dev;
struct stat *linkstatus = NULL;
pointer = (struct mouse*) malloc(sizeof(struct mouse));
- dev = (struct devnode*) malloc(sizeof(struct devnode));
// get commandline options...
//-----------------------------
@@ -624,12 +622,15 @@
// show monitor configuration...
//----------------------------------------
void showMonitorConfig (void) {
- MsgDetect display = MonitorGetData();
- if ( ((display.dpix > 0) && (display.dpix < 100)) &&
- ((display.dpiy > 0) && (display.dpiy < 100))
+ MsgDetect* display = MonitorGetData();
+ if (! display) {
+ exit (0);
+ }
+ if ( ((display->dpix > 0) && (display->dpix < 100)) &&
+ ((display->dpiy > 0) && (display->dpiy < 100))
) {
- int x = display.dpix * 10;
- int y = display.dpiy * 10;
+ int x = display->dpix * 10;
+ int y = display->dpiy * 10;
printf ("DisplaySize %d %d",x,y);
}
exit (0);
@@ -645,9 +646,6 @@
int count = 1;
for (lp=mp; lp; lp=lp->next) {
- printf("Section \"InputDevice\"\n");
- printf(" Driver \"mouse\"\n");
- printf(" Identifier \"Mouse[%d]\"\n",count);
if (
(strstr(lp->name,"Tablet") != NULL) ||
(strstr(lp->name,"tablet") != NULL) ||
@@ -657,6 +655,9 @@
// Tablet detected shouldn't be handled as mouse
continue;
}
+ printf("Section \"InputDevice\"\n");
+ printf(" Driver \"mouse\"\n");
+ printf(" Identifier \"Mouse[%d]\"\n",count);
if (lp->protocol) {
printf(" Option \"Protocol\" \"%s\"\n",lp->protocol);
}