コード例 #1
0
ファイル: Battery.macos.cs プロジェクト: josephwambura/maui
 public void StopBatteryListeners()
 {
     if (powerSourceNotification != null)
     {
         CFRunLoop.Current.RemoveSource(powerSourceNotification, CFRunLoop.ModeDefault);
         powerSourceNotification = null;
     }
 }
コード例 #2
0
        public void StartWatchingMediaKeys()
        {
            StopWatchingMediaKeys();
            var sysMask = (CGEventMask)NX_SYSDEFINED;

            eventPort       = CreateTap(CGEventTapLocation.Session, CGEventTapPlacement.HeadInsert, CGEventTapOptions.Default, 16384, tapEventCallback, this.Handle);
            eventPortSource = eventPort.CreateRunLoopSource();
            Task.Run(() => {
                eventTapThread();
            });
            ShouldInterceptMediaKeyEvents = true;
        }
コード例 #3
0
        public MouseMonitor()
        {
            tapPort = CGEvent.CreateTap(
                CGEventTapLocation.Session,
                CGEventTapPlacement.TailAppend,
                CGEventTapOptions.ListenOnly,
                CGEventMask.LeftMouseUp | CGEventMask.MouseMoved,
                eventTapCallback = new CGEvent.CGEventTapCallback(HandleEventTap),
                IntPtr.Zero);

            runLoopSource = tapPort.CreateRunLoopSource();
            CFRunLoop.Current.AddSource(runLoopSource, CFRunLoop.ModeDefault);
        }
コード例 #4
0
        void Dispose(bool disposing)
        {
            if (runLoopSource != null)
            {
                CFRunLoop.Current.RemoveSource(runLoopSource, CFRunLoop.ModeDefault);
                runLoopSource.Dispose();
                runLoopSource = null;
            }

            if (tapPort != null)
            {
                tapPort.Dispose();
                tapPort = null;
            }

            if (eventTapCallback != null)
            {
                eventTapCallback = null;
            }
        }
コード例 #5
0
        public void StopWatchingMediaKeys()
        {
            if (tapThread != null)
            {
                tapThread.Stop();
                tapThread = null;
            }

            if (eventPort != null)
            {
                eventPort.Invalidate();
                eventPort.Dispose();
                eventPort = null;
            }

            if (eventPortSource != null)
            {
                eventPortSource.Invalidate();
                eventPortSource.Dispose();
                eventPortSource = null;
            }
        }
コード例 #6
0
 public WrappedNSInputStream(Stream inputStream)
 {
     status = NSStreamStatus.NotOpen;
     stream = inputStream;
     source = new CFRunLoopSource(Handle);
 }
コード例 #7
0
ファイル: Battery.macos.cs プロジェクト: josephwambura/maui
 public void StartBatteryListeners()
 {
     powerSourceNotification = IOKit.CreatePowerSourceNotification(PowerSourceNotification);
     CFRunLoop.Current.AddSource(powerSourceNotification, CFRunLoop.ModeDefault);
 }