Beispiel #1
0
        // TODO: This approach will completely break when the
        //       MoonUiaDbusBridge work is committed. This code
        //       will be replaced with proper source tree merging,
        //       which requires updates to gtk-sharp.
        private static void AddUniqueRootElements(List <AutomationElement> rootElements,
                                                  IAutomationSource source,
                                                  Dictionary <int, IElement> pidElementMapping)
        {
            const string at_spi = "at-spi";

            foreach (IElement sourceElement in source.GetRootElements())
            {
                int    pid;
                string sourceFid;
                try {
                    pid       = sourceElement.ProcessId;
                    sourceFid = sourceElement.FrameworkId;
                } catch { continue; }                 // TODO: ElementNotAvailableException

                // NOTE: This is not a complete mapping, since
                //       one process could generate multiple root
                //       elements. But it's sufficient to catch
                //       that at least one element exists for
                //       a given PID.
                if (pidElementMapping.TryGetValue(pid, out IElement found))
                {
                    string foundFid;
                    try {
                        foundFid = found.FrameworkId;
                    } catch { continue; }                     // TODO: ElementNotAvailableException

                    // Ignore at-spi elements when elements
                    // for this process from a preferred
                    // framework exist
                    if (sourceFid == at_spi &&
                        foundFid != at_spi)
                    {
                        continue;
                    }
                    // Remove at-spi elements when elements
                    // for this process from a preferred
                    // framework exist
                    else if (sourceFid != at_spi &&
                             foundFid == at_spi)
                    {
                        // TODO: When we fix ElementNotAvailableException,
                        //       we'll need to mark these
                        //       elements as unavailable.
                        rootElements.RemoveAll(e => e.Current.ProcessId == pid &&
                                               e.Current.FrameworkId == at_spi);
                    }
                }

                rootElements.Add(SourceManager.GetOrCreateAutomationElement(sourceElement));
                pidElementMapping [pid] = sourceElement;
            }
        }
Beispiel #2
0
		// TODO: This approach will completely break when the
		//       MoonUiaDbusBridge work is committed. This code
		//       will be replaced with proper source tree merging,
		//       which requires updates to gtk-sharp.
		private static void AddUniqueRootElements (List<AutomationElement> rootElements,
		                                           IAutomationSource source,
		                                           Dictionary<int, IElement> pidElementMapping)
		{
			const string at_spi = "at-spi";
			foreach (IElement sourceElement in source.GetRootElements ()) {
				int pid;
				try {
					pid = sourceElement.ProcessId;
				} catch { continue; } // TODO: ElementNotAvailableException

				IElement found;
				// NOTE: This is not a complete mapping, since
				//       one process could generate multiple root
				//       elements. But it's sufficient to catch
				//       that at least one element exists for
				//       a given PID.
				if (pidElementMapping.TryGetValue (pid, out found)) {
					var sourceFid = sourceElement.FrameworkId;
					var foundFid = found.FrameworkId;
					// Ignore at-spi elements when elements
					// for this process from a preferred
					// framework exist
					if (sourceFid == at_spi &&
					    foundFid != at_spi)
						continue;
					// Remove at-spi elements when elements
					// for this process from a preferred
					// framework exist
					else if (sourceFid != at_spi &&
					         foundFid == at_spi) {
						// TODO: When we fix ElementNotAvailableException,
						//       we'll need to mark these
						//       elements as unavailable.
						rootElements.RemoveAll (e => e.Current.ProcessId == pid &&
						                        e.Current.FrameworkId == at_spi);
					}
				}

				rootElements.Add (
					SourceManager.GetOrCreateAutomationElement (sourceElement));
				pidElementMapping [pid] = sourceElement;
			}
		}