-
- case LFUN_MOUSE_PRESS:
- if (cmd.button() != mouse_button::button3)
- InsetCollapsable::doDispatch(cur, cmd);
- else
- cur.undispatched();
- break;
-
- case LFUN_INSET_DIALOG_UPDATE:
- cur.bv().updateDialog("branch", params2string(params()));
+ case LFUN_BRANCH_ACTIVATE:
+ case LFUN_BRANCH_DEACTIVATE: {
+ Buffer * buf = const_cast<Buffer *>(buffer().masterBuffer());
+ // is the branch in our master buffer?
+ bool branch_in_master = (buf != &buffer());
+
+ Branch * our_branch = buf->params().branchlist().find(params_.branch);
+ if (branch_in_master && !our_branch) {
+ // child only?
+ our_branch = buffer().params().branchlist().find(params_.branch);
+ if (!our_branch)
+ break;
+ branch_in_master = false;
+ }
+ bool const activate = (cmd.action() == LFUN_BRANCH_ACTIVATE);
+ if (our_branch->isSelected() != activate) {
+ // FIXME If the branch is in the master document, we cannot
+ // call recordUndo..., becuase the master may be hidden, and
+ // the code presently assumes that hidden documents can never
+ // be dirty. See GuiView::closeBufferAll(), for example.
+ if (!branch_in_master)
+ buffer().undo().recordUndoFullDocument(cur);
+ our_branch->setSelected(activate);
+ cur.forceBufferUpdate();
+ }