content: // Generated by dart-wayland-scanner
  // https://github.com/your-repo/dart-wayland-scanner
  // XML file : https://gitlab.freedesktop.org/wayland/wayland-protocols/-/raw/main/staging/xdg-toplevel-drag/xdg-toplevel-drag-v1.xml
  //
  // xdg_toplevel_drag_v1 Protocol Copyright: 
  /// 
  /// Copyright 2023 David Redondo
  /// 
  /// 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.
  /// 
  
  library client;
  
  import 'package:wayland/wayland.dart';
  import 'package:wayland/protocols/wayland.dart';
  import 'package:wayland/protocols/stable/xdg-shell/xdg_shell.dart';
  import 'dart:async';
  import 'dart:convert';
  import 'dart:typed_data';
  import 'package:result_dart/result_dart.dart';
  
  
  /// Move a window during a drag
  /// 
  /// This protocol enhances normal drag and drop with the ability to move a
  /// window at the same time. This allows having detachable parts of a window
  /// that when dragged out of it become a new window and can be dragged over
  /// an existing window to be reattached.
  /// 
  /// A typical workflow would be when the user starts dragging on top of a
  /// detachable part of a window, the client would create a wl_data_source and
  /// a xdg_toplevel_drag_v1 object and start the drag as normal via
  /// wl_data_device.start_drag. Once the client determines that the detachable
  /// window contents should be detached from the originating window, it creates
  /// a new xdg_toplevel with these contents and issues a
  /// xdg_toplevel_drag_v1.attach request before mapping it. From now on the new
  /// window is moved by the compositor during the drag as if the client called
  /// xdg_toplevel.move.
  /// 
  /// Dragging an existing window is similar. The client creates a
  /// xdg_toplevel_drag_v1 object and attaches the existing toplevel before
  /// starting the drag.
  /// 
  /// Clients use the existing drag and drop mechanism to detect when a window
  /// can be docked or undocked. If the client wants to snap a window into a
  /// parent window it should delete or unmap the dragged top-level. If the
  /// contents should be detached again it attaches a new toplevel as described
  /// above. If a drag operation is cancelled without being dropped, clients
  /// should revert to the previous state, deleting any newly created windows
  /// as appropriate. When a drag operation ends as indicated by
  /// wl_data_source.dnd_drop_performed the dragged toplevel window's final
  /// position is determined as if a xdg_toplevel_move operation ended.
  /// 
  /// Warning! The protocol described in this file is currently in the testing
  /// phase. Backward compatible changes may be added together with the
  /// corresponding interface version bump. Backward incompatible changes can
  /// only be done by creating a new major version of the extension.
  /// 
  class XdgToplevelDragManagerV1 extends Proxy{
    final Context innerContext;
    final version = 1;
  
    XdgToplevelDragManagerV1(this.innerContext) : super(innerContext.allocateClientId()){
      innerContext.register(this);
    }
  
  
  @override
  toString(){
  return "XdgToplevelDragManagerV1 {name: 'xdg_toplevel_drag_manager_v1', id: '$objectId', version: '1',}";
  }
  
  /// destroy the xdg_toplevel_drag_manager_v1 object
  /// 
  /// Destroy this xdg_toplevel_drag_manager_v1 object. Other objects,
  /// including xdg_toplevel_drag_v1 objects created by this factory, are not
  /// affected by this request.
  /// 
    Result<void,Object> destroy() {
  innerContext.unRegister(this);
      logLn("XdgToplevelDragManagerV1::destroy ");
  var arguments = [];var argTypes = <WaylandType>[];
  var calclulatedSize  = calculateSize(argTypes, arguments);
  final bytesBuilder = BytesBuilder();
  bytesBuilder.add(Uint32List.fromList([objectId, (calclulatedSize << 16) | 0]).buffer.asUint8List());
      try{
      innerContext.sendMessage(bytesBuilder.toBytes(), );
      }catch (e) {
        logLn("Exception in XdgToplevelDragManagerV1::destroy: $e");
     return Failure(e);
      }
      return Success(Object());
    }
  
  /// get an xdg_toplevel_drag for a wl_data_source
  /// 
  /// Create an xdg_toplevel_drag for a drag and drop operation that is going
  /// to be started with data_source.
  /// 
  /// This request can only be made on sources used in drag-and-drop, so it
  /// must be performed before wl_data_device.start_drag. Attempting to use
  /// the source other than for drag-and-drop such as in
  /// wl_data_device.set_selection will raise an invalid_source error.
  /// 
  /// Destroying data_source while a toplevel is attached to the
  /// xdg_toplevel_drag is undefined.
  /// 
  /// [id]:
  /// [data_source]:
    Result<XdgToplevelDragV1,Object> getXdgToplevelDrag(DataSource dataSource) {
    var id =  XdgToplevelDragV1(innerContext);
      logLn("XdgToplevelDragManagerV1::getXdgToplevelDrag  id: $id dataSource: $dataSource");
  var arguments = [id, dataSource];var argTypes = <WaylandType>[WaylandType.newId, WaylandType.object];
  var calclulatedSize  = calculateSize(argTypes, arguments);
  final bytesBuilder = BytesBuilder();
  bytesBuilder.add(Uint32List.fromList([objectId, (calclulatedSize << 16) | 1]).buffer.asUint8List());
      bytesBuilder.add(Uint32List.fromList([id.objectId]).buffer.asUint8List());
      bytesBuilder.add(Uint32List.fromList([dataSource.objectId]).buffer.asUint8List());
      try{
      innerContext.sendMessage(bytesBuilder.toBytes(), );
      }catch (e) {
        logLn("Exception in XdgToplevelDragManagerV1::getXdgToplevelDrag: $e");
     return Failure(e);
      }
      return Success(id);
    }
  
  }
  
  /// 
  /// 
  
  enum XdgToplevelDragManagerV1Error {
  /// data_source already used for toplevel drag
    invalidSource("invalid_source", 0);
  const XdgToplevelDragManagerV1Error(this.enumName, this.enumValue);
  final int enumValue;
  final String enumName;
  @override
  toString(){
  return "XdgToplevelDragManagerV1Error {name: $enumName, value: $enumValue}";
  }
  }
  
  
  
  /// Object representing a toplevel move during a drag
  /// 
  /// 
  class XdgToplevelDragV1 extends Proxy{
    final Context innerContext;
    final version = 1;
  
    XdgToplevelDragV1(this.innerContext) : super(innerContext.allocateClientId()){
      innerContext.register(this);
    }
  
  
  @override
  toString(){
  return "XdgToplevelDragV1 {name: 'xdg_toplevel_drag_v1', id: '$objectId', version: '1',}";
  }
  
  /// destroy an xdg_toplevel_drag_v1 object
  /// 
  /// Destroy this xdg_toplevel_drag_v1 object. This request must only be
  /// called after the underlying wl_data_source drag has ended, as indicated
  /// by the dnd_drop_performed or cancelled events. In any other case an
  /// ongoing_drag error is raised.
  /// 
    Result<void,Object> destroy() {
  innerContext.unRegister(this);
      logLn("XdgToplevelDragV1::destroy ");
  var arguments = [];var argTypes = <WaylandType>[];
  var calclulatedSize  = calculateSize(argTypes, arguments);
  final bytesBuilder = BytesBuilder();
  bytesBuilder.add(Uint32List.fromList([objectId, (calclulatedSize << 16) | 0]).buffer.asUint8List());
      try{
      innerContext.sendMessage(bytesBuilder.toBytes(), );
      }catch (e) {
        logLn("Exception in XdgToplevelDragV1::destroy: $e");
     return Failure(e);
      }
      return Success(Object());
    }
  
  /// Move a toplevel with the drag operation
  /// 
  /// Request that the window will be moved with the cursor during the drag
  /// operation. The offset is a hint to the compositor how the toplevel
  /// should be positioned relative to the cursor hotspot in surface local
  /// coordinates. For example it might only be used when an unmapped window
  /// is attached. The attached window does not participate in the selection
  /// of the drag target.
  /// 
  /// If the toplevel is unmapped while it is attached, it is automatically
  /// detached from the drag. In this case this request has to be called again
  /// if the window should be attached after it is remapped.
  /// 
  /// This request can be called multiple times but issuing it while a
  /// toplevel with an active role is attached raises a toplevel_attached
  /// error.
  /// 
  /// [toplevel]:
  /// [x_offset]: dragged surface x offset
  /// [y_offset]: dragged surface y offset
    Result<void,Object> attach(XdgToplevel toplevel, int xOffset, int yOffset) {
      logLn("XdgToplevelDragV1::attach  toplevel: $toplevel xOffset: $xOffset yOffset: $yOffset");
  var arguments = [toplevel, xOffset, yOffset];var argTypes = <WaylandType>[WaylandType.object, WaylandType.int, WaylandType.int];
  var calclulatedSize  = calculateSize(argTypes, arguments);
  final bytesBuilder = BytesBuilder();
  bytesBuilder.add(Uint32List.fromList([objectId, (calclulatedSize << 16) | 1]).buffer.asUint8List());
      bytesBuilder.add(Uint32List.fromList([toplevel.objectId]).buffer.asUint8List());
      bytesBuilder.add(Int32List.fromList([xOffset]).buffer.asUint8List());
      bytesBuilder.add(Int32List.fromList([yOffset]).buffer.asUint8List());
      try{
      innerContext.sendMessage(bytesBuilder.toBytes(), );
      }catch (e) {
        logLn("Exception in XdgToplevelDragV1::attach: $e");
     return Failure(e);
      }
      return Success(Object());
    }
  
  }
  
  /// 
  /// 
  
  enum XdgToplevelDragV1Error {
  /// valid toplevel already attached
    toplevelAttached("toplevel_attached", 0),/// drag has not ended
    ongoingDrag("ongoing_drag", 1);
  const XdgToplevelDragV1Error(this.enumName, this.enumValue);
  final int enumValue;
  final String enumName;
  @override
  toString(){
  return "XdgToplevelDragV1Error {name: $enumName, value: $enumValue}";
  }
  }
  
  