rem: W_ColorPanel    *panel = (W_ColorPanel*)(data); W_Screen    *scr = WMWidgetScreen(panel->win); Cursor        magCursor; int            x, y; Pixmap        pixmap; XEvent        event; WMPoint        initialPosition;   if (panel->selectionBackImg) { XFreePixmap(WMWidgetScreen(panel->win)->display, panel->selectionBackImg); panel->selectionBackImg = None; }   panel->magnifyGlass = wmalloc(sizeof(MovingView));  panel->magnifyGlass->view = magnifyCreateView(panel); magCursor = magnifyGrabPointer(panel);  initialPosition = magnifyInitialize(panel); x = initialPosition.x; y = initialPosition.y;   while(panel->magnifyGlass->valid) { WMNextEvent(scr->display, &event);  switch (event.type) { case ButtonPress: if (event.xbutton.button == Button1) { updateSwatch(panel, panel->magnifyGlass->color); switch (panel->mode) { case WMWheelModeColorPanel: wheelInit(panel); wheelRender(panel); wheelPaint(panel); break; case WMGrayModeColorPanel: grayInit(panel); break; case WMRGBModeColorPanel: rgbInit(panel); break; case WMCMYKModeColorPanel: cmykInit(panel); break; case WMHSBModeColorPanel: hsbInit(panel); break; default: break; } panel->lastChanged = panel->mode; }  panel->magnifyGlass->valid = False; WMSetButtonSelected(panel->magnifyBtn, False); break;  case MotionNotify:  panel->magnifyGlass->pixmap = magnifyGetStorePixmap( panel, x+1, y+1,                                     event.xmotion.x_root+1, event.xmotion.y_root+1);       x = event.xmotion.x_root; y = event.xmotion.y_root;   W_MoveView(panel->magnifyGlass->view, x - Cursor_x_hot +1, y - Cursor_y_hot +1);   pixmap = magnifyCreatePixmap(panel); XSetWindowBackgroundPixmap(scr->display, panel->magnifyGlass->view->window, pixmap); XClearWindow(scr->display, panel->magnifyGlass->view->window);  XFreePixmap(scr->display, pixmap); break;  default: WMHandleEvent(&event); break; }  } panel->magnifyGlass->valid = False;  XUngrabPointer(scr->display, CurrentTime); XFreeCursor(scr->display, magCursor); W_DestroyView(panel->magnifyGlass->view);  XFreePixmap(scr->display, panel->magnifyGlass->mask); XFreePixmap(scr->display, panel->magnifyGlass->pixmap); free(panel->magnifyGlass);
add: W_ColorPanel	*panel = (W_ColorPanel*)(data); W_Screen	*scr = WMWidgetScreen(panel->win); Cursor		magCursor; int			x, y; Pixmap		pixmap; XEvent		event; WMPoint		initialPosition;   if (panel->selectionBackImg) { XFreePixmap(WMWidgetScreen(panel->win)->display, panel->selectionBackImg); panel->selectionBackImg = None; }   panel->magnifyGlass = wmalloc(sizeof(MovingView)); panel->magnifyGlass->view = magnifyCreateView(panel);  initialPosition = magnifyInitialize(panel); x = initialPosition.x; y = initialPosition.y;  W_MoveView(panel->magnifyGlass->view, x - Cursor_x_hot +1, y - Cursor_y_hot +1); W_MapView(panel->magnifyGlass->view);  magCursor = magnifyGrabPointer(panel);  while(panel->magnifyGlass->valid) { WMNextEvent(scr->display, &event);  switch (event.type) { case ButtonPress: if (event.xbutton.button == Button1) { updateSwatch(panel, panel->magnifyGlass->color); switch (panel->mode) { case WMWheelModeColorPanel: wheelInit(panel); wheelRender(panel); wheelPaint(panel); break; case WMGrayModeColorPanel: grayInit(panel); break; case WMRGBModeColorPanel: rgbInit(panel); break; case WMCMYKModeColorPanel: cmykInit(panel); break; case WMHSBModeColorPanel: hsbInit(panel); break; default: break; } panel->lastChanged = panel->mode; }  panel->magnifyGlass->valid = False; WMSetButtonSelected(panel->magnifyBtn, False); break;  case MotionNotify:  panel->magnifyGlass->pixmap = magnifyGetStorePixmap( panel, x+1, y+1,									 event.xmotion.x_root+1, event.xmotion.y_root+1);	   x = event.xmotion.x_root; y = event.xmotion.y_root;   W_MoveView(panel->magnifyGlass->view, x - Cursor_x_hot +1, y - Cursor_y_hot +1);   pixmap = magnifyCreatePixmap(panel); XSetWindowBackgroundPixmap(scr->display, panel->magnifyGlass->view->window, pixmap); XClearWindow(scr->display, panel->magnifyGlass->view->window);  XFreePixmap(scr->display, pixmap); break;  case FocusOut:		 case FocusIn:  XUngrabPointer(scr->display, CurrentTime); W_UnmapView(panel->magnifyGlass->view);  magnifyInitialize(panel);  W_MapView(panel->magnifyGlass->view); XGrabPointer (scr->display, panel->magnifyGlass->view->window, True, PointerMotionMask | ButtonPressMask, GrabModeAsync, GrabModeAsync, scr->rootWin, magCursor, CurrentTime); break;  default: WMHandleEvent(&event); break; }  } panel->magnifyGlass->valid = False;  XUngrabPointer(scr->display, CurrentTime); XFreeCursor(scr->display, magCursor); W_DestroyView(panel->magnifyGlass->view);  XFreePixmap(scr->display, panel->magnifyGlass->mask); XFreePixmap(scr->display, panel->magnifyGlass->pixmap); free(panel->magnifyGlass);
context: magnifyPutCursor(WMWidget *w, void *data){    W_ColorPanel    *panel = (W_ColorPanel*)(data);    W_Screen    *scr = WMWidgetScreen(panel->win);    Cursor        magCursor;    int            x, y;    Pixmap        pixmap;    XEvent        event;    WMPoint        initialPosition;        /* Destroy wheelBackImg, so it'll update properly */    if (panel->selectionBackImg) {        XFreePixmap(WMWidgetScreen(panel->win)->display, panel->selectionBackImg);        panel->selectionBackImg = None;    }        /* Create magnifying glass */    panel->magnifyGlass = wmalloc(sizeof(MovingView));        panel->magnifyGlass->view = magnifyCreateView(panel);    magCursor = magnifyGrabPointer(panel);        initialPosition = magnifyInitialize(panel);    x = initialPosition.x;    y = initialPosition.y;            while(panel->magnifyGlass->valid)     {        WMNextEvent(scr->display, &event);	        switch (event.type)        {	 case ButtonPress:	    if (event.xbutton.button == Button1) {		updateSwatch(panel, panel->magnifyGlass->color);		switch (panel->mode) {		 case WMWheelModeColorPanel:		    wheelInit(panel);		    wheelRender(panel);		    wheelPaint(panel);		    break;		 case WMGrayModeColorPanel:		    grayInit(panel);		    break;		 case WMRGBModeColorPanel:		    rgbInit(panel);		    break;		 case WMCMYKModeColorPanel:		    cmykInit(panel);		    break;		 case WMHSBModeColorPanel:		    hsbInit(panel);		    break;		 default:		    break;		}		panel->lastChanged = panel->mode; 	    }	    	    panel->magnifyGlass->valid = False;	    WMSetButtonSelected(panel->magnifyBtn, False);	    break;	    	 case MotionNotify:	    /* Get a "dirty rectangle" */	    panel->magnifyGlass->pixmap = magnifyGetStorePixmap(								panel, x+1, y+1,                                    /* Cool, a circular reference ! */								event.xmotion.x_root+1, event.xmotion.y_root+1);    /* also free's magnifyGlass->pixmap */	    	    /* Update coordinates */	    x = event.xmotion.x_root;	    y = event.xmotion.y_root;	    	    /* Move view */	    W_MoveView(panel->magnifyGlass->view, x - Cursor_x_hot +1, y - Cursor_y_hot +1);	    	    /* Put new image (with magn.) in view */	    pixmap = magnifyCreatePixmap(panel);	    XSetWindowBackgroundPixmap(scr->display, panel->magnifyGlass->view->window, pixmap);	    XClearWindow(scr->display, panel->magnifyGlass->view->window);	    	    XFreePixmap(scr->display, pixmap);	    break;	    	 default:	    WMHandleEvent(&event);	    break;        } /* of switch */    }    panel->magnifyGlass->valid = False;        XUngrabPointer(scr->display, CurrentTime);    XFreeCursor(scr->display, magCursor);    W_DestroyView(panel->magnifyGlass->view);        XFreePixmap(scr->display, panel->magnifyGlass->mask);    XFreePixmap(scr->display, panel->magnifyGlass->pixmap);    free(panel->magnifyGlass);}