mirror of
https://github.com/servo/servo.git
synced 2025-06-17 04:44:28 +00:00
Auto merge of #26043 - paulrouget:IMMenu, r=jdm
Context menu API This adds an API for Servo internals to request a context menu to the embedder, along an implement for the UWP port.
This commit is contained in:
commit
c3ecf2ecef
10 changed files with 132 additions and 10 deletions
|
@ -233,9 +233,9 @@ void ServoControl::OnSurfaceWheelChanged(
|
|||
void ServoControl::OnSurfaceResized(IInspectable const &,
|
||||
SizeChangedEventArgs const &e) {
|
||||
auto size = e.NewSize();
|
||||
auto w = size.Width * mDPI;
|
||||
auto h = size.Height * mDPI;
|
||||
RunOnGLThread([=] { mServo->SetSize(w, h); });
|
||||
auto w = (size.Width * mDPI);
|
||||
auto h = (size.Height * mDPI);
|
||||
RunOnGLThread([=] { mServo->SetSize((GLsizei)w, (GLsizei)h); });
|
||||
}
|
||||
|
||||
void ServoControl::GoBack() {
|
||||
|
@ -435,7 +435,7 @@ void ServoControl::OnServoAnimatingChanged(bool animating) {
|
|||
WakeConditionVariable(&mGLCondVar);
|
||||
}
|
||||
|
||||
void ServoControl::OnServoIMEStateChanged(bool aShow) {
|
||||
void ServoControl::OnServoIMEStateChanged(bool) {
|
||||
// FIXME:
|
||||
// https://docs.microsoft.com/en-us/windows/win32/winauto/uiauto-implementingtextandtextrange
|
||||
}
|
||||
|
@ -564,6 +564,30 @@ void ServoControl::OnServoDevtoolsStarted(bool success,
|
|||
});
|
||||
}
|
||||
|
||||
void ServoControl::OnServoShowContextMenu(std::vector<winrt::hstring> items) {
|
||||
RunOnUIThread([=] {
|
||||
MessageDialog msg{L"Menu"};
|
||||
for (auto i = 0; i < items.size(); i++) {
|
||||
UICommand cmd{items[i], [=](auto) {
|
||||
RunOnGLThread([=] {
|
||||
mServo->ContextMenuClosed(
|
||||
Servo::ContextMenuResult::Selected, i);
|
||||
});
|
||||
}};
|
||||
msg.Commands().Append(cmd);
|
||||
}
|
||||
UICommand cancel{L"Cancel", [=](auto) {
|
||||
RunOnGLThread([=] {
|
||||
mServo->ContextMenuClosed(
|
||||
Servo::ContextMenuResult::Dismissed_, 0);
|
||||
});
|
||||
}};
|
||||
msg.Commands().Append(cancel);
|
||||
msg.CancelCommandIndex((uint32_t)items.size());
|
||||
msg.ShowAsync();
|
||||
});
|
||||
}
|
||||
|
||||
template <typename Callable> void ServoControl::RunOnUIThread(Callable cb) {
|
||||
Dispatcher().RunAsync(CoreDispatcherPriority::High, cb);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue