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;
15 // *** CONTEXT_HELP ***
16 context_help_set_keyword("Remote Control for DVB");
19 RemoteWindow::~RemoteWindow()
24 RemoteControl::RemoteControl(MWindowGUI *mwindow_gui)
27 this->mwindow_gui = mwindow_gui;
29 active_lock = new Mutex("RemoteControl::active_lock");
31 remote_window = new RemoteWindow(this);
33 remote_window->init_wait();
34 gui = new RemoteGUI(remote_window, this);
37 void RemoteControl::run()
39 remote_window->run_window();
42 RemoteControl::~RemoteControl()
44 if( Thread::running() ) {
45 remote_window->close(1);
55 int RemoteControl::activate(RemoteHandler *handler)
60 handler = !mwindow_gui->record->running() ?
61 (RemoteHandler *)mwindow_gui->cwindow_remote_handler :
62 (RemoteHandler *)mwindow_gui->record_remote_handler ;
63 active_lock->lock("RemoteControl::activate");
65 gui->lock_window("RemoteControl::activate");
66 gui->set_active(handler);
67 gui->set_color(handler->color);
68 gui->fill_color(handler->color);
72 active_lock->unlock();
76 int RemoteControl::deactivate()
80 active_lock->lock("RemoteControl::deactivate");
85 active_lock->unlock();
90 int RemoteControl::remote_key(int key)
92 if( !is_active() ) return 0;
93 return handler->remote_key(key);
96 void RemoteControl::set_color(int color)
98 gui->lock_window("RemoteControl::fill_color");
99 gui->set_color(color);
100 gui->unlock_window();
103 void RemoteControl::fill_color(int color)
105 gui->lock_window("RemoteControl::fill_color");
106 gui->fill_color(color);
107 gui->unlock_window();
110 RemoteGUI::RemoteGUI(BC_WindowBase *wdw, RemoteControl *remote_control)
111 : BC_Popup(wdw, remote_control->mwindow_gui->mwindow->session->mwindow_x,0,
112 xS(16),yS(16), -1, 1)
114 this->remote_control = remote_control;
117 RemoteGUI::~RemoteGUI()
121 void RemoteGUI::set_active(RemoteHandler *handler)
123 remote_control->handler = handler;
128 void RemoteGUI::set_inactive()
130 remote_control->handler = 0;
136 fill_color(int color)
139 draw_box(0, 0, get_w(), get_h());
143 void RemoteGUI::tile_windows(int config)
145 MWindow *mwindow = remote_control->mwindow_gui->mwindow;
146 if( config == mwindow->session->window_config ) return;
147 lock_window("RemoteGUI::tile_windows");
148 ungrab_keyboard(); hide_window();
149 mwindow->gui->lock_window("RemoteGUI::tile_windows 1");
150 int need_reload = mwindow->tile_windows(config);
151 mwindow->gui->unlock_window();
153 show_window(); raise_window(); grab_keyboard();
154 reposition_window(mwindow->session->mwindow_x,0);
159 mwindow->restart_status = 1;
164 int RemoteGUI::button_press_event()
166 remote_control->deactivate();
170 int RemoteGUI::keypress_event()
172 int key = get_keypress();
173 int result = remote_control->remote_key(key);
175 remote_control->deactivate();
181 RemoteHandler::RemoteHandler(RemoteGUI *gui, int color)
187 RemoteHandler::~RemoteHandler()
191 int RemoteHandler::remote_key(int key)
197 int RemoteHandler::process_key(int key)