Skip to content

Commit

Permalink
Hook Windows API in WMSG mode in fiber.
Browse files Browse the repository at this point in the history
  • Loading branch information
郑树新 committed Nov 9, 2024
1 parent fde9c63 commit 015218b
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
2 changes: 2 additions & 0 deletions lib_fiber/cpp/src/fiber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,8 @@ void fiber::schedule_gui()
{
acl_fiber_schedule_init(1);
acl_fiber_schedule_set_event(FIBER_EVENT_WMSG);
winapi_hook();

if (backend_fiber == NULL) {
backend_fiber = new gui_backend;
backend_fiber->start();
Expand Down
10 changes: 7 additions & 3 deletions lib_fiber/samples-gui/QtFiber/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui_(new Ui::MainWindow)
, process_(new QProcess(this))
{
ui_->setupUi(this);
stamp_ = new struct timeval;
Expand Down Expand Up @@ -209,6 +208,7 @@ void MainWindow::onStartSchedule()
ui_->stopSchedule->setEnabled(true);
ui_->urlGet->setEnabled(true);
ui_->startServer->setEnabled(true);
ui_->startSchedule->setEnabled(false);

qDebug() << "Begin schedule_gui!";
acl::fiber::schedule_gui();
Expand Down Expand Up @@ -238,8 +238,12 @@ void MainWindow::onStopSchedule()
void MainWindow::onHttpOptions()
{
go[this] {
qDebug() << "Sleep 5 seconds before starting http options dialog";
acl::fiber::delay(5000);
QMessageBox::information(this, "HttpOptions", "Options Window will be opened after 5 seconds.");
ui_->progress->setValue(0);
for (int i = 1; i < 6; i++) {
acl::fiber::delay(1000);
ui_->progress2->setValue(20 * i);
}

InputDialog dialog(this);
QRect mainWindowGeometry = this->frameGeometry();
Expand Down
1 change: 0 additions & 1 deletion lib_fiber/samples-gui/QtFiber/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ class MainWindow : public QMainWindow
Ui::MainWindow *ui_;

fiber_server *server_ = nullptr;
QProcess *process_;
struct timeval *stamp_;

std::string url_ = "http://www.baidu.com/";
Expand Down
13 changes: 13 additions & 0 deletions lib_fiber/samples-gui/QtFiber/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,19 @@
</font>
</property>
</widget>
<widget class="QProgressBar" name="progress2">
<property name="geometry">
<rect>
<x>1270</x>
<y>630</y>
<width>591</width>
<height>41</height>
</rect>
</property>
<property name="value">
<number>0</number>
</property>
</widget>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
Expand Down

0 comments on commit 015218b

Please sign in to comment.