All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.freedesktop.wayland.server.WlPointerResource Maven / Gradle / Ivy

The newest version!
package org.freedesktop.wayland.server;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.freedesktop.wayland.util.Arguments;
import org.freedesktop.wayland.util.Interface;
import org.freedesktop.wayland.util.Message;
// 
//
//    Copyright © 2008-2011 Kristian Høgsberg
//    Copyright © 2010-2011 Intel Corporation
//    Copyright © 2012-2013 Collabora, Ltd.
//
//    Permission is hereby granted, free of charge, to any person
//    obtaining a copy of this software and associated documentation files
//    (the "Software"), to deal in the Software without restriction,
//    including without limitation the rights to use, copy, modify, merge,
//    publish, distribute, sublicense, and/or sell copies of the Software,
//    and to permit persons to whom the Software is furnished to do so,
//    subject to the following conditions:
//
//    The above copyright notice and this permission notice (including the
//    next paragraph) shall be included in all copies or substantial
//    portions of the Software.
//
//    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
//    EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
//    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
//    NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
//    BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
//    ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
//    CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
//    SOFTWARE.
//  
/**
 * pointer input device
 * 

* * The wl_pointer interface represents one or more input devices, * such as mice, which control the pointer location and pointer_focus * of a seat. *

* The wl_pointer interface generates motion, enter and leave * events for the surfaces that the pointer is located over, * and button and axis events for button presses, button releases * and scrolling. * */ @Interface( methods = { @Message( types = { int.class, org.freedesktop.wayland.server.WlSurfaceResource.class, int.class, int.class }, signature = "u?oii", functionName = "setCursor", name = "set_cursor" ) , @Message( types = { }, signature = "3", functionName = "release", name = "release" ) }, name = "wl_pointer", version = 5, events = { @Message( types = { int.class, org.freedesktop.wayland.server.WlSurfaceResource.class, org.freedesktop.wayland.util.Fixed.class, org.freedesktop.wayland.util.Fixed.class }, signature = "uoff", functionName = "enter", name = "enter" ) , @Message( types = { int.class, org.freedesktop.wayland.server.WlSurfaceResource.class }, signature = "uo", functionName = "leave", name = "leave" ) , @Message( types = { int.class, org.freedesktop.wayland.util.Fixed.class, org.freedesktop.wayland.util.Fixed.class }, signature = "uff", functionName = "motion", name = "motion" ) , @Message( types = { int.class, int.class, int.class, int.class }, signature = "uuuu", functionName = "button", name = "button" ) , @Message( types = { int.class, int.class, org.freedesktop.wayland.util.Fixed.class }, signature = "uuf", functionName = "axis", name = "axis" ) , @Message( types = { }, signature = "5", functionName = "frame", name = "frame" ) , @Message( types = { int.class }, signature = "5u", functionName = "axisSource", name = "axis_source" ) , @Message( types = { int.class, int.class }, signature = "5uu", functionName = "axisStop", name = "axis_stop" ) , @Message( types = { int.class, int.class }, signature = "5ui", functionName = "axisDiscrete", name = "axis_discrete" ) } ) public class WlPointerResource extends Resource { public static final String INTERFACE_NAME = "wl_pointer"; public WlPointerResource(Client client, int version, int id, WlPointerRequests implementation) { super(client, version, id, implementation); } public WlPointerResource(Long pointer) { super(pointer); } /** * enter event *

* * Notification that this seat's pointer is focused on a certain * surface. *

* When a seat's focus enters a surface, the pointer image * is undefined and a client should respond to this event by setting * an appropriate pointer image with the set_cursor request. * * @param serial serial number of the enter event * @param surface surface entered by the pointer * @param surfaceX surface-local x coordinate * @param surfaceY surface-local y coordinate */ public void enter(int serial, @Nonnull WlSurfaceResource surface, @Nonnull org.freedesktop.wayland.util.Fixed surfaceX, @Nonnull org.freedesktop.wayland.util.Fixed surfaceY) { postEvent(0,Arguments.create(4).set(0, serial).set(1, surface).set(2, surfaceX).set(3, surfaceY)); } /** * leave event *

* * Notification that this seat's pointer is no longer focused on * a certain surface. *

* The leave notification is sent before the enter notification * for the new focus. * * @param serial serial number of the leave event * @param surface surface left by the pointer */ public void leave(int serial, @Nonnull WlSurfaceResource surface) { postEvent(1,Arguments.create(2).set(0, serial).set(1, surface)); } /** * pointer motion event *

* * Notification of pointer location change. The arguments * surface_x and surface_y are the location relative to the * focused surface. * * @param time timestamp with millisecond granularity * @param surfaceX surface-local x coordinate * @param surfaceY surface-local y coordinate */ public void motion(int time, @Nonnull org.freedesktop.wayland.util.Fixed surfaceX, @Nonnull org.freedesktop.wayland.util.Fixed surfaceY) { postEvent(2,Arguments.create(3).set(0, time).set(1, surfaceX).set(2, surfaceY)); } /** * pointer button event *

* * Mouse button click and release notifications. *

* The location of the click is given by the last motion or * enter event. * The time argument is a timestamp with millisecond * granularity, with an undefined base. * * @param serial serial number of the button event * @param time timestamp with millisecond granularity * @param button button that produced the event * @param state physical state of the button */ public void button(int serial, int time, int button, int state) { postEvent(3,Arguments.create(4).set(0, serial).set(1, time).set(2, button).set(3, state)); } /** * axis event *

* * Scroll and other axis notifications. *

* For scroll events (vertical and horizontal scroll axes), the * value parameter is the length of a vector along the specified * axis in a coordinate space identical to those of motion events, * representing a relative movement along the specified axis. *

* For devices that support movements non-parallel to axes multiple * axis events will be emitted. *

* When applicable, for example for touch pads, the server can * choose to emit scroll events where the motion vector is * equivalent to a motion event vector. *

* When applicable, a client can transform its content relative to the * scroll distance. * * @param time timestamp with millisecond granularity * @param axis axis type * @param value length of vector in surface-local coordinate space */ public void axis(int time, int axis, @Nonnull org.freedesktop.wayland.util.Fixed value) { postEvent(4,Arguments.create(3).set(0, time).set(1, axis).set(2, value)); } /** * end of a pointer event sequence *

* * Indicates the end of a set of events that logically belong together. * A client is expected to accumulate the data in all events within the * frame before proceeding. *

* All wl_pointer events before a wl_pointer.frame event belong * logically together. For example, in a diagonal scroll motion the * compositor will send an optional wl_pointer.axis_source event, two * wl_pointer.axis events (horizontal and vertical) and finally a * wl_pointer.frame event. The client may use this information to * calculate a diagonal vector for scrolling. *

* When multiple wl_pointer.axis events occur within the same frame, * the motion vector is the combined motion of all events. * When a wl_pointer.axis and a wl_pointer.axis_stop event occur within * the same frame, this indicates that axis movement in one axis has * stopped but continues in the other axis. * When multiple wl_pointer.axis_stop events occur within the same * frame, this indicates that these axes stopped in the same instance. *

* A wl_pointer.frame event is sent for every logical event group, * even if the group only contains a single wl_pointer event. * Specifically, a client may get a sequence: motion, frame, button, * frame, axis, frame, axis_stop, frame. *

* The wl_pointer.enter and wl_pointer.leave events are logical events * generated by the compositor and not the hardware. These events are * also grouped by a wl_pointer.frame. When a pointer moves from one * surface to another, a compositor should group the * wl_pointer.leave event within the same wl_pointer.frame. * However, a client must not rely on wl_pointer.leave and * wl_pointer.enter being in the same wl_pointer.frame. * Compositor-specific policies may require the wl_pointer.leave and * wl_pointer.enter event being split across multiple wl_pointer.frame * groups. * */ public void frame() { if (getVersion() < 5) { throw new UnsupportedOperationException("This object is version "+getVersion()+" while version 5 is required for this operation."); } postEvent(5); } /** * axis source event *

* * Source information for scroll and other axes. *

* This event does not occur on its own. It is sent before a * wl_pointer.frame event and carries the source information for * all events within that frame. *

* The source specifies how this event was generated. If the source is * wl_pointer.axis_source.finger, a wl_pointer.axis_stop event will be * sent when the user lifts the finger off the device. *

* If the source is wl_pointer axis_source.wheel or * wl_pointer.axis_source.continuous, a wl_pointer.axis_stop event may * or may not be sent. Whether a compositor sends an axis_stop event * for these sources is hardware-specific and implementation-dependent; * clients must not rely on receiving an axis_stop event for these * scroll sources and should treat scroll sequences from these scroll * sources as unterminated by default. *

* This event is optional. If the source is unknown for a particular * axis event sequence, no event is sent. * Only one wl_pointer.axis_source event is permitted per frame. *

* The order of wl_pointer.axis_discrete and wl_pointer.axis_source is * not guaranteed. * * @param axisSource source of the axis event */ public void axisSource(int axisSource) { if (getVersion() < 5) { throw new UnsupportedOperationException("This object is version "+getVersion()+" while version 5 is required for this operation."); } postEvent(6,Arguments.create(1).set(0, axisSource)); } /** * axis stop event *

* * Stop notification for scroll and other axes. *

* For some wl_pointer.axis_source types, a wl_pointer.axis_stop event * is sent to notify a client that the axis sequence has terminated. * This enables the client to implement kinetic scrolling. * See the wl_pointer.axis_source documentation for information on when * this event may be generated. *

* Any wl_pointer.axis events with the same axis_source after this * event should be considered as the start of a new axis motion. *

* The timestamp is to be interpreted identical to the timestamp in the * wl_pointer.axis event. The timestamp value may be the same as a * preceding wl_pointer.axis event. * * @param time timestamp with millisecond granularity * @param axis the axis stopped with this event */ public void axisStop(int time, int axis) { if (getVersion() < 5) { throw new UnsupportedOperationException("This object is version "+getVersion()+" while version 5 is required for this operation."); } postEvent(7,Arguments.create(2).set(0, time).set(1, axis)); } /** * axis click event *

* * Discrete step information for scroll and other axes. *

* This event carries the axis value of the wl_pointer.axis event in * discrete steps (e.g. mouse wheel clicks). *

* This event does not occur on its own, it is coupled with a * wl_pointer.axis event that represents this axis value on a * continuous scale. The protocol guarantees that each axis_discrete * event is always followed by exactly one axis event with the same * axis number within the same wl_pointer.frame. Note that the protocol * allows for other events to occur between the axis_discrete and * its coupled axis event, including other axis_discrete or axis * events. *

* This event is optional; continuous scrolling devices * like two-finger scrolling on touchpads do not have discrete * steps and do not generate this event. *

* The discrete value carries the directional information. e.g. a value * of -2 is two steps towards the negative direction of this axis. *

* The axis number is identical to the axis number in the associated * axis event. *

* The order of wl_pointer.axis_discrete and wl_pointer.axis_source is * not guaranteed. * * @param axis axis type * @param discrete number of steps */ public void axisDiscrete(int axis, int discrete) { if (getVersion() < 5) { throw new UnsupportedOperationException("This object is version "+getVersion()+" while version 5 is required for this operation."); } postEvent(8,Arguments.create(2).set(0, axis).set(1, discrete)); } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy