more external tab work, tidying and tab width config option
@@ -4,6 +4,7 @@ *06/03/22:
* More external tabs work (Simon) - Can now be placed TopLeft/TopRight/BottomLeft/BottomRight - New "Tab Options" config menu, with (efficient) runtime updating + - New tab.width config option to control external tab width - edge snapping includes tabs - decoration fixes where some missed the tab option - label text color was not updated
@@ -260,7 +260,10 @@
} void Container::setMaxSizePerClient(unsigned int size) { - m_max_size_per_client = size; + if (size != m_max_size_per_client) { + m_max_size_per_client = size; + repositionItems(); + } } void Container::setMaxTotalSize(unsigned int size) {
@@ -80,13 +80,12 @@ ButtonMotionMask | ExposureMask |
EnterWindowMask | LeaveWindowMask), m_bevel(1), m_use_titlebar(true), - m_tabplacement(BOTTOMRIGHT), m_use_tabs(true), m_use_handle(true), m_focused(false), m_visible(false), m_button_pm(0), - m_tabmode(NOTSET), + m_tabmode(screen.getDefaultInternalTabs()?INTERNAL:EXTERNAL), m_need_render(true), m_themelistener(*this), m_shape(new Shape(m_window, theme.shapePlace())) {@@ -128,6 +127,8 @@ if (tabmode == NOTSET)
tabmode = m_tabmode; m_tabmode = tabmode; + + m_tab_container.setUpdateLock(true); // reparent tab container if (tabmode == EXTERNAL) {@@ -145,7 +146,7 @@ GrabModeSync, GrabModeSync, None, None);
XUngrabButton(m_tab_container.display(), Button1, Mod1Mask|Mod2Mask|Mod3Mask, m_tab_container.window()); int tabx, taby; - switch (m_tabplacement) { + switch (m_screen.getTabPlacement()) { case TOPLEFT: m_tab_container.setAlignment(Container::LEFT); tabx = x();@@ -173,8 +174,13 @@ m_tab_container.reparent(m_screen.rootWindow(), tabx, taby);
m_layeritem.addWindow(m_tab_container); } - m_tab_container.setMaxSizePerClient(64); //!!TODO make this a setting + m_tab_container.setMaxSizePerClient(m_screen.getTabWidth()); + m_tab_container.setUpdateLock(false); m_tab_container.setMaxTotalSize(window().width()); + + renderTabContainer(); + applyTabContainer(); + m_tab_container.clear(); // TODO: tab position if (m_use_tabs && m_visible)@@ -194,7 +200,13 @@ m_tab_container.raise();
} m_tab_container.setBorderWidth(0); m_tab_container.setMaxTotalSize(0); + m_tab_container.setUpdateLock(false); m_tab_container.setMaxSizePerClient(0); + + renderTabContainer(); + applyTabContainer(); + m_tab_container.clear(); + if (!m_use_tabs) m_tab_container.show(); else@@ -310,7 +322,7 @@ } else {
m_window.resize(width, height); } - if (move || resize && m_tabplacement != TOPLEFT) + if (move || resize && m_screen.getTabPlacement() != TOPLEFT) alignTabs(); if (resize) {@@ -333,8 +345,10 @@ void FbWinFrame::alignTabs() {
if (m_tabmode != EXTERNAL) return; + m_tab_container.setMaxSizePerClient(m_screen.getTabWidth()); + int tabx = 0, taby = 0; - switch (m_tabplacement) { + switch (m_screen.getTabPlacement()) { case TOPLEFT: tabx = x(); taby = y() - yOffset();@@ -877,8 +891,10 @@ m_titlebar.raise();
} else m_titlebar.lower(); - if (m_tabmode == EXTERNAL) + if (m_tabmode == EXTERNAL) { m_tab_container.resize(m_tab_container.width(), buttonHeight()); + alignTabs(); + } // leave client+grips alone if we're shaded (it'll get fixed when we unshade) if (!m_shaded) {@@ -1271,9 +1287,7 @@ m_clientarea.setBorderWidth(0);
m_label.setBorderWidth(0); m_shaded = false; - // TODO: configurable default (on compile, for backwards compat) -// setTabMode(EXTERNAL); - setTabMode(INTERNAL); + setTabMode(NOTSET); m_label.setEventMask(ExposureMask | ButtonPressMask | ButtonReleaseMask | ButtonMotionMask |@@ -1605,7 +1619,7 @@ int FbWinFrame::yOffset() const {
if (m_tabmode != EXTERNAL || !m_use_tabs) return 0; - switch (m_tabplacement) { + switch (m_screen.getTabPlacement()) { case TOPLEFT: case TOPRIGHT: return m_tab_container.height() + m_window.borderWidth();
@@ -125,7 +125,7 @@ void setFocus(bool newvalue);
inline void setFocusTitle(const std::string &str) { m_label.setText(str); } void setDoubleClickTime(unsigned int time); bool setTabMode(TabMode tabmode); - inline void setTabPlacement(TabPlacement tabplacement) { m_tabplacement = tabplacement; alignTabs(); } + inline void updateTabProperties() { alignTabs(); } /// add a button to the left of the label void addLeftButton(FbTk::Button *btn);@@ -367,7 +367,6 @@ FbTk::Color m_grip_unfocused_color; ///< unfocused color for grip if no pixmap is given
//@} TabMode m_tabmode; - TabPlacement m_tabplacement; bool m_need_render; int m_button_size; ///< size for all titlebar buttons
@@ -270,6 +270,7 @@ unfocused_alpha(rm, 255, scrname+".window.unfocus.alpha", altscrname+".Window.Unfocus.Alpha"),
menu_alpha(rm, 255, scrname+".menu.alpha", altscrname+".Menu.Alpha"), menu_delay(rm, 0, scrname + ".menuDelay", altscrname+".MenuDelay"), menu_delay_close(rm, 0, scrname + ".menuDelayClose", altscrname+".MenuDelayClose"), + tab_width(rm, 64, scrname + ".tab.width", altscrname+".Tab.Width"), menu_mode(rm, FbTk::MenuTheme::DELAY_OPEN, scrname+".menuMode", altscrname+".MenuMode"), gc_line_width(rm, 1, scrname+".overlay.lineWidth", altscrname+".Overlay.LineWidth"),@@ -287,7 +288,7 @@ scrname+".overlay.capStyle",
altscrname+".overlay.CapStyle"), scroll_action(rm, "", scrname+".windowScrollAction", altscrname+".WindowScrollAction"), scroll_reverse(rm, false, scrname+".windowScrollReverse", altscrname+".WindowScrollReverse"), - default_internal_tabs(rm, false /* TODO: autoconf option? */ , scrname+".tabs.intitlebar", altscrname+".Tabs.InTitlebar") { + default_internal_tabs(rm, true /* TODO: autoconf option? */ , scrname+".tabs.intitlebar", altscrname+".Tabs.InTitlebar") { }@@ -900,7 +901,7 @@ if ((*w_it)->windowList().size()) {
Workspace::Windows::iterator win_it = (*w_it)->windowList().begin(); const Workspace::Windows::iterator win_it_end = (*w_it)->windowList().end(); for (; win_it != win_it_end; ++win_it) { - (*win_it)->frame().setTabPlacement(*resource.tab_placement); + (*win_it)->frame().updateTabProperties(); if (*resource.default_internal_tabs) (*win_it)->frame().setTabMode(FbWinFrame::INTERNAL); else@@ -1642,11 +1643,21 @@ _BOOLITEM(*tab_menu,Configmenu, TabsInTitlebar,
"Tabs in Titlebar", "Tabs in Titlebar", *resource.default_internal_tabs, save_and_reconftabs); + FbTk::MenuItem *tab_width_item = + new IntResMenuItem(_FBTEXT(Configmenu, ExternalTabWidth, + "External Tab Width", + "Width of external-style tabs"), + resource.tab_width, 10, 3000, /* silly number */ + *tab_menu); + tab_width_item->setCommand(save_and_reconftabs); + tab_menu->insert(tab_width_item); + + typedef pair<const char*, FbWinFrame::TabPlacement> PlacementP; typedef list<PlacementP> Placements; Placements place_menu; - // menu is 3 wide, 5 down + // menu is 2 wide, 2 down place_menu.push_back(PlacementP(_FBTEXT(Align, TopLeft, "Top Left", "Top Left"), FbWinFrame::TOPLEFT)); place_menu.push_back(PlacementP(_FBTEXT(Align, BottomLeft, "Bottom Left", "Bottom Left"), FbWinFrame::BOTTOMLEFT)); place_menu.push_back(PlacementP(_FBTEXT(Align, TopRight, "Top Right", "Top Right"), FbWinFrame::TOPRIGHT));
@@ -142,6 +142,8 @@ inline const std::string &getScrollAction() const { return *resource.scroll_action; }
inline const bool getScrollReverse() const { return *resource.scroll_reverse; } inline const bool getDefaultInternalTabs() const { return *resource.default_internal_tabs; } + inline unsigned int getTabWidth() const { return *resource.tab_width; } + inline Slit *slit() { return m_slit.get(); } inline const Slit *slit() const { return m_slit.get(); }@@ -445,7 +447,7 @@ FbTk::Resource<std::string> windowmenufile;
FbTk::Resource<FollowModel> follow_model; bool ordered_dither; FbTk::Resource<int> workspaces, edge_snap_threshold, focused_alpha, - unfocused_alpha, menu_alpha, menu_delay, menu_delay_close; + unfocused_alpha, menu_alpha, menu_delay, menu_delay_close, tab_width; FbTk::Resource<FbTk::MenuTheme::MenuMode> menu_mode; FbTk::Resource<int> gc_line_width;
@@ -394,13 +394,6 @@ }
frame().setUseShape(!m_shaped); - frame().setTabPlacement(screen().getTabPlacement()); - if (screen().getDefaultInternalTabs()) { - frame().setTabMode(FbWinFrame::INTERNAL); - } else { - frame().setTabMode(FbWinFrame::EXTERNAL); - } - //!! TODO init of client should be better // we don't want to duplicate code here and in attachClient m_clientlist.push_back(m_client);