/// <summary>
        /// Calls into GetCursorButtonCount with a special flag that indicates we should release
        /// the lock obtained previously by a CoLockObjectExternal call.
        /// </summary>
        /// <param name="manager">The tablet to release the lock for.</param>'
        internal static void ReleaseTabletExternalLock(IPimcTablet3 tablet)
        {
            int unused = 0;

            // Call through with special param to release the external lock on the tablet.
            tablet.GetCursorButtonCount(ReleaseTabletExt, out unused);
        }
        /// <summary>
        /// Queries and sets the GIT key for the WISP Tablet Manager
        /// </summary>
        /// <param name="tablet">The tablet to call through</param>
        internal static void SetWispManagerKey(IPimcTablet3 tablet)
        {
            UInt32 latestKey = QueryWispKeyFromTablet(GetWispManagerKey, tablet);

            // Assert here to ensure that every call through to this specific manager has the same
            // key.  This should be guaranteed since these calls are always done on the thread the tablet
            // is created on and all tablets created on a particular thread should be through the same
            // manager.
            Invariant.Assert(!_wispManagerKey.HasValue || _wispManagerKey.Value == latestKey);

            _wispManagerKey = latestKey;
        }
        /// <summary>
        /// Queries the GIT key from the PenIMC Tablet
        /// </summary>
        /// <param name="keyType">The kind of key to instruct the tablet to return</param>
        /// <param name="tablet">The tablet to call through</param>
        /// <returns>The GIT key for the requested operation</returns>
        private static UInt32 QueryWispKeyFromTablet(int keyType, IPimcTablet3 tablet)
        {
            int key = 0;

            tablet.GetCursorButtonCount(keyType, out key);

            if (key == 0)
            {
                throw new InvalidOperationException();
            }

            return((UInt32)key);
        }
Beispiel #4
0
        /// <summary>
        /// DevDiv:1078091
        /// It's possible that there is pending input on the stylus queue for this tablet.
        /// In such cases, we cannot immediately call Dispose as future input needs this
        /// object's data.  Instead, set a flag that indicates we should dispose of this
        /// tablet once all input has been processed.
        /// </summary>
        internal void DisposeOrDeferDisposal()
        {
            // Only dispose when no input events are left in the queue
            if (CanDispose)
            {
                // Make sure this device is not the current one.
                if (Tablet.CurrentTabletDevice == this.TabletDevice)
                {
                    StylusLogic.GetCurrentStylusLogicAs <WispLogic>().SelectStylusDevice(null, null, true);
                }

                // A disconnect will be logged in the dispose as WPF will have gotten rid of the tablet.
                StylusTraceLogger.LogDeviceDisconnect(_tabletInfo.Id);


                // Force tablets to clean up as soon as they are disposed.  This helps to reduce
                // COM references that might be waiting for RCWs to finalize.
                IPimcTablet3 tablet = _tabletInfo.PimcTablet?.Value;
                _tabletInfo.PimcTablet = null;

                if (tablet != null)
                {
                    // Balance calls in PenThreadWorker.GetTabletInfoHelper and CPimcTablet::Init.
                    PenThread.WorkerReleaseTabletLocks(tablet, _tabletInfo.WispTabletKey);

                    Marshal.ReleaseComObject(tablet);
                }

                StylusDeviceCollection styluses = _stylusDeviceCollection;
                _stylusDeviceCollection = null;

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

                _penThread         = null;
                _isDisposalPending = false;


                // Ensure that we are marked disposed and no longer attempt to finalize.
                _disposed = true;
                GC.SuppressFinalize(this);
            }
            else
            {
                _isDisposalPending = true;
            }
        }
 /// <summary>
 /// Queries the GIT key for the WISP Tablet
 /// </summary>
 /// <param name="tablet">The tablet to call through</param>
 /// <returns>The GIT key for the WISP Tablet</returns>
 internal static UInt32 QueryWispTabletKey(IPimcTablet3 tablet)
 {
     return(QueryWispKeyFromTablet(GetWispTabletKey, tablet));
 }
        /// <summary>
        ///
        /// Calls into GetTablet with a special flag that indicates we should release
        /// the lock obtained previously by a CoLockObjectExternal call.
        /// </summary>
        /// <param name="manager">The manager to release the lock for.</param>'
        private static void ReleaseManagerExternalLockImpl(IPimcManager3 manager)
        {
            IPimcTablet3 unused = null;

            manager.GetTablet(ReleaseManagerExt, out unused);
        }
Beispiel #7
0
 internal TabletDeviceSizeInfo WorkerGetUpdatedSizes(IPimcTablet3 pimcTablet)
 {
     return(_penThreadWorker.WorkerGetUpdatedSizes(pimcTablet));
 }
Beispiel #8
0
 internal StylusDeviceInfo[] WorkerRefreshCursorInfo(IPimcTablet3 pimcTablet)
 {
     return(_penThreadWorker.WorkerRefreshCursorInfo(pimcTablet));
 }
Beispiel #9
0
 internal bool WorkerReleaseTabletLocks(IPimcTablet3 tablet, UInt32 wispTabletKey)
 {
     return(_penThreadWorker.WorkerReleaseTabletLocks(tablet, wispTabletKey));
 }
Beispiel #10
0
 internal PenContextInfo WorkerCreateContext(IntPtr hwnd, IPimcTablet3 pimcTablet)
 {
     return(_penThreadWorker.WorkerCreateContext(hwnd, pimcTablet));
 }