protected override void Dispose(bool manual)
 {
     if (manual)
     {
         // Reset the scanout region
         LinuxWindowInfo wnd = WindowInfo as LinuxWindowInfo;
         if (wnd != null)
         {
             unsafe
             {
                 int      connector_id = wnd.DisplayDevice.pConnector->connector_id;
                 ModeInfo mode         = wnd.DisplayDevice.OriginalMode;
                 Drm.ModeSetCrtc(fd,
                                 wnd.DisplayDevice.pCrtc->crtc_id,
                                 wnd.DisplayDevice.pCrtc->buffer_id,
                                 wnd.DisplayDevice.pCrtc->x,
                                 wnd.DisplayDevice.pCrtc->y,
                                 &connector_id,
                                 1,
                                 &mode);
             }
         }
     }
     base.Dispose(manual);
 }
        private void SetScanoutRegion(int buffer)
        {
            LinuxWindowInfo wnd = WindowInfo as LinuxWindowInfo;

            if (wnd == null)
            {
                throw new InvalidOperationException();
            }

            unsafe
            {
                ModeInfo *mode         = wnd.DisplayDevice.pConnector->modes;
                int       connector_id = wnd.DisplayDevice.pConnector->connector_id;
                int       crtc_id      = wnd.DisplayDevice.Id;

                int x = 0;
                int y = 0;
                int connector_count = 1;
                int ret             = Drm.ModeSetCrtc(fd, crtc_id, buffer, x, y,
                                                      &connector_id, connector_count, mode);

                if (ret != 0)
                {
                    Debug.Print("[KMS] Drm.ModeSetCrtc{0}, {1}, {2}, {3}, {4:x}, {5}, {6:x}) failed. Error: {7}",
                                fd, crtc_id, buffer, x, y, (IntPtr)connector_id, connector_count, (IntPtr)mode, ret);
                }
            }
        }
 public override bool TryRestoreResolution(DisplayDevice device)
 {
     unsafe
     {
         LinuxDisplay display      = (LinuxDisplay)device.Id;
         ModeInfo     mode         = display.OriginalMode;
         int          connector_id = display.pConnector->connector_id;
         return(Drm.ModeSetCrtc(FD, display.Id, 0, 0, 0,
                                &connector_id, 1, &mode) == 0);
     }
 }
 public override bool TryChangeResolution(DisplayDevice device, DisplayResolution resolution)
 {
     unsafe
     {
         LinuxDisplay display      = (LinuxDisplay)device.Id;
         ModeInfo *   mode         = GetModeInfo(display, resolution);
         int          connector_id = display.pConnector->connector_id;
         if (mode != null)
         {
             return(Drm.ModeSetCrtc(FD, display.Id, 0, 0, 0,
                                    &connector_id, 1, mode) == 0);
         }
         return(false);
     }
 }