x11: capture pointer when a button is pressed
This commit is contained in:
		
							parent
							
								
									463105b0d5
								
							
						
					
					
						commit
						73f5f1d214
					
				@ -1739,6 +1739,10 @@ int Get_input(int sleep_time)
 | 
				
			|||||||
          }
 | 
					          }
 | 
				
			||||||
          break;
 | 
					          break;
 | 
				
			||||||
        case ButtonPress: // left = 1, middle = 2, right = 3, wheelup = 4, wheeldown = 5
 | 
					        case ButtonPress: // left = 1, middle = 2, right = 3, wheelup = 4, wheeldown = 5
 | 
				
			||||||
 | 
					          XGrabPointer(X11_display, X11_window, True,
 | 
				
			||||||
 | 
					                       PointerMotionMask | ButtonPressMask | ButtonReleaseMask,
 | 
				
			||||||
 | 
					                       GrabModeAsync, GrabModeAsync,
 | 
				
			||||||
 | 
					                       X11_window, None, CurrentTime);
 | 
				
			||||||
          //printf("Press button = %d state = 0x%08x\n", event.xbutton.button, event.xbutton.state);
 | 
					          //printf("Press button = %d state = 0x%08x\n", event.xbutton.button, event.xbutton.state);
 | 
				
			||||||
          if (event.xkey.state & ShiftMask)
 | 
					          if (event.xkey.state & ShiftMask)
 | 
				
			||||||
            mod |= MOD_SHIFT;
 | 
					            mod |= MOD_SHIFT;
 | 
				
			||||||
@ -1777,6 +1781,7 @@ int Get_input(int sleep_time)
 | 
				
			|||||||
          }
 | 
					          }
 | 
				
			||||||
          break;
 | 
					          break;
 | 
				
			||||||
        case ButtonRelease:
 | 
					        case ButtonRelease:
 | 
				
			||||||
 | 
					          XUngrabPointer(X11_display, CurrentTime);
 | 
				
			||||||
          //printf("Release button = %d\n", event.xbutton.button);
 | 
					          //printf("Release button = %d\n", event.xbutton.button);
 | 
				
			||||||
          if(event.xbutton.button == 1 || event.xbutton.button == 3)
 | 
					          if(event.xbutton.button == 1 || event.xbutton.button == 3)
 | 
				
			||||||
          {
 | 
					          {
 | 
				
			||||||
 | 
				
			|||||||
@ -333,5 +333,7 @@ void Define_icon(void)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
void Set_mouse_position(void)
 | 
					void Set_mouse_position(void)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  /// @todo implement screen capture and set position for x11.
 | 
					  XWarpPointer(X11_display, None, X11_window,
 | 
				
			||||||
 | 
					               0, 0, 0, 0,
 | 
				
			||||||
 | 
					               Mouse_X * Pixel_width, Mouse_Y * Pixel_height);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user