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/ext-session-lock/ext-session-lock-v1.xml
  //
  // ext_session_lock_v1 Protocol Copyright: 
  /// 
  /// Copyright 2021 Isaac Freund
  /// 
  /// 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 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 'dart:async';
  import 'dart:convert';
  import 'dart:typed_data';
  import 'package:result_dart/result_dart.dart';
  
  
  /// used to lock the session
  /// 
  /// This interface is used to request that the session be locked.
  /// 
  class ExtSessionLockManagerV1 extends Proxy{
    final Context innerContext;
    final version = 1;
  
    ExtSessionLockManagerV1(this.innerContext) : super(innerContext.allocateClientId()){
      innerContext.register(this);
    }
  
  
  @override
  toString(){
  return "ExtSessionLockManagerV1 {name: 'ext_session_lock_manager_v1', id: '$objectId', version: '1',}";
  }
  
  /// destroy the session lock manager object
  /// 
  /// This informs the compositor that the session lock manager object will
  /// no longer be used. Existing objects created through this interface
  /// remain valid.
  /// 
    Result<void,Object> destroy() {
  innerContext.unRegister(this);
      logLn("ExtSessionLockManagerV1::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 ExtSessionLockManagerV1::destroy: $e");
     return Failure(e);
      }
      return Success(Object());
    }
  
  /// attempt to lock the session
  /// 
  /// This request creates a session lock and asks the compositor to lock the
  /// session. The compositor will send either the ext_session_lock_v1.locked
  /// or ext_session_lock_v1.finished event on the created object in
  /// response to this request.
  /// 
  /// [id]:
    Result<ExtSessionLockV1,Object> lock() {
    var id =  ExtSessionLockV1(innerContext);
      logLn("ExtSessionLockManagerV1::lock  id: $id");
  var arguments = [id];var argTypes = <WaylandType>[WaylandType.newId];
  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());
      try{
      innerContext.sendMessage(bytesBuilder.toBytes(), );
      }catch (e) {
        logLn("Exception in ExtSessionLockManagerV1::lock: $e");
     return Failure(e);
      }
      return Success(id);
    }
  
  }
  
  
  /// session successfully locked
  /// 
  /// This client is now responsible for displaying graphics while the
  /// session is locked and deciding when to unlock the session.
  /// 
  /// The locked event must not be sent until a new "locked" frame has been
  /// presented on all outputs and no security sensitive normal/unlocked
  /// content is possibly visible.
  /// 
  /// If this event is sent, making the destroy request is a protocol error,
  /// the lock object must be destroyed using the unlock_and_destroy request.
  /// 
  class ExtSessionLockV1LockedEvent {
    ExtSessionLockV1LockedEvent(
  );
  
  @override
  toString(){
  return "ExtSessionLockV1LockedEvent ()";
  }
  }
  
  typedef ExtSessionLockV1LockedEventHandler = void Function(ExtSessionLockV1LockedEvent);
  
  /// the session lock object should be destroyed
  /// 
  /// The compositor has decided that the session lock should be destroyed
  /// as it will no longer be used by the compositor. Exactly when this
  /// event is sent is compositor policy, but it must never be sent more
  /// than once for a given session lock object.
  /// 
  /// This might be sent because there is already another ext_session_lock_v1
  /// object held by a client, or the compositor has decided to deny the
  /// request to lock the session for some other reason. This might also
  /// be sent because the compositor implements some alternative, secure
  /// way to authenticate and unlock the session.
  /// 
  /// The finished event should be sent immediately on creation of this
  /// object if the compositor decides that the locked event will not
  /// be sent.
  /// 
  /// If the locked event is sent on creation of this object the finished
  /// event may still be sent at some later time in this object's
  /// lifetime. This is compositor policy.
  /// 
  /// Upon receiving this event, the client should make either the destroy
  /// request or the unlock_and_destroy request, depending on whether or
  /// not the locked event was received on this object.
  /// 
  class ExtSessionLockV1FinishedEvent {
    ExtSessionLockV1FinishedEvent(
  );
  
  @override
  toString(){
  return "ExtSessionLockV1FinishedEvent ()";
  }
  }
  
  typedef ExtSessionLockV1FinishedEventHandler = void Function(ExtSessionLockV1FinishedEvent);
  
  
  /// manage lock state and create lock surfaces
  /// 
  /// In response to the creation of this object the compositor must send
  /// either the locked or finished event.
  /// 
  /// The locked event indicates that the session is locked. This means
  /// that the compositor must stop rendering and providing input to normal
  /// clients. Instead the compositor must blank all outputs with an opaque
  /// color such that their normal content is fully hidden.
  /// 
  /// The only surfaces that should be rendered while the session is locked
  /// are the lock surfaces created through this interface and optionally,
  /// at the compositor's discretion, special privileged surfaces such as
  /// input methods or portions of desktop shell UIs.
  /// 
  /// The locked event must not be sent until a new "locked" frame (either
  /// from a session lock surface or the compositor blanking the output) has
  /// been presented on all outputs and no security sensitive normal/unlocked
  /// content is possibly visible.
  /// 
  /// The finished event should be sent immediately on creation of this
  /// object if the compositor decides that the locked event will not be sent.
  /// 
  /// The compositor may wait for the client to create and render session lock
  /// surfaces before sending the locked event to avoid displaying intermediate
  /// blank frames. However, it must impose a reasonable time limit if
  /// waiting and send the locked event as soon as the hard requirements
  /// described above can be met if the time limit expires. Clients should
  /// immediately create lock surfaces for all outputs on creation of this
  /// object to make this possible.
  /// 
  /// This behavior of the locked event is required in order to prevent
  /// possible race conditions with clients that wish to suspend the system
  /// or similar after locking the session. Without these semantics, clients
  /// triggering a suspend after receiving the locked event would race with
  /// the first "locked" frame being presented and normal/unlocked frames
  /// might be briefly visible as the system is resumed if the suspend
  /// operation wins the race.
  /// 
  /// If the client dies while the session is locked, the compositor must not
  /// unlock the session in response. It is acceptable for the session to be
  /// permanently locked if this happens. The compositor may choose to continue
  /// to display the lock surfaces the client had mapped before it died or
  /// alternatively fall back to a solid color, this is compositor policy.
  /// 
  /// Compositors may also allow a secure way to recover the session, the
  /// details of this are compositor policy. Compositors may allow a new
  /// client to create a ext_session_lock_v1 object and take responsibility
  /// for unlocking the session, they may even start a new lock client
  /// instance automatically.
  /// 
  class ExtSessionLockV1 extends Proxy implements Dispatcher{
    final Context innerContext;
    final version = 1;
  
    ExtSessionLockV1(this.innerContext) : super(innerContext.allocateClientId()){
      innerContext.register(this);
    }
  
  
  @override
  toString(){
  return "ExtSessionLockV1 {name: 'ext_session_lock_v1', id: '$objectId', version: '1',}";
  }
  
  /// destroy the session lock
  /// 
  /// This informs the compositor that the lock object will no longer be
  /// used. Existing objects created through this interface remain valid.
  /// 
  /// After this request is made, lock surfaces created through this object
  /// should be destroyed by the client as they will no longer be used by
  /// the compositor.
  /// 
  /// It is a protocol error to make this request if the locked event was
  /// sent, the unlock_and_destroy request must be used instead.
  /// 
    Result<void,Object> destroy() {
  innerContext.unRegister(this);
      logLn("ExtSessionLockV1::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 ExtSessionLockV1::destroy: $e");
     return Failure(e);
      }
      return Success(Object());
    }
  
  /// create a lock surface for a given output
  /// 
  /// The client is expected to create lock surfaces for all outputs
  /// currently present and any new outputs as they are advertised. These
  /// won't be displayed by the compositor unless the lock is successful
  /// and the locked event is sent.
  /// 
  /// Providing a wl_surface which already has a role or already has a buffer
  /// attached or committed is a protocol error, as is attaching/committing
  /// a buffer before the first ext_session_lock_surface_v1.configure event.
  /// 
  /// Attempting to create more than one lock surface for a given output
  /// is a duplicate_output protocol error.
  /// 
  /// [id]:
  /// [surface]:
  /// [output]:
    Result<ExtSessionLockSurfaceV1,Object> getLockSurface(Surface surface, Output output) {
    var id =  ExtSessionLockSurfaceV1(innerContext);
      logLn("ExtSessionLockV1::getLockSurface  id: $id surface: $surface output: $output");
  var arguments = [id, surface, output];var argTypes = <WaylandType>[WaylandType.newId, WaylandType.object, 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([surface.objectId]).buffer.asUint8List());
      bytesBuilder.add(Uint32List.fromList([output.objectId]).buffer.asUint8List());
      try{
      innerContext.sendMessage(bytesBuilder.toBytes(), );
      }catch (e) {
        logLn("Exception in ExtSessionLockV1::getLockSurface: $e");
     return Failure(e);
      }
      return Success(id);
    }
  
  /// unlock the session, destroying the object
  /// 
  /// This request indicates that the session should be unlocked, for
  /// example because the user has entered their password and it has been
  /// verified by the client.
  /// 
  /// This request also informs the compositor that the lock object will
  /// no longer be used and should be destroyed. Existing objects created
  /// through this interface remain valid.
  /// 
  /// After this request is made, lock surfaces created through this object
  /// should be destroyed by the client as they will no longer be used by
  /// the compositor.
  /// 
  /// It is a protocol error to make this request if the locked event has
  /// not been sent. In that case, the lock object must be destroyed using
  /// the destroy request.
  /// 
  /// Note that a correct client that wishes to exit directly after unlocking
  /// the session must use the wl_display.sync request to ensure the server
  /// receives and processes the unlock_and_destroy request. Otherwise
  /// there is no guarantee that the server has unlocked the session due
  /// to the asynchronous nature of the Wayland protocol. For example,
  /// the server might terminate the client with a protocol error before
  /// it processes the unlock_and_destroy request.
  /// 
    Result<void,Object> unlockAndDestroy() {
  innerContext.unRegister(this);
      logLn("ExtSessionLockV1::unlockAndDestroy ");
  var arguments = [];var argTypes = <WaylandType>[];
  var calclulatedSize  = calculateSize(argTypes, arguments);
  final bytesBuilder = BytesBuilder();
  bytesBuilder.add(Uint32List.fromList([objectId, (calclulatedSize << 16) | 2]).buffer.asUint8List());
      try{
      innerContext.sendMessage(bytesBuilder.toBytes(), );
      }catch (e) {
        logLn("Exception in ExtSessionLockV1::unlockAndDestroy: $e");
     return Failure(e);
      }
      return Success(Object());
    }
  
  /// session successfully locked
  /// 
  /// This client is now responsible for displaying graphics while the
  /// session is locked and deciding when to unlock the session.
  /// 
  /// The locked event must not be sent until a new "locked" frame has been
  /// presented on all outputs and no security sensitive normal/unlocked
  /// content is possibly visible.
  /// 
  /// If this event is sent, making the destroy request is a protocol error,
  /// the lock object must be destroyed using the unlock_and_destroy request.
  /// 
  /// Event handler for Locked
   void onLocked(ExtSessionLockV1LockedEventHandler handler) {
     _lockedHandler = handler;
   }
  
   ExtSessionLockV1LockedEventHandler? _lockedHandler;
  
  /// the session lock object should be destroyed
  /// 
  /// The compositor has decided that the session lock should be destroyed
  /// as it will no longer be used by the compositor. Exactly when this
  /// event is sent is compositor policy, but it must never be sent more
  /// than once for a given session lock object.
  /// 
  /// This might be sent because there is already another ext_session_lock_v1
  /// object held by a client, or the compositor has decided to deny the
  /// request to lock the session for some other reason. This might also
  /// be sent because the compositor implements some alternative, secure
  /// way to authenticate and unlock the session.
  /// 
  /// The finished event should be sent immediately on creation of this
  /// object if the compositor decides that the locked event will not
  /// be sent.
  /// 
  /// If the locked event is sent on creation of this object the finished
  /// event may still be sent at some later time in this object's
  /// lifetime. This is compositor policy.
  /// 
  /// Upon receiving this event, the client should make either the destroy
  /// request or the unlock_and_destroy request, depending on whether or
  /// not the locked event was received on this object.
  /// 
  /// Event handler for Finished
   void onFinished(ExtSessionLockV1FinishedEventHandler handler) {
     _finishedHandler = handler;
   }
  
   ExtSessionLockV1FinishedEventHandler? _finishedHandler;
  
   @override
   void dispatch(int opcode, int fd, Uint8List data) {
  logLn("ExtSessionLockV1.dispatch($opcode, $fd, $data)");
     switch (opcode) {     case 0:
  
         if (_lockedHandler != null) {
           _lockedHandler!(ExtSessionLockV1LockedEvent());
         }
         break;
       case 1:
  
         if (_finishedHandler != null) {
           _finishedHandler!(ExtSessionLockV1FinishedEvent());
         }
         break;
     }
   }
  }
  
  /// 
  /// 
  
  enum ExtSessionLockV1Error {
  /// attempted to destroy session lock while locked
    invalidDestroy("invalid_destroy", 0),/// unlock requested but locked event was never sent
    invalidUnlock("invalid_unlock", 1),/// given wl_surface already has a role
    role("role", 2),/// given output already has a lock surface
    duplicateOutput("duplicate_output", 3),/// given wl_surface has a buffer attached or committed
    alreadyConstructed("already_constructed", 4);
  const ExtSessionLockV1Error(this.enumName, this.enumValue);
  final int enumValue;
  final String enumName;
  @override
  toString(){
  return "ExtSessionLockV1Error {name: $enumName, value: $enumValue}";
  }
  }
  
  
  /// the client should resize its surface
  /// 
  /// This event is sent once on binding the interface and may be sent again
  /// at the compositor's discretion, for example if output geometry changes.
  /// 
  /// The width and height are in surface-local coordinates and are exact
  /// requirements. Failing to match these surface dimensions in the next
  /// commit after acking a configure is a protocol error.
  /// 
  class ExtSessionLockSurfaceV1ConfigureEvent {
  /// serial for use in ack_configure
    final int serial;
  
  /// 
    final int width;
  
  /// 
    final int height;
  
    ExtSessionLockSurfaceV1ConfigureEvent(
  this.serial,
  
  this.width,
  
  this.height,
  
  );
  
  @override
  toString(){
  return "ExtSessionLockSurfaceV1ConfigureEvent (serial: $serial, width: $width, height: $height)";
  }
  }
  
  typedef ExtSessionLockSurfaceV1ConfigureEventHandler = void Function(ExtSessionLockSurfaceV1ConfigureEvent);
  
  
  /// a surface displayed while the session is locked
  /// 
  /// The client may use lock surfaces to display a screensaver, render a
  /// dialog to enter a password and unlock the session, or however else it
  /// sees fit.
  /// 
  /// On binding this interface the compositor will immediately send the
  /// first configure event. After making the ack_configure request in
  /// response to this event the client should attach and commit the first
  /// buffer. Committing the surface before acking the first configure is a
  /// protocol error. Committing the surface with a null buffer at any time
  /// is a protocol error.
  /// 
  /// The compositor is free to handle keyboard/pointer focus for lock
  /// surfaces however it chooses. A reasonable way to do this would be to
  /// give the first lock surface created keyboard focus and change keyboard
  /// focus if the user clicks on other surfaces.
  /// 
  class ExtSessionLockSurfaceV1 extends Proxy implements Dispatcher{
    final Context innerContext;
    final version = 1;
  
    ExtSessionLockSurfaceV1(this.innerContext) : super(innerContext.allocateClientId()){
      innerContext.register(this);
    }
  
  
  @override
  toString(){
  return "ExtSessionLockSurfaceV1 {name: 'ext_session_lock_surface_v1', id: '$objectId', version: '1',}";
  }
  
  /// destroy the lock surface object
  /// 
  /// This informs the compositor that the lock surface object will no
  /// longer be used.
  /// 
  /// It is recommended for a lock client to destroy lock surfaces if
  /// their corresponding wl_output global is removed.
  /// 
  /// If a lock surface on an active output is destroyed before the
  /// ext_session_lock_v1.unlock_and_destroy event is sent, the compositor
  /// must fall back to rendering a solid color.
  /// 
    Result<void,Object> destroy() {
  innerContext.unRegister(this);
      logLn("ExtSessionLockSurfaceV1::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 ExtSessionLockSurfaceV1::destroy: $e");
     return Failure(e);
      }
      return Success(Object());
    }
  
  /// ack a configure event
  /// 
  /// When a configure event is received, if a client commits the surface
  /// in response to the configure event, then the client must make an
  /// ack_configure request sometime before the commit request, passing
  /// along the serial of the configure event.
  /// 
  /// If the client receives multiple configure events before it can
  /// respond to one, it only has to ack the last configure event.
  /// 
  /// A client is not required to commit immediately after sending an
  /// ack_configure request - it may even ack_configure several times
  /// before its next surface commit.
  /// 
  /// A client may send multiple ack_configure requests before committing,
  /// but only the last request sent before a commit indicates which
  /// configure event the client really is responding to.
  /// 
  /// Sending an ack_configure request consumes the configure event
  /// referenced by the given serial, as well as all older configure events
  /// sent on this object.
  /// 
  /// It is a protocol error to issue multiple ack_configure requests
  /// referencing the same configure event or to issue an ack_configure
  /// request referencing a configure event older than the last configure
  /// event acked for a given lock surface.
  /// 
  /// [serial]: serial from the configure event
    Result<void,Object> ackConfigure(int serial) {
      logLn("ExtSessionLockSurfaceV1::ackConfigure  serial: $serial");
  var arguments = [serial];var argTypes = <WaylandType>[WaylandType.uint];
  var calclulatedSize  = calculateSize(argTypes, arguments);
  final bytesBuilder = BytesBuilder();
  bytesBuilder.add(Uint32List.fromList([objectId, (calclulatedSize << 16) | 1]).buffer.asUint8List());
      bytesBuilder.add(Uint32List.fromList([serial]).buffer.asUint8List());
      try{
      innerContext.sendMessage(bytesBuilder.toBytes(), );
      }catch (e) {
        logLn("Exception in ExtSessionLockSurfaceV1::ackConfigure: $e");
     return Failure(e);
      }
      return Success(Object());
    }
  
  /// the client should resize its surface
  /// 
  /// This event is sent once on binding the interface and may be sent again
  /// at the compositor's discretion, for example if output geometry changes.
  /// 
  /// The width and height are in surface-local coordinates and are exact
  /// requirements. Failing to match these surface dimensions in the next
  /// commit after acking a configure is a protocol error.
  /// 
  /// Event handler for Configure
  /// - [serial]: serial for use in ack_configure
  /// - [width]:
  /// - [height]:
   void onConfigure(ExtSessionLockSurfaceV1ConfigureEventHandler handler) {
     _configureHandler = handler;
   }
  
   ExtSessionLockSurfaceV1ConfigureEventHandler? _configureHandler;
  
   @override
   void dispatch(int opcode, int fd, Uint8List data) {
  logLn("ExtSessionLockSurfaceV1.dispatch($opcode, $fd, $data)");
     switch (opcode) {     case 0:
  
         if (_configureHandler != null) {
  var offset = 0;
  final serial = ByteData.view(data.buffer).getUint32(offset, Endian.little);
  offset += 4;
  final width = ByteData.view(data.buffer).getUint32(offset, Endian.little);
  offset += 4;
  final height = ByteData.view(data.buffer).getUint32(offset, Endian.little);
  offset += 4;
  var event = ExtSessionLockSurfaceV1ConfigureEvent(
  serial,
  width,
  height,
          );
           _configureHandler!(event);
         }
         break;
     }
   }
  }
  
  /// 
  /// 
  
  enum ExtSessionLockSurfaceV1Error {
  /// surface committed before first ack_configure request
    commitBeforeFirstAck("commit_before_first_ack", 0),/// surface committed with a null buffer
    nullBuffer("null_buffer", 1),/// failed to match ack'd width/height
    dimensionsMismatch("dimensions_mismatch", 2),/// serial provided in ack_configure is invalid
    invalidSerial("invalid_serial", 3);
  const ExtSessionLockSurfaceV1Error(this.enumName, this.enumValue);
  final int enumValue;
  final String enumName;
  @override
  toString(){
  return "ExtSessionLockSurfaceV1Error {name: $enumName, value: $enumValue}";
  }
  }
  
  