fix build error

error: ‘mask’ undeclared (first use in this function)
add _DEVICE macro

Because we have to treat GdkDevice* type
suppress incompatible pointer type warning