Browse Source

Trying to fix session tab order when tab opening next current

master
boisso 7 years ago
parent
commit
bfc3c2a7ff
  1. 1
      k-meleon/BrowserFrmTab.h
  2. 30
      k-meleon/Plugins.cpp
  3. 4
      k-meleon/TabReBar.cpp
  4. 4
      k-meleon/TabReBar.h
  5. 2
      k-meleon/kmeleon_plugin.h
  6. 22
      k-meleon/sessions/sessions.cpp
  7. 16
      k-meleon/sessions/sessions.h
  8. 3
      k-meleon/sessions/sessionstore.cpp

1
k-meleon/BrowserFrmTab.h

@ -152,6 +152,7 @@ public:
virtual void RecalcLayout(BOOL bNotify = TRUE);
const CTabReBar* GetTabBar() { return m_wndTabs; }
protected:
CBrowserTab* m_wndCBrowserTab;

30
k-meleon/Plugins.cpp

@ -975,7 +975,8 @@ UINT GetWindowVar(HWND hWnd, WindowVarType type, void* ret)
case Window_Tab_Index: {
if (!ret) return 1;
if (frame->IsKindOf(RUNTIME_CLASS(CBrowserFrmTab)))
*(int*)ret = ((CBrowserFrmTab*)frame)->GetActiveTab()->m_iIndex;
//*(int*)ret = ((CBrowserFrmTab*)frame)->GetActiveTab()->m_iIndex;
*(int*)ret = ((CBrowserFrmTab*)frame)->GetTabBar()->FindByData((DWORD_PTR)(CBrowserTab*)view);
else
*(int*)ret = 0;
return 1;
@ -2004,6 +2005,25 @@ bool AddPermission(const char* url, const char* type, const char* perm, bool ses
return NS_SUCCEEDED(man->Add(uri, type, permission, sessionOnly?nsIPermissionManager::EXPIRE_SESSION:nsIPermissionManager::EXPIRE_NEVER, 0));
}
HWND GetCurrent(HWND hWnd)
{
CBrowserFrame* frame = GetFrame(hWnd);
if (!frame) return NULL;
return frame->GetActiveView()->GetSafeHwnd();
}
bool RunCommand(HWND hWnd, const char* command)
{
UINT id = theApp.commands.GetId(command);
if (!id) return false;
PLUGIN_HEADER(hWnd, false);
if (view->OnCmdMsg(id, CN_COMMAND, nullptr, nullptr))
return true;
return frame->SendMessage(WM_COMMAND, MAKELONG(id, 1), 0)>0;
}
kmeleonFunctions kmelFuncsUTF8 = {
SendMessage,
GetCommandIDs,
@ -2078,7 +2098,9 @@ kmeleonFunctions kmelFuncsUTF8 = {
SetCmdIcon,
SetButtonIcon,
AddPermission,
ShowMenu
ShowMenu,
GetCurrent,
RunCommand
};
kmeleonFunctions kmelFuncs = {
@ -2155,7 +2177,9 @@ kmeleonFunctions kmelFuncs = {
SetCmdIcon,
SetButtonIcon,
AddPermission,
ShowMenu
ShowMenu,
GetCurrent,
RunCommand
};
BOOL CPlugins::TestLoad(LPCTSTR file, const char *description)

4
k-meleon/TabReBar.cpp

@ -578,7 +578,7 @@ BOOL CTabReBar::DeleteItem(int idCommand)
return r;
}
int CTabReBar::FindByData(DWORD_PTR data)
int CTabReBar::FindByData(DWORD_PTR data) const
{
bool found = false;
@ -594,7 +594,7 @@ int CTabReBar::FindByData(DWORD_PTR data)
return iCount;
}
int CTabReBar::FindById(int idCommand)
int CTabReBar::FindById(int idCommand) const
{
bool found = false;
int iCount, iButtonCount = GetToolBarCtrl().GetButtonCount();

4
k-meleon/TabReBar.h

@ -108,8 +108,8 @@ public:
//UINT GetItemCommandID(int index);
BOOL DeleteItem(int idCommand);
int FindById(int idCommand);
int FindByData(DWORD_PTR data);
int FindById(int idCommand) const;
int FindByData(DWORD_PTR data) const;
CMenu* m_Menu;
BOOL GetItemText(int idCommand, CString& str);

2
k-meleon/kmeleon_plugin.h

@ -387,6 +387,8 @@ typedef struct {
int (*SetButtonIcon)(const char* toolbar, UINT id, const char* icon, const LPRECT region, const char* hot, const LPRECT hotregion, const char* dead, const LPRECT deadregion);
bool (*AddPermission)(const char* url, const char* type, const char* perm, bool sessionOnly);
UINT (*ShowMenu)(HWND hWnd, const char* name, bool sendCommand);
HWND (*GetCurrent)(HWND hWnd);
bool (*RunCommand)(HWND hWnd, const char* command);
} kmeleonFunctions;
/*

22
k-meleon/sessions/sessions.cpp

@ -62,6 +62,22 @@ kmeleonPlugin kPlugin = {
#include "sessions.h"
bool Session::loading = false;
int Session::openOption = 0;
void Window::addTab(HWND hWnd) {
int option = 0;
kPlugin.kFuncs->GetPreference(PREF_INT, "kmeleon.tabs.onOpenOption", &option, &option);
// Until we have a better option
if (option != 1 || !tabsList.size())
tabsList.push_back(Tab(hWnd, this->hWnd));
else {
HWND hWndCurrent = kPlugin.kFuncs->GetCurrent(hWnd);
TABLIST::iterator iter = findTab(hWndCurrent);
if (iter != tabsList.end()) iter++;
tabsList.insert(iter , Tab(hWnd, this->hWnd));
}
tabcount++;
}
Session currentSession;
Session undo;
@ -174,10 +190,10 @@ long DoMessage(const char *to, const char *from, const char *subject, long data1
}
else if (strcmp(subject, "SwitchTab") == 0) {
int selected = 0;
if (!data1) return 0;
Window* w = currentSession.getWindow(GetParent((HWND)data1));
if (!data2) return 0;
Window* w = currentSession.getWindow(GetParent((HWND)data2));
if (w) {
kPlugin.kFuncs->GetWindowVar((HWND)data1, Window_Tab_Index, &selected);
kPlugin.kFuncs->GetWindowVar((HWND)data2, Window_Tab_Index, &selected);
w->selectedTab = selected;
}
}

16
k-meleon/sessions/sessions.h

@ -152,10 +152,7 @@ public:
tabcount++;
}
void addTab(HWND hWnd) {
tabsList.push_back(Tab(hWnd, this->hWnd));
tabcount++;
}
void addTab(HWND hWnd);
TABLIST::iterator const findTab(HWND hWnd) {
TABLIST::iterator iter;
@ -358,9 +355,11 @@ typedef std::vector<Window> WINLIST;
class Session {
std::string name;
WINLIST windowsList;
public:
static bool loading;
static int openOption;
Session() {
//name = aName;
@ -479,9 +478,18 @@ public:
HWND activewnd = NULL;
WINLIST::iterator iter = windowsList.begin();
// XXX Change the open tab option
int tmp = 0;
kPlugin.kFuncs->GetPreference(PREF_INT, "kmeleon.tabs.onOpenOption", &openOption, &openOption);
kPlugin.kFuncs->SetPreference(PREF_INT, "kmeleon.tabs.onOpenOption", &tmp, FALSE);
for (iter = windowsList.begin(); iter != windowsList.end(); iter++) {
if ((*iter).open()) activewnd = (*iter).hWnd;
}
kPlugin.kFuncs->SetPreference(PREF_INT, "kmeleon.tabs.onOpenOption", &openOption, FALSE);
if (activewnd) SetForegroundWindow(activewnd);
return true;
}

3
k-meleon/sessions/sessionstore.cpp

@ -324,7 +324,8 @@ bool SessionStore::Read(Session& s)
if (win.HasMember("tabs") && win["tabs"].IsArray() && win["tabs"].Size()) {
Value& tabs = win["tabs"];
w.tabcount = tabs.Size();
w.selectedTab = win["selected"].GetInt();
w.selectedTab = win["selected"].GetInt();
w.tabsList.reserve(w.tabcount);
for (SizeType j=0;j<w.tabcount;j++) {
Tab tab(NULL, w.hWnd);
Value& t = tabs[j];

Loading…
Cancel
Save