summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/app.c3
-rw-r--r--src/ui/documentwidget.c9
-rw-r--r--src/ui/widget.c6
-rw-r--r--src/ui/widget.h1
4 files changed, 13 insertions, 6 deletions
diff --git a/src/app.c b/src/app.c
index 84066c8e..4365f77d 100644
--- a/src/app.c
+++ b/src/app.c
@@ -124,7 +124,6 @@ struct Impl_App {
124 int sleepTimer; 124 int sleepTimer;
125#endif 125#endif
126 iAtomicInt pendingRefresh; 126 iAtomicInt pendingRefresh;
127 int tabEnum; /* IDs for new tabs */
128 iBool isLoadingPrefs; 127 iBool isLoadingPrefs;
129 iStringList *launchCommands; 128 iStringList *launchCommands;
130 iBool isFinishedLaunching; 129 iBool isFinishedLaunching;
@@ -722,7 +721,6 @@ static void init_App_(iApp *d, int argc, char **argv) {
722 d->certs = new_GmCerts(dataDir_App_()); 721 d->certs = new_GmCerts(dataDir_App_());
723 d->visited = new_Visited(); 722 d->visited = new_Visited();
724 d->bookmarks = new_Bookmarks(); 723 d->bookmarks = new_Bookmarks();
725 d->tabEnum = 0; /* generates unique IDs for tab pages */
726 init_Periodic(&d->periodic); 724 init_Periodic(&d->periodic);
727#if defined (iPlatformAppleDesktop) 725#if defined (iPlatformAppleDesktop)
728 setupApplication_MacOS(); 726 setupApplication_MacOS();
@@ -1602,7 +1600,6 @@ iDocumentWidget *newTab_App(const iDocumentWidget *duplicateOf, iBool switchToNe
1602 else { 1600 else {
1603 doc = new_DocumentWidget(); 1601 doc = new_DocumentWidget();
1604 } 1602 }
1605 setId_Widget(as_Widget(doc), format_CStr("document%03d", ++d->tabEnum));
1606 appendTabPage_Widget(tabs, as_Widget(doc), "", 0, 0); 1603 appendTabPage_Widget(tabs, as_Widget(doc), "", 0, 0);
1607 iRelease(doc); /* now owned by the tabs */ 1604 iRelease(doc); /* now owned by the tabs */
1608 addChild_Widget(findChild_Widget(tabs, "tabs.buttons"), iClob(newTabButton)); 1605 addChild_Widget(findChild_Widget(tabs, "tabs.buttons"), iClob(newTabButton));
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c
index 3175f274..5a5a4f84 100644
--- a/src/ui/documentwidget.c
+++ b/src/ui/documentwidget.c
@@ -298,10 +298,12 @@ struct Impl_DocumentWidget {
298 298
299iDefineObjectConstruction(DocumentWidget) 299iDefineObjectConstruction(DocumentWidget)
300 300
301static int docEnum_ = 0;
302
301void init_DocumentWidget(iDocumentWidget *d) { 303void init_DocumentWidget(iDocumentWidget *d) {
302 iWidget *w = as_Widget(d); 304 iWidget *w = as_Widget(d);
303 init_Widget(w); 305 init_Widget(w);
304 setId_Widget(w, "document000"); 306 setId_Widget(w, format_CStr("document%03d", ++docEnum_));
305 setFlags_Widget(w, hover_WidgetFlag, iTrue); 307 setFlags_Widget(w, hover_WidgetFlag, iTrue);
306 init_PersistentDocumentState(&d->mod); 308 init_PersistentDocumentState(&d->mod);
307 d->flags = 0; 309 d->flags = 0;
@@ -880,7 +882,7 @@ static void updateWindowTitle_DocumentWidget_(const iDocumentWidget *d) {
880 } 882 }
881 /* Take away parts if it doesn't fit. */ 883 /* Take away parts if it doesn't fit. */
882 const int avail = bounds_Widget(as_Widget(tabButton)).size.x - 3 * gap_UI; 884 const int avail = bounds_Widget(as_Widget(tabButton)).size.x - 3 * gap_UI;
883 iBool setWindow = (document_App() == d); 885 iBool setWindow = (document_App() == d && isUnderKeyRoot_Widget(d));
884 for (;;) { 886 for (;;) {
885 iString *text = collect_String(joinCStr_StringArray(title, " \u2014 ")); 887 iString *text = collect_String(joinCStr_StringArray(title, " \u2014 "));
886 if (setWindow) { 888 if (setWindow) {
@@ -1953,7 +1955,8 @@ static iBool handleCommand_DocumentWidget_(iDocumentWidget *d, const char *cmd)
1953 } 1955 }
1954 return iTrue; 1956 return iTrue;
1955 } 1957 }
1956 else if (equal_Command(cmd, "window.resized") || equal_Command(cmd, "font.changed")) { 1958 else if (equal_Command(cmd, "window.resized") || equal_Command(cmd, "font.changed") ||
1959 equal_Command(cmd, "keyroot.changed")) {
1957 /* Alt/Option key may be involved in window size changes. */ 1960 /* Alt/Option key may be involved in window size changes. */
1958 setLinkNumberMode_DocumentWidget_(d, iFalse); 1961 setLinkNumberMode_DocumentWidget_(d, iFalse);
1959 d->phoneToolbar = findWidget_App("toolbar"); 1962 d->phoneToolbar = findWidget_App("toolbar");
diff --git a/src/ui/widget.c b/src/ui/widget.c
index 00fe0f5f..67ce1345 100644
--- a/src/ui/widget.c
+++ b/src/ui/widget.c
@@ -1346,6 +1346,12 @@ iBool isHover_Widget(const iAnyObject *d) {
1346 return get_Window()->hover == d; 1346 return get_Window()->hover == d;
1347} 1347}
1348 1348
1349iBool isUnderKeyRoot_Widget(const iAnyObject *d) {
1350 iAssert(isInstance_Object(d, &Class_Widget));
1351 const iWidget *w = d;
1352 return w && get_Window() && w->root == get_Window()->keyRoot;
1353}
1354
1349iBool isSelected_Widget(const iAnyObject *d) { 1355iBool isSelected_Widget(const iAnyObject *d) {
1350 if (d) { 1356 if (d) {
1351 iAssert(isInstance_Object(d, &Class_Widget)); 1357 iAssert(isInstance_Object(d, &Class_Widget));
diff --git a/src/ui/widget.h b/src/ui/widget.h
index 36797210..5b6b18e1 100644
--- a/src/ui/widget.h
+++ b/src/ui/widget.h
@@ -232,6 +232,7 @@ iBool isDisabled_Widget (const iAnyObject *);
232iBool isFocused_Widget (const iAnyObject *); 232iBool isFocused_Widget (const iAnyObject *);
233iBool isHover_Widget (const iAnyObject *); 233iBool isHover_Widget (const iAnyObject *);
234iBool isSelected_Widget (const iAnyObject *); 234iBool isSelected_Widget (const iAnyObject *);
235iBool isUnderKeyRoot_Widget (const iAnyObject *);
235iBool isCommand_Widget (const iWidget *d, const SDL_Event *ev, const char *cmd); 236iBool isCommand_Widget (const iWidget *d, const SDL_Event *ev, const char *cmd);
236iBool hasParent_Widget (const iWidget *d, const iWidget *someParent); 237iBool hasParent_Widget (const iWidget *d, const iWidget *someParent);
237iBool isAffectedByVisualOffset_Widget 238iBool isAffectedByVisualOffset_Widget