hrev51223 adds 2 changesets to branch 'master'
old head: 4c9ec29000770e44b7edca208c857d3391eb5f53
new head: bb0d0ea2e307340ec9e912e75a9d09e1e7529fd5
overview:
http://cgit.haiku-os.org/haiku/log/?qt=range&q=bb0d0ea2e307+%5E4c9ec2900077
----------------------------------------------------------------------------
af5001925e99: Fixed (again) the way URL locking works.
URL input is considered locked when it is focused and original text was
changed. Pressing ESC will now change URL input's text to the current URL.
Signed-off-by: Adrien Destugues <pulkomandy@xxxxxxxxxxxxx>
[ Victor <vikkindhart@xxxxxxxxx> ]
bb0d0ea2e307: pc_serial: cleanup, no functional changes
- Improve readability of code to detect serial debug
- Rename usb_serial_* functions to pc_serial_* (code was copied from the
USB serial driver)
[ Adrien Destugues <pulkomandy@xxxxxxxxxxxxx> ]
----------------------------------------------------------------------------
6 files changed, 49 insertions(+), 79 deletions(-)
.../kernel/drivers/ports/pc_serial/Driver.cpp | 4 +-
.../kernel/drivers/ports/pc_serial/Tracing.cpp | 2 +-
.../kernel/drivers/ports/pc_serial/Tracing.h | 10 +--
src/apps/webpositive/BrowserWindow.cpp | 30 +++++---
src/apps/webpositive/URLInputGroup.cpp | 73 +++++---------------
src/apps/webpositive/URLInputGroup.h | 9 +--
############################################################################
Commit: af5001925e99aa2fea37dc66c3613dd99c046651
URL: http://cgit.haiku-os.org/haiku/commit/?id=af5001925e99
Author: Victor <vikkindhart@xxxxxxxxx>
Date: Sat Jun 17 14:01:52 2017 UTC
Committer: Adrien Destugues <pulkomandy@xxxxxxxxxxxxx>
Commit-Date: Sun Jun 25 05:40:35 2017 UTC
Fixed (again) the way URL locking works.
URL input is considered locked when it is focused and original text was
changed. Pressing ESC will now change URL input's text to the current URL.
Signed-off-by: Adrien Destugues <pulkomandy@xxxxxxxxxxxxx>
----------------------------------------------------------------------------
diff --git a/src/apps/webpositive/BrowserWindow.cpp
b/src/apps/webpositive/BrowserWindow.cpp
index e899593..066d189 100644
--- a/src/apps/webpositive/BrowserWindow.cpp
+++ b/src/apps/webpositive/BrowserWindow.cpp
@@ -735,12 +735,10 @@ BrowserWindow::DispatchMessage(BMessage* message,
BHandler* target)
// Do it in such a way that the user sees the
Go-button go down.
_InvokeButtonVisibly(fURLInputGroup->GoButton());
return;
- }
- // Lock the URL text control to prevent changes while
user is
- // typing and set a timer to unlock it after a set
period
- // of time.
- else {
- fURLInputGroup->LockURLInput();
+ } else if (bytes[0] == B_ESCAPE) {
+ // Replace edited text with the current URL.
+ fURLInputGroup->LockURLInput(false);
+
fURLInputGroup->SetText(CurrentWebView()->MainFrameURL());
}
} else if (target == fFindTextControl->TextView()) {
// Handle B_RETURN when the find text control has focus.
@@ -1314,6 +1312,10 @@ BrowserWindow::SetCurrentWebView(BWebView* webView)
} else
webView->MakeFocus(true);
+ bool state = fURLInputGroup->IsURLInputLocked();
+ fURLInputGroup->LockURLInput(false);
+ // Unlock it so the following code can update the URL
+
if (userData != NULL) {
fURLInputGroup->SetPageIcon(userData->PageIcon());
if (userData->URLInputContents().Length())
@@ -1330,6 +1332,9 @@ BrowserWindow::SetCurrentWebView(BWebView* webView)
fURLInputGroup->SetText(webView->MainFrameURL());
}
+ fURLInputGroup->LockURLInput(state);
+ // Restore the state
+
// Trigger update of the interface to the new page, by
requesting
// to resend all notifications.
webView->WebPage()->ResendNotifications();
@@ -1474,8 +1479,15 @@ BrowserWindow::CloseWindowRequested(BWebView* view)
void
BrowserWindow::LoadNegotiating(const BString& url, BWebView* view)
{
- if (view != CurrentWebView())
- return;
+ if (view != CurrentWebView()) {
+ // Update the userData contents instead so the user sees
+ // the correct URL when they switch back to that tab.
+ PageUserData* userData = static_cast<PageUserData*>(
+ view->GetUserData());
+ if (userData != NULL && userData->URLInputContents().Length()
== 0) {
+ userData->SetURLInputContents(url);
+ }
+ }
fURLInputGroup->SetText(url.String());
@@ -1729,6 +1741,8 @@ void
BrowserWindow::UpdateGlobalHistory(const BString& url)
{
BrowsingHistory::DefaultInstance()->AddItem(BrowsingHistoryItem(url));
+
+ fURLInputGroup->SetText(CurrentWebView()->MainFrameURL());
}
diff --git a/src/apps/webpositive/URLInputGroup.cpp
b/src/apps/webpositive/URLInputGroup.cpp
index 0106378..9a0437e 100644
--- a/src/apps/webpositive/URLInputGroup.cpp
+++ b/src/apps/webpositive/URLInputGroup.cpp
@@ -151,7 +151,6 @@ public:
virtual void MouseDown(BPoint where);
virtual void KeyDown(const char* bytes,
int32 numBytes);
virtual void MakeFocus(bool focused = true);
- virtual void SetPreviousText(const char*
text);
virtual BSize MinSize();
virtual BSize MaxSize();
@@ -170,7 +169,6 @@ private:
private:
URLInputGroup* fURLInputGroup;
TextViewCompleter* fURLAutoCompleter;
- BString fPreviousText;
bool
fUpdateAutoCompleterChoices;
};
@@ -181,7 +179,6 @@ URLInputGroup::URLTextView::URLTextView(URLInputGroup*
parent)
fURLInputGroup(parent),
fURLAutoCompleter(new TextViewCompleter(this,
new BrowsingHistoryChoiceModel())),
- fPreviousText(""),
fUpdateAutoCompleterChoices(true)
{
MakeResizable(true);
@@ -285,8 +282,8 @@ URLInputGroup::URLTextView::KeyDown(const char* bytes,
int32 numBytes)
break;
case B_ESCAPE:
- // Revert to text as it was when we received keyboard
focus.
- SetText(fPreviousText.String());
+ // Text already unlocked && replaced in BrowserWindow,
+ // now select it.
SelectAll();
break;
@@ -295,40 +292,37 @@ URLInputGroup::URLTextView::KeyDown(const char* bytes,
int32 numBytes)
break;
default:
+ {
+ BString currentText = Text();
BTextView::KeyDown(bytes, numBytes);
+ // Lock the URL input if it was modified
+ if (!fURLInputGroup->IsURLInputLocked()
+ && Text() != currentText)
+ fURLInputGroup->LockURLInput();
break;
+ }
}
}
void
URLInputGroup::URLTextView::MakeFocus(bool focus)
{
- // Unlock the URL input ahead of time if focus was lost.
- if (!focus) {
+ // Unlock the URL input if focus was lost.
+ if (!focus)
fURLInputGroup->LockURLInput(false);
- }
if (focus == IsFocus())
return;
BTextView::MakeFocus(focus);
- if (focus) {
- fPreviousText = Text();
+ if (focus)
SelectAll();
- }
fURLInputGroup->Invalidate();
}
-void
-URLInputGroup::URLTextView::SetPreviousText(const char* text)
-{
- fPreviousText = text;
-}
-
-
BSize
URLInputGroup::URLTextView::MinSize()
{
@@ -596,7 +590,6 @@ private:
URLInputGroup::URLInputGroup(BMessage* goMessage)
:
BGroupView(B_HORIZONTAL, 0.0),
- fURLLockTimeout(NULL),
fWindowActive(false),
fURLLocked(false)
{
@@ -629,7 +622,6 @@ URLInputGroup::URLInputGroup(BMessage* goMessage)
URLInputGroup::~URLInputGroup()
{
- delete fURLLockTimeout;
}
@@ -683,14 +675,9 @@ URLInputGroup::TextView() const
void
URLInputGroup::SetText(const char* text)
{
- // Ignore setting the text, if the user edited the URL in the last
- // couple of seconds. Instead set the previous text in the text view,
- // so if the user presses ESC the input will update to show the new
- // text.
- if (fURLLocked) {
- fTextView->SetPreviousText(text);
+ // Ignore setting the text, if the input is locked.
+ if (fURLLocked)
return;
- }
if (!text || !Text() || strcmp(Text(), text) != 0) {
fTextView->SetUpdateAutoCompleterChoices(false);
@@ -721,37 +708,15 @@ URLInputGroup::SetPageIcon(const BBitmap* icon)
}
-void
-URLInputGroup::LockURLInput(bool lock)
+bool
+URLInputGroup::IsURLInputLocked() const
{
- fURLLocked = lock;
- if (lock) {
- if (fURLLockTimeout == NULL) {
- fURLLockTimeout = new BMessageRunner(this,
- new BMessage(MSG_LOCK_TIMEOUT), LOCK_TIMEOUT,
1);
- } else {
- fURLLockTimeout->SetInterval(LOCK_TIMEOUT);
- }
- }
+ return fURLLocked;
}
void
-URLInputGroup::MessageReceived(BMessage* message)
+URLInputGroup::LockURLInput(bool lock)
{
- switch (message->what) {
- case MSG_LOCK_TIMEOUT:
- {
- delete fURLLockTimeout;
- fURLLockTimeout = NULL;
- LockURLInput(false);
- break;
- }
- default:
- {
- BGroupView(message);
- break;
- }
- }
+ fURLLocked = lock;
}
-
diff --git a/src/apps/webpositive/URLInputGroup.h
b/src/apps/webpositive/URLInputGroup.h
index 2e5bd72..21bae63 100644
--- a/src/apps/webpositive/URLInputGroup.h
+++ b/src/apps/webpositive/URLInputGroup.h
@@ -6,18 +6,12 @@
#define URL_INPUT_GROUP_H
#include <GroupView.h>
-#include <MessageRunner.h>
class BButton;
class BTextView;
class URLInputGroup : public BGroupView {
-private:
- static const uint32 MSG_LOCK_TIMEOUT = 'loti';
- static const bigtime_t LOCK_TIMEOUT = 1000000;
- // Lock will timeout in one second
-
public:
URLInputGroup(BMessage* goMessage);
virtual ~URLInputGroup();
@@ -35,14 +29,13 @@ public:
void SetPageIcon(const
BBitmap* icon);
+ bool IsURLInputLocked()
const;
virtual void LockURLInput(bool lock = true);
- virtual void MessageReceived(BMessage*
message);
private:
class PageIconView;
class URLTextView;
- BMessageRunner* fURLLockTimeout;
PageIconView* fIconView;
URLTextView* fTextView;
BButton* fGoButton;
############################################################################
Revision: hrev51223
Commit: bb0d0ea2e307340ec9e912e75a9d09e1e7529fd5
URL: http://cgit.haiku-os.org/haiku/commit/?id=bb0d0ea2e307
Author: Adrien Destugues <pulkomandy@xxxxxxxxxxxxx>
Date: Sun Jun 25 05:54:02 2017 UTC
pc_serial: cleanup, no functional changes
- Improve readability of code to detect serial debug
- Rename usb_serial_* functions to pc_serial_* (code was copied from the
USB serial driver)
----------------------------------------------------------------------------
diff --git a/src/add-ons/kernel/drivers/ports/pc_serial/Driver.cpp
b/src/add-ons/kernel/drivers/ports/pc_serial/Driver.cpp
index ffcfa38..dde2499 100644
--- a/src/add-ons/kernel/drivers/ports/pc_serial/Driver.cpp
+++ b/src/add-ons/kernel/drivers/ports/pc_serial/Driver.cpp
@@ -524,9 +524,7 @@ scan_isa_hardcoded()
{
#ifdef HANDLE_ISA_COM
int i;
- bool serialDebug = true;
-
- serialDebug = get_safemode_boolean("serial_debug_output", serialDebug);
+ bool serialDebug = get_safemode_boolean("serial_debug_output", true);
for (i = 0; i < 4; i++) {
// skip the port used for kernel debugging...
diff --git a/src/add-ons/kernel/drivers/ports/pc_serial/Tracing.cpp
b/src/add-ons/kernel/drivers/ports/pc_serial/Tracing.cpp
index 358f0fc..2ed74ff 100644
--- a/src/add-ons/kernel/drivers/ports/pc_serial/Tracing.cpp
+++ b/src/add-ons/kernel/drivers/ports/pc_serial/Tracing.cpp
@@ -70,7 +70,7 @@ create_log_file()
void
-usb_serial_trace(bool force, const char *format, ...)
+pc_serial_trace(bool force, const char *format, ...)
{
if (!gLogEnabled && !force)
return;
diff --git a/src/add-ons/kernel/drivers/ports/pc_serial/Tracing.h
b/src/add-ons/kernel/drivers/ports/pc_serial/Tracing.h
index 422550a..b70ff31 100644
--- a/src/add-ons/kernel/drivers/ports/pc_serial/Tracing.h
+++ b/src/add-ons/kernel/drivers/ports/pc_serial/Tracing.h
@@ -10,20 +10,20 @@
void load_settings();
void create_log_file();
-void usb_serial_trace(bool force, const char *format, ...);
+void pc_serial_trace(bool force, const char *format, ...);
-#define TRACE_ALWAYS(x...) usb_serial_trace(true, x);
-#define TRACE(x...) usb_serial_trace(false, x);
+#define TRACE_ALWAYS(x...) pc_serial_trace(true, x);
+#define TRACE(x...) pc_serial_trace(false, x);
extern bool gLogFunctionCalls;
#define TRACE_FUNCALLS(x...) \
if (gLogFunctionCalls) \
- usb_serial_trace(false, x);
+ pc_serial_trace(false, x);
extern bool gLogFunctionReturns;
#define TRACE_FUNCRET(x...) \
if (gLogFunctionReturns) \
- usb_serial_trace(false, x);
+ pc_serial_trace(false, x);
extern bool gLogFunctionResults;
#define TRACE_FUNCRES(func, param) \