X-Git-Url: http://git.mutantstargoat.com?p=winnie;a=blobdiff_plain;f=src%2Fwm.cc;h=c9b8959770e4c997dd8bd11f390715d2c6fefa2e;hp=fd86d1d82960afc4251e68e735267692f2fede2c;hb=d02747c88b1df856c5531cdc4b7af5b3ac8a0dc3;hpb=65eda3d5a8e4ad8d28bda12cace044628c1a69be diff --git a/src/wm.cc b/src/wm.cc index fd86d1d..c9b8959 100644 --- a/src/wm.cc +++ b/src/wm.cc @@ -270,6 +270,40 @@ void WindowManager::release_mouse() grab_win = 0; } +void WindowManager::raise_window(Window *win) +{ + if(!win) { + return; + } + + Window *parent = win->get_parent(); + if(parent != root_win) { + if(parent->get_parent() == root_win) { + win = parent; + } + else { + return; + } + } + + root_win->remove_child(win); + root_win->add_child(win); +} + +void WindowManager::sink_window(Window *win) +{ + if(!win) { + return; + } + + std::list::iterator it; + it = std::find(windows.begin(), windows.end(), win); + if(it != windows.end()) { + windows.erase(it); + windows.push_front(win); + } +} + static void display(Window *win) { //frame display: @@ -293,6 +327,7 @@ static void mouse(Window *win, int bn, bool pressed, int x, int y) if(bn == 0) { if(pressed) { wm->grab_mouse(win); + wm->raise_window(win); prev_x = x; prev_y = y; } @@ -305,6 +340,8 @@ static void mouse(Window *win, int bn, bool pressed, int x, int y) static void motion(Window *win, int x, int y) { int left_bn = get_button(0); + int right_button = get_button(2); + if(left_bn) { int dx = x - prev_x; int dy = y - prev_y;