diff options
Diffstat (limited to 'src/FbWinFrame.cc')
-rw-r--r-- | src/FbWinFrame.cc | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/FbWinFrame.cc b/src/FbWinFrame.cc index 53cecf7..937f87f 100644 --- a/src/FbWinFrame.cc +++ b/src/FbWinFrame.cc | |||
@@ -35,10 +35,13 @@ | |||
35 | #include "Screen.hh" | 35 | #include "Screen.hh" |
36 | #include "FocusableTheme.hh" | 36 | #include "FocusableTheme.hh" |
37 | #include "IconButton.hh" | 37 | #include "IconButton.hh" |
38 | #include "RectangleUtil.hh" | ||
38 | 39 | ||
39 | #include <algorithm> | 40 | #include <algorithm> |
40 | #include <X11/X.h> | 41 | #include <X11/X.h> |
41 | 42 | ||
43 | #include "Keys.hh" | ||
44 | |||
42 | using std::max; | 45 | using std::max; |
43 | using std::mem_fun; | 46 | using std::mem_fun; |
44 | using std::string; | 47 | using std::string; |
@@ -1727,3 +1730,49 @@ bool FbWinFrame::insideTitlebar(Window win) const { | |||
1727 | gripRight().window() != win && | 1730 | gripRight().window() != win && |
1728 | window().window() != win; | 1731 | window().window() != win; |
1729 | } | 1732 | } |
1733 | |||
1734 | int FbWinFrame::getContext(Window win, int x, int y, int last_x, int last_y, bool doBorders) { | ||
1735 | int context = 0; | ||
1736 | if (gripLeft().window() == win) return Keys::ON_LEFTGRIP; | ||
1737 | if (gripRight().window() == win) return Keys::ON_RIGHTGRIP; | ||
1738 | if (doBorders) { | ||
1739 | using RectangleUtil::insideBorder; | ||
1740 | int borderw = window().borderWidth(); | ||
1741 | if ( // if mouse is currently on the window border, ignore it | ||
1742 | ( | ||
1743 | ! insideBorder(window(), x, y, borderw) | ||
1744 | && ( externalTabMode() | ||
1745 | || ! insideBorder(tabcontainer(), x, y, borderw) ) | ||
1746 | ) | ||
1747 | || // or if mouse was on border when it was last clicked | ||
1748 | ( | ||
1749 | ! insideBorder(window(), last_x, last_y, borderw) | ||
1750 | && ( externalTabMode() | ||
1751 | || ! insideBorder(tabcontainer(), last_x, last_y, borderw ) ) | ||
1752 | ) | ||
1753 | ) context = Keys::ON_WINDOWBORDER; | ||
1754 | } | ||
1755 | |||
1756 | if (window().window() == win) return context | Keys::ON_WINDOW; | ||
1757 | // /!\ old code: handle = titlebar in motionNotifyEvent but only there ! | ||
1758 | // handle() as border ?? | ||
1759 | if (handle().window() == win) return Keys::ON_WINDOWBORDER | Keys::ON_WINDOW; | ||
1760 | if (titlebar().window() == win) return context | Keys::ON_TITLEBAR; | ||
1761 | if (label().window() == win) return context | Keys::ON_TITLEBAR; | ||
1762 | // internal tabs are on title bar | ||
1763 | if (tabcontainer().window() == win) | ||
1764 | return context | Keys::ON_TAB | (externalTabMode()?0:Keys::ON_TITLEBAR); | ||
1765 | |||
1766 | |||
1767 | FbTk::Container::ItemList::iterator it = tabcontainer().begin(); | ||
1768 | FbTk::Container::ItemList::iterator it_end = tabcontainer().end(); | ||
1769 | for (; it != it_end; ++it) { | ||
1770 | if ((*it)->window() == win) | ||
1771 | break; | ||
1772 | } | ||
1773 | // internal tabs are on title bar | ||
1774 | if (it != it_end) | ||
1775 | return context | Keys::ON_TAB | (externalTabMode()?0:Keys::ON_TITLEBAR); | ||
1776 | |||
1777 | return context; | ||
1778 | } | ||