File: stylus_handwriting_callback_sink_win.h

package info (click to toggle)
chromium 138.0.7204.183-1~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-proposed-updates
  • size: 6,080,960 kB
  • sloc: cpp: 34,937,079; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,954; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,811; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (69 lines) | stat: -rw-r--r-- 2,873 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CONTENT_BROWSER_RENDERER_HOST_INPUT_STYLUS_HANDWRITING_CALLBACK_SINK_WIN_H_
#define CONTENT_BROWSER_RENDERER_HOST_INPUT_STYLUS_HANDWRITING_CALLBACK_SINK_WIN_H_

#include "base/functional/callback.h"
#include "content/browser/renderer_host/input/stylus_handwriting_controller_win.h"

namespace content {

// Handles the callback from Shell Handwriting service.
class CONTENT_EXPORT StylusHandwritingCallbackSinkWin
    : public Microsoft::WRL::RuntimeClass<
          Microsoft::WRL::RuntimeClassFlags<Microsoft::WRL::ClassicCom>,
          ::ITfHandwritingSink> {
 public:
  using OnFocusHandwritingTargetCallback =
      StylusHandwritingControllerWin::OnFocusHandwritingTargetCallback;

  // The constructor is public for `MakeAndInitialize` and should not be called
  // directly.
  StylusHandwritingCallbackSinkWin();
  StylusHandwritingCallbackSinkWin(const StylusHandwritingCallbackSinkWin&) =
      delete;
  StylusHandwritingCallbackSinkWin& operator=(
      const StylusHandwritingCallbackSinkWin&) = delete;
  ~StylusHandwritingCallbackSinkWin() override;

  // Called during `MakeAndInitialize`.
  HRESULT STDMETHODCALLTYPE RuntimeClassInitialize();

  // ITfHandwritingSink:
  HRESULT STDMETHODCALLTYPE DetermineProximateHandwritingTarget(
      ::ITfDetermineProximateHandwritingTargetArgs* args) override;

  // ITfHandwritingSink:
  HRESULT STDMETHODCALLTYPE
  FocusHandwritingTarget(::ITfFocusHandwritingTargetArgs* args) override;

  void SetCallback(OnFocusHandwritingTargetCallback callback) {
    handwriting_callback_ = std::move(callback);
  }

  void OnFocusHandled();
  void OnFocusFailed();

 private:
  // Stores the callback to request setting the renderer focus based on the
  // target area of the pointer input and the distance threshold.
  OnFocusHandwritingTargetCallback handwriting_callback_;
  // The ITfSource interface is implemented by the TSF manager obtained from the
  // ITfThreadMgr instance. Used to install and uninstall the ITfHandwritingSink
  // so Shell Handwriting can call this controller instance, in particular
  // FocusHandwritingTarget to set the target focus.
  Microsoft::WRL::ComPtr<ITfSource> source_;
  // Args passed during FocusHandwritingTarget() call by Shell Handwriting
  // which help to retrieve pointer input details and specify the response
  // about focus handling back to Shell Handwriting.
  Microsoft::WRL::ComPtr<::ITfFocusHandwritingTargetArgs> pending_target_args_;
  // Stores the address of a DWORD valued used to correctly uninstall the advise
  // sink on the object destruction.
  DWORD sink_cookie_ = TF_INVALID_COOKIE;
};

}  // namespace content

#endif  // CONTENT_BROWSER_RENDERER_HOST_INPUT_STYLUS_HANDWRITING_CALLBACK_SINK_WIN_H_