3 #include "mainsession.h"
5 #include "mwindowgui.h"
7 #include "remotecontrol.h"
10 RemoteWindow::RemoteWindow(RemoteControl *remote_control)
11 : BC_Window(_(PROGRAM_NAME ": RemoteWindow"),
12 0, 0, xS(16), yS(16), -1, -1, 1, 0, 1)
14 this->remote_control = remote_control;
17 RemoteWindow::~RemoteWindow()
22 RemoteControl::RemoteControl(MWindowGUI *mwindow_gui)
25 this->mwindow_gui = mwindow_gui;
27 active_lock = new Mutex("RemoteControl::active_lock");
29 remote_window = new RemoteWindow(this);
31 remote_window->init_wait();
32 gui = new RemoteGUI(remote_window, this);
35 void RemoteControl::run()
37 remote_window->run_window();
40 RemoteControl::~RemoteControl()
42 if( Thread::running() ) {
43 remote_window->close(1);
53 int RemoteControl::activate(RemoteHandler *handler)
58 handler = !mwindow_gui->record->running() ?
59 (RemoteHandler *)mwindow_gui->cwindow_remote_handler :
60 (RemoteHandler *)mwindow_gui->record_remote_handler ;
61 active_lock->lock("RemoteControl::activate");
63 gui->lock_window("RemoteControl::activate");
64 gui->set_active(handler);
65 gui->set_color(handler->color);
66 gui->fill_color(handler->color);
70 active_lock->unlock();
74 int RemoteControl::deactivate()
78 active_lock->lock("RemoteControl::deactivate");
83 active_lock->unlock();
88 int RemoteControl::remote_key(int key)
90 if( !is_active() ) return 0;
91 return handler->remote_key(key);
94 void RemoteControl::set_color(int color)
96 gui->lock_window("RemoteControl::fill_color");
97 gui->set_color(color);
101 void RemoteControl::fill_color(int color)
103 gui->lock_window("RemoteControl::fill_color");
104 gui->fill_color(color);
105 gui->unlock_window();
108 RemoteGUI::RemoteGUI(BC_WindowBase *wdw, RemoteControl *remote_control)
109 : BC_Popup(wdw, remote_control->mwindow_gui->mwindow->session->mwindow_x,0,
110 xS(16),yS(16), -1, 1)
112 this->remote_control = remote_control;
115 RemoteGUI::~RemoteGUI()
119 void RemoteGUI::set_active(RemoteHandler *handler)
121 remote_control->handler = handler;
126 void RemoteGUI::set_inactive()
128 remote_control->handler = 0;
134 fill_color(int color)
137 draw_box(0, 0, get_w(), get_h());
141 void RemoteGUI::tile_windows(int config)
143 MWindow *mwindow = remote_control->mwindow_gui->mwindow;
144 if( config == mwindow->session->window_config ) return;
145 lock_window("RemoteGUI::tile_windows");
146 ungrab_keyboard(); hide_window();
147 mwindow->gui->lock_window("RemoteGUI::tile_windows 1");
148 int need_reload = mwindow->tile_windows(config);
149 mwindow->gui->unlock_window();
151 show_window(); raise_window(); grab_keyboard();
152 reposition_window(mwindow->session->mwindow_x,0);
157 mwindow->restart_status = 1;
162 int RemoteGUI::button_press_event()
164 remote_control->deactivate();
168 int RemoteGUI::keypress_event()
170 int key = get_keypress();
171 int result = remote_control->remote_key(key);
173 remote_control->deactivate();
179 RemoteHandler::RemoteHandler(RemoteGUI *gui, int color)
185 RemoteHandler::~RemoteHandler()
189 int RemoteHandler::remote_key(int key)
195 int RemoteHandler::process_key(int key)