mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-10-17 06:36:18 +00:00
Proper handling of resize events.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@256 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
+15
-9
@@ -35,24 +35,22 @@ Poll::poll() {
|
|||||||
|
|
||||||
m_maxFd = select(m_maxFd + 1, &m_readSet, &m_writeSet, &m_exceptSet, &timeout);
|
m_maxFd = select(m_maxFd + 1, &m_readSet, &m_writeSet, &m_exceptSet, &timeout);
|
||||||
|
|
||||||
if (m_maxFd >= 0)
|
if (m_maxFd >= 0) {
|
||||||
work();
|
work();
|
||||||
|
|
||||||
else if (errno == EINTR)
|
} else if (errno == EINTR) {
|
||||||
m_slotSelectInterrupted();
|
m_slotSelectInterrupted();
|
||||||
|
work_input();
|
||||||
|
|
||||||
else if (errno < 0)
|
} else if (errno < 0) {
|
||||||
throw std::runtime_error("Poll::work(): select error");
|
throw std::runtime_error("Poll::work(): select error");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Poll::work() {
|
Poll::work() {
|
||||||
if (FD_ISSET(0, &m_readSet)) {
|
if (FD_ISSET(0, &m_readSet))
|
||||||
int key;
|
work_input();
|
||||||
|
|
||||||
while ((key = getch()) != ERR)
|
|
||||||
m_slotReadStdin(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_curlStack.is_busy())
|
if (m_curlStack.is_busy())
|
||||||
m_curlStack.perform();
|
m_curlStack.perform();
|
||||||
@@ -60,6 +58,14 @@ Poll::work() {
|
|||||||
torrent::work(&m_readSet, &m_writeSet, &m_exceptSet, m_maxFd);
|
torrent::work(&m_readSet, &m_writeSet, &m_exceptSet, m_maxFd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Poll::work_input() {
|
||||||
|
int key;
|
||||||
|
|
||||||
|
while ((key = getch()) != ERR)
|
||||||
|
m_slotReadStdin(key);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Poll::register_http() {
|
Poll::register_http() {
|
||||||
torrent::Http::set_factory(sigc::bind(sigc::ptr_fun(&core::CurlGet::new_object), &m_curlStack));
|
torrent::Http::set_factory(sigc::bind(sigc::ptr_fun(&core::CurlGet::new_object), &m_curlStack));
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void work();
|
void work();
|
||||||
|
void work_input();
|
||||||
|
|
||||||
SlotInt m_slotReadStdin;
|
SlotInt m_slotReadStdin;
|
||||||
Slot m_slotSelectInterrupted;
|
Slot m_slotSelectInterrupted;
|
||||||
|
|||||||
@@ -59,9 +59,8 @@ Manager::adjust_layout() {
|
|||||||
h += (*itr)->get_min_height();
|
h += (*itr)->get_min_height();
|
||||||
|
|
||||||
(*itr)->resize(0, height, Canvas::get_screen_width(), h);
|
(*itr)->resize(0, height, Canvas::get_screen_width(), h);
|
||||||
|
(*itr)->mark_dirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::for_each(begin(), end(), std::mem_fun(&Window::mark_dirty));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
+6
-3
@@ -74,9 +74,13 @@ main(int argc, char** argv) {
|
|||||||
input::Bindings inputMain;
|
input::Bindings inputMain;
|
||||||
uiControl.get_input().push_back(&inputMain);
|
uiControl.get_input().push_back(&inputMain);
|
||||||
|
|
||||||
|
inputMain[KEY_RESIZE] = sigc::mem_fun(uiControl.get_display(), &display::Manager::adjust_layout);
|
||||||
|
|
||||||
poll.slot_read_stdin(sigc::mem_fun(uiControl.get_input(), &input::Manager::pressed));
|
poll.slot_read_stdin(sigc::mem_fun(uiControl.get_input(), &input::Manager::pressed));
|
||||||
poll.register_http();
|
poll.register_http();
|
||||||
|
|
||||||
|
poll.slot_select_interrupted(sigc::ptr_fun(display::Canvas::do_update));
|
||||||
|
|
||||||
torrent::initialize();
|
torrent::initialize();
|
||||||
torrent::listen_open(6880, 6999);
|
torrent::listen_open(6880, 6999);
|
||||||
|
|
||||||
@@ -91,15 +95,14 @@ main(int argc, char** argv) {
|
|||||||
|
|
||||||
SignalHandler::set_handler(SIGINT, sigc::ptr_fun(&set_shutdown));
|
SignalHandler::set_handler(SIGINT, sigc::ptr_fun(&set_shutdown));
|
||||||
|
|
||||||
|
uiControl.get_display().adjust_layout();
|
||||||
|
|
||||||
while (!is_shutting_down || !torrent::get(torrent::SHUTDOWN_DONE)) {
|
while (!is_shutting_down || !torrent::get(torrent::SHUTDOWN_DONE)) {
|
||||||
if (start_shutdown && !is_shutting_down)
|
if (start_shutdown && !is_shutting_down)
|
||||||
do_shutdown();
|
do_shutdown();
|
||||||
|
|
||||||
Timer::update();
|
Timer::update();
|
||||||
|
|
||||||
if (is_resized())
|
|
||||||
uiControl.get_display().adjust_layout();
|
|
||||||
|
|
||||||
uiControl.get_display().do_update();
|
uiControl.get_display().do_update();
|
||||||
|
|
||||||
poll.poll();
|
poll.poll();
|
||||||
|
|||||||
+22
-2
@@ -1,6 +1,7 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
#include <sigc++/bind.h>
|
||||||
#include <torrent/torrent.h>
|
#include <torrent/torrent.h>
|
||||||
|
|
||||||
#include "input/bindings.h"
|
#include "input/bindings.h"
|
||||||
@@ -25,8 +26,7 @@ Download::Download(DPtr d, Control* c) :
|
|||||||
m_window = new WPeerList(&m_peers, &m_focus);
|
m_window = new WPeerList(&m_peers, &m_focus);
|
||||||
m_window->slot_chunks_total(sigc::mem_fun(m_download->get_download(), &torrent::Download::get_chunks_total));
|
m_window->slot_chunks_total(sigc::mem_fun(m_download->get_download(), &torrent::Download::get_chunks_total));
|
||||||
|
|
||||||
(*m_bindings)[KEY_UP] = sigc::mem_fun(*this, &Download::receive_prev);
|
bind_keys(m_bindings);
|
||||||
(*m_bindings)[KEY_DOWN] = sigc::mem_fun(*this, &Download::receive_next);
|
|
||||||
|
|
||||||
m_download->get_download().peer_list(m_peers);
|
m_download->get_download().peer_list(m_peers);
|
||||||
|
|
||||||
@@ -98,6 +98,26 @@ Download::receive_peer_disconnected(torrent::Peer p) {
|
|||||||
m_peers.erase(itr);
|
m_peers.erase(itr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Download::receive_throttle(int t) {
|
||||||
|
m_status->mark_dirty();
|
||||||
|
|
||||||
|
torrent::set(torrent::THROTTLE_ROOT_CONST_RATE, torrent::get(torrent::THROTTLE_ROOT_CONST_RATE) + t * 1024);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Download::bind_keys(input::Bindings* b) {
|
||||||
|
(*b)['a'] = sigc::bind(sigc::mem_fun(*this, &Download::receive_throttle), 1);
|
||||||
|
(*b)['z'] = sigc::bind(sigc::mem_fun(*this, &Download::receive_throttle), -1);
|
||||||
|
(*b)['s'] = sigc::bind(sigc::mem_fun(*this, &Download::receive_throttle), 5);
|
||||||
|
(*b)['x'] = sigc::bind(sigc::mem_fun(*this, &Download::receive_throttle), -5);
|
||||||
|
(*b)['d'] = sigc::bind(sigc::mem_fun(*this, &Download::receive_throttle), 50);
|
||||||
|
(*b)['c'] = sigc::bind(sigc::mem_fun(*this, &Download::receive_throttle), -50);
|
||||||
|
|
||||||
|
(*b)[KEY_UP] = sigc::mem_fun(*this, &Download::receive_prev);
|
||||||
|
(*b)[KEY_DOWN] = sigc::mem_fun(*this, &Download::receive_next);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Download::mark_dirty() {
|
Download::mark_dirty() {
|
||||||
m_window->mark_dirty();
|
m_window->mark_dirty();
|
||||||
|
|||||||
@@ -42,6 +42,10 @@ private:
|
|||||||
void receive_peer_connected(torrent::Peer p);
|
void receive_peer_connected(torrent::Peer p);
|
||||||
void receive_peer_disconnected(torrent::Peer p);
|
void receive_peer_disconnected(torrent::Peer p);
|
||||||
|
|
||||||
|
void receive_throttle(int t);
|
||||||
|
|
||||||
|
void bind_keys(input::Bindings* b);
|
||||||
|
|
||||||
void mark_dirty();
|
void mark_dirty();
|
||||||
|
|
||||||
DPtr m_download;
|
DPtr m_download;
|
||||||
|
|||||||
+16
-10
@@ -26,16 +26,7 @@ DownloadList::DownloadList(core::DownloadList* l, Control* c) :
|
|||||||
|
|
||||||
m_window = new WList(m_list, &m_focus);
|
m_window = new WList(m_list, &m_focus);
|
||||||
|
|
||||||
(*m_bindings)[KEY_UP] = sigc::mem_fun(*this, &DownloadList::receive_prev);
|
bind_keys(m_bindings);
|
||||||
(*m_bindings)[KEY_DOWN] = sigc::mem_fun(*this, &DownloadList::receive_next);
|
|
||||||
(*m_bindings)[KEY_RIGHT] = sigc::mem_fun(*this, &DownloadList::receive_view_download);
|
|
||||||
|
|
||||||
(*m_bindings)['a'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_throttle), 1);
|
|
||||||
(*m_bindings)['z'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_throttle), -1);
|
|
||||||
(*m_bindings)['s'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_throttle), 5);
|
|
||||||
(*m_bindings)['x'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_throttle), -5);
|
|
||||||
(*m_bindings)['d'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_throttle), 50);
|
|
||||||
(*m_bindings)['c'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_throttle), -50);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DownloadList::~DownloadList() {
|
DownloadList::~DownloadList() {
|
||||||
@@ -117,6 +108,21 @@ DownloadList::receive_throttle(int t) {
|
|||||||
torrent::set(torrent::THROTTLE_ROOT_CONST_RATE, torrent::get(torrent::THROTTLE_ROOT_CONST_RATE) + t * 1024);
|
torrent::set(torrent::THROTTLE_ROOT_CONST_RATE, torrent::get(torrent::THROTTLE_ROOT_CONST_RATE) + t * 1024);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
DownloadList::bind_keys(input::Bindings* b) {
|
||||||
|
(*b)['a'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_throttle), 1);
|
||||||
|
(*b)['z'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_throttle), -1);
|
||||||
|
(*b)['s'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_throttle), 5);
|
||||||
|
(*b)['x'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_throttle), -5);
|
||||||
|
(*b)['d'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_throttle), 50);
|
||||||
|
(*b)['c'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_throttle), -50);
|
||||||
|
|
||||||
|
(*b)[KEY_UP] = sigc::mem_fun(*this, &DownloadList::receive_prev);
|
||||||
|
(*b)[KEY_DOWN] = sigc::mem_fun(*this, &DownloadList::receive_next);
|
||||||
|
(*b)[KEY_RIGHT] = sigc::mem_fun(*this, &DownloadList::receive_view_download);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
DownloadList::mark_dirty() {
|
DownloadList::mark_dirty() {
|
||||||
m_window->mark_dirty();
|
m_window->mark_dirty();
|
||||||
|
|||||||
@@ -38,6 +38,8 @@ private:
|
|||||||
|
|
||||||
void receive_throttle(int t);
|
void receive_throttle(int t);
|
||||||
|
|
||||||
|
void bind_keys(input::Bindings* b);
|
||||||
|
|
||||||
void mark_dirty();
|
void mark_dirty();
|
||||||
|
|
||||||
WList* m_window;
|
WList* m_window;
|
||||||
|
|||||||
Reference in New Issue
Block a user