xvig.c.16

来自「gsac程序包」· 16 代码 · 共 1,146 行 · 第 1/3 页

16
1,146
字号
              prev_cursor_x = event.xmotion.x;              prev_cursor_y = event.xmotion.y;		if(prev_cursor_x < dc_left+border)			prev_cursor_x = dc_left+border;		if(prev_cursor_x > dc_right+border)			prev_cursor_x = dc_right+border;		if(prev_cursor_y > Ldc_top - border )			prev_cursor_y = Ldc_top - border ;		if(prev_cursor_y < border )			prev_cursor_y = border;		event.xmotion.x = prev_cursor_x;		event.xmotion.y = prev_cursor_y;			cur_x = event.xmotion.x;	cur_y = event.xmotion.y;          if (!XSendEvent(display, dummy_window, False, NoEventMask, &event))            fprintf(stderr,                 "ERROR (XviG) : Cannot send KeyPress or ButtonPress event.\n");if(DoGrabKeyboard){	XUngrabKeyboard(display,CurrentTime);	DoGrabKeyboard = NO;}          XSetWindowBorderPixmap(display, window, border_noselect);          if (sense_kbd_save)          {            sense_kbd_set = True;            XSelectInput(display, window, KeyPressMask | ExposureMask);            sense_kbd = False;          }          else            XSelectInput(display, window, ExposureMask);          break;      case MotionNotify:          /* printf("INFO (XviG) : MotionNotify event ...\n"); */          while (XCheckMaskEvent(display, PointerMotionMask, &event));          if (cursor_on)          {            XSetFunction(display, gc, GXxor);              XSetForeground(display, gc, xhair_color);              if (cursor_drawn)              {		draw_cursor( curstype,  prev_cursor_x,  prev_cursor_y, 			border+dc_ClipLeft, Ldc_top-border-dc_ClipTop, 			border+dc_ClipRight, Ldc_top-border-dc_ClipBottom);              }              prev_cursor_x = event.xmotion.x;              prev_cursor_y = event.xmotion.y;		if(prev_cursor_x < dc_left+border)			prev_cursor_x = dc_left+border;		if(prev_cursor_x > dc_right+border)			prev_cursor_x = dc_right+border;		if(prev_cursor_y > Ldc_top - border )			prev_cursor_y = Ldc_top - border ;		if(prev_cursor_y < border )			prev_cursor_y = border;		if(inclipregion(prev_cursor_x,prev_cursor_y)){              		XDefineCursor(display, window, empty_cursor);			curstype = user_curstype;		} else			curstype = 0;		draw_cursor( curstype,  prev_cursor_x,  prev_cursor_y, 			border+dc_ClipLeft, Ldc_top-border-dc_ClipTop, 			border+dc_ClipRight, Ldc_top-border-dc_ClipBottom);            cursor_drawn = True;          }          break;      case Expose:          /* printf("INFO (XviG) : Expose event ...\n"); */          if (event.xexpose.count == 0)          {            Refresh_Screen();            cursor_drawn = False;            XGetGeometry(display, window, &root_rtn, &x_rtn, &y_rtn,                         &xhair_width, &xhair_height, &bwidth_rtn, &depth_rtn);          }          break;      case ClientMessage:          /* printf("INFO (XviG) : ClientMessage event ...\n"); */          if (event.xclient.message_type == MESSAGE_KEY_atom)          {DoGrabKeyboard = YES;if(keyboard_active)XGrabKeyboard(display,window,False,GrabModeAsync,GrabModeAsync,CurrentTime);            XSetWindowBorderPixmap(display, window, border_select);            if (cursor_type)            {              XSelectInput(display, window,  EnterWindowMask | LeaveWindowMask |                           KeyPressMask | PointerMotionMask | ExposureMask);              XDefineCursor(display, window, empty_cursor);              cursor_on = True;            }            else            {              XSelectInput(display, window, KeyPressMask | ExposureMask);              cursor_on = False;            }            cursor_drawn = False;            sense_kbd_set = False;            break;          }          if (event.xclient.message_type == MESSAGE_BUTTON_atom)          {            XSetWindowBorderPixmap(display, window, border_select);            if (cursor_type)            {              XSelectInput(display, window, EnterWindowMask | LeaveWindowMask |                           ButtonPressMask | PointerMotionMask | ExposureMask);              XDefineCursor(display, window, empty_cursor);              cursor_on = True;            }            else            {              XSelectInput(display, window, ButtonPressMask | ExposureMask);              cursor_on = False;            }            cursor_drawn = False;            break;          }          if (event.xclient.message_type == MESSAGE_KEY_BUTTON_atom)          {DoGrabKeyboard = YES;if(keyboard_active)XGrabKeyboard(display,window,False,GrabModeAsync,GrabModeAsync,CurrentTime);            XSetWindowBorderPixmap(display, window, border_select);            if (cursor_type)            {              XSelectInput(display, window,  EnterWindowMask | LeaveWindowMask |                           KeyPressMask | ButtonPressMask |                           PointerMotionMask | ExposureMask);              XDefineCursor(display, window, empty_cursor);              cursor_on = True;            }            else            {              XSelectInput(display, window,  EnterWindowMask | LeaveWindowMask |                           KeyPressMask | ButtonPressMask | ExposureMask);              cursor_on = False;            }            cursor_drawn = False;            sense_kbd_set = False;            break;          }          if (event.xclient.message_type == MESSAGE_SIZE_atom)          {            Window_Size();            break;          }          if (event.xclient.message_type == MESSAGE_SENSEKBD_ON_atom)          {            sense_kbd_set = sense_kbd_save = True;            sense_char = event.xclient.data.b[0];            XSelectInput(display, window, KeyPressMask | ExposureMask);            sense_kbd = False;            break;          }          if (event.xclient.message_type == MESSAGE_SENSEKBD_OFF_atom)          {            sense_kbd_set = sense_kbd_save = False;            XSelectInput(display, window, ExposureMask);            sense_kbd = False;            break;          }          if (event.xclient.message_type == MESSAGE_SENSEKBD_atom)          {            event.xclient.message_type = MESSAGE_SENSEKBD_atom;            event.xclient.format = 8;            event.xclient.data.b[0] = sense_kbd ? DATA_SENSEKBD_YES                                                : DATA_SENSEKBD_NO;            event.type = ClientMessage;            if (!XSendEvent(display, dummy_window, False, NoEventMask, &event))              fprintf(stderr,                     "ERROR (XviG) : Cannot send ClientMessage 'sense_kbd'.\n");            sense_kbd = False;            break;          }          if (event.xclient.message_type == MESSAGE_CURSOR_atom)          {            cursor_type = event.xclient.data.l[0];            if (cursor_type == DATA_CURSOR_ARROW) {		XDefineCursor(display, window, arrow_cursor);              user_curstype = 0;		old_curstype = user_curstype ;            } else if (cursor_type == DATA_CURSOR_XORARROW) {              xhair_color = (unsigned long) event.xclient.data.l[1];              XDefineCursor(display, window, empty_cursor);              user_curstype = 1;		old_curstype = user_curstype ;            } else if (cursor_type == DATA_CURSOR_XHAIR) {              xhair_color = (unsigned long) event.xclient.data.l[1];              XDefineCursor(display, window, empty_cursor);              user_curstype = 2;		old_curstype = user_curstype ;            } else if (cursor_type == DATA_CURSOR_PLUS) {              xhair_color = (unsigned long) event.xclient.data.l[1];              XDefineCursor(display, window, empty_cursor);              user_curstype = 3;		old_curstype = user_curstype ;            } else if (cursor_type == DATA_CURSOR_BOX ) {              xhair_color = (unsigned long) event.xclient.data.l[1];              XDefineCursor(display, window, empty_cursor);              user_curstype = 4;            } else if (cursor_type == DATA_CURSOR_RUBBER ) {              xhair_color = (unsigned long) event.xclient.data.l[1];              XDefineCursor(display, window, empty_cursor);              user_curstype = 5;            } else if (cursor_type == DATA_CURSOR_OFF ) {              user_curstype = old_curstype;		cur_x = -1 ; cur_y = -1 ;	    } else if (cursor_type != DATA_CURSOR_ARROW) {              cursor_width = (unsigned int) event.xclient.data.l[1];              cursor_height = (unsigned int) event.xclient.data.l[2];              cursor_hot_x = (int) event.xclient.data.l[3];              cursor_hot_y = (int) event.xclient.data.l[4];              user_curstype = 7;            xhair_color = 1;            }/*            XSetFunction(display, gc, GXxor);              XSetForeground(display, gc, xhair_color);		if(inclipregion(prev_cursor_x,prev_cursor_y)){              		XDefineCursor(display, window, empty_cursor);			curstype = user_curstype;		} else			curstype = 0;		draw_cursor( curstype,  prev_cursor_x,  prev_cursor_y, 			border+dc_ClipLeft, Ldc_top-border-dc_ClipTop, 			border+dc_ClipRight, Ldc_top-border-dc_ClipBottom);              cursor_on = True;              cursor_drawn = True;*/              cursor_type = 1;            break;          }          if (event.xclient.message_type == MESSAGE_QUIT_atom)          {            do_event_loop = False;            break;          }          if (event.xclient.message_type == wm_protocols_atom)          {            if ((Atom) event.xclient.data.l[0] != wm_delete_window_atom)              printf("WARNING (XviG) : Unknown Protocols message received.\n");            /*            else              printf("INFO (XviG) : WM_DELETE_WINDOW received.\n");            */            break;          }          /* begin rbh extension */          if (event.xclient.message_type == MESSAGE_BOUNDS_atom)          {                border = event.xclient.data.l[0];                title  = event.xclient.data.l[1];		dc_right = Ldc_right - border - border;        	dc_top = Ldc_top -  border - border - title;            break;          }          if (event.xclient.message_type == MESSAGE_CLIP_atom)          {        	dc_ClipLeft	= event.xclient.data.l[0];        	dc_ClipBottom	= event.xclient.data.l[1];        	dc_ClipRight	= event.xclient.data.l[2];        	dc_ClipTop	= event.xclient.data.l[3];            break;          }          if (event.xclient.message_type == MESSAGE_REVERSE_atom)          {		Refresh_Screen();		printf("REVERSE %ld \n",			event.xclient.data.l[0]);            break;          }          if (event.xclient.message_type == MESSAGE_TOGRAY_atom)          {		printf("TOGRAY %ld \n",			event.xclient.data.l[0]);            break;          }          if (event.xclient.message_type == MESSAGE_LCMAP_SIZE_atom)          {		int cmapsize;        	cmapsize	= event.xclient.data.l[0];/*printf("LCMAP_SIZE %d\n",cmapsize);*/		if(color != (XColor *)NULL)			free(color);		color = (XColor *) malloc(cmapsize * sizeof(XColor));		colormap = DefaultColormap(display, screen_nr);            break;          }          if (event.xclient.message_type == MESSAGE_LCMAP_ENTRY_atom)          {		int i;        	i	= event.xclient.data.l[0];		color[i].red    =  257*event.xclient.data.l[1];		color[i].green  =  257*event.xclient.data.l[2];		color[i].blue   =  257*event.xclient.data.l[3];		color[i].flags = DoRed | DoGreen | DoBlue;		if(!XAllocColor(display, colormap, &color[i]))printf("Cannot allocate the color\n");            break;          }          if (event.xclient.message_type == MESSAGE_LCMAP_RESET_atom)          {/*printf("LCMAP_RESET\n");*/XSetWindowColormap(display,window,colormap);            break;          }          /* end   rbh extension */          /*          printf("WARNING (XviG) : Unknown ClientMessage received .....\n");          */      case EnterNotify:/*printf("EnterNotify\n");*/		(keyboard_active = True);;if(keyboard_active)XGrabKeyboard(display,window,False,GrabModeAsync,GrabModeAsync,CurrentTime);elseXUngrabKeyboard(display,CurrentTime);		break;      case LeaveNotify:/*printf("LeaveNotify\n");*/			 (keyboard_active = False);if(keyboard_active)XGrabKeyboard(display,window,False,GrabModeAsync,GrabModeAsync,CurrentTime);elseXUngrabKeyboard(display,CurrentTime);		break;      case FocusIn:/*printf("FocusIn\n");*/		focus = True;		keyboard_active = True;XGrabKeyboard(display,window,False,GrabModeAsync,GrabModeAsync,CurrentTime);		break;      case FocusOut:/*printf("FocusOut\n");*/		focus = False;		keyboard_active = False;	XUngrabKeyboard(display,CurrentTime);		break;      default: ;    }  }  /*  -- Quit .....  */  Cleanup();  return 0;}/*------------------------------------------------------------------------------------------------------------------------------------------------------------------*/static void Parse_Commandline(int argc,                              char *argv[],                              int *x,                              int *y,                              unsigned int *width,                              unsigned int *height){  long nr;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?