ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
July 2011
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
24 participants
517 discussions
Start a n
N
ew thread
[cgutman] 52723: [AFD] - Fix a nasty datagram corruption bug that would result in an uninitialized buffer data being returned instead of packet data if the client read buffer was smaller than the d...
by cgutman@svn.reactos.org
Author: cgutman Date: Mon Jul 18 04:21:40 2011 New Revision: 52723 URL:
http://svn.reactos.org/svn/reactos?rev=52723&view=rev
Log: [AFD] - Fix a nasty datagram corruption bug that would result in an uninitialized buffer data being returned instead of packet data if the client read buffer was smaller than the datagram received - Fix broken user-mode send datagram IRP completion code which didn't set the completion status - Implement disabling/enabling event select triggers Modified: trunk/reactos/drivers/network/afd/afd/listen.c trunk/reactos/drivers/network/afd/afd/read.c trunk/reactos/drivers/network/afd/afd/select.c trunk/reactos/drivers/network/afd/afd/write.c trunk/reactos/drivers/network/afd/include/afd.h Modified: trunk/reactos/drivers/network/afd/afd/listen.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/afd/afd/li…
============================================================================== --- trunk/reactos/drivers/network/afd/afd/listen.c [iso-8859-1] (original) +++ trunk/reactos/drivers/network/afd/afd/listen.c [iso-8859-1] Mon Jul 18 04:21:40 2011 @@ -367,13 +367,16 @@ AFD_DbgPrint(MID_TRACE,("Completed a wait for accept\n")); ExFreePool( PendingConnObj ); - - if( !IsListEmpty( &FCB->PendingConnections ) ) { - FCB->PollState |= AFD_EVENT_ACCEPT; - FCB->PollStatus[FD_ACCEPT_BIT] = STATUS_SUCCESS; + + FCB->EventSelectDisabled &= ~AFD_EVENT_ACCEPT; + + if( !IsListEmpty( &FCB->PendingConnections ) ) + { + FCB->PollState |= AFD_EVENT_ACCEPT; + FCB->PollStatus[FD_ACCEPT_BIT] = STATUS_SUCCESS; PollReeval( FCB->DeviceExt, FCB->FileObject ); - } else - FCB->PollState &= ~AFD_EVENT_ACCEPT; + } else + FCB->PollState &= ~AFD_EVENT_ACCEPT; SocketStateUnlock( FCB ); return Status; Modified: trunk/reactos/drivers/network/afd/afd/read.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/afd/afd/re…
============================================================================== --- trunk/reactos/drivers/network/afd/afd/read.c [iso-8859-1] (original) +++ trunk/reactos/drivers/network/afd/afd/read.c [iso-8859-1] Mon Jul 18 04:21:40 2011 @@ -408,9 +408,19 @@ *TotalBytesCopied = BytesToCopy; } - - Status = Irp->IoStatus.Status = STATUS_SUCCESS; - Irp->IoStatus.Information = BytesToCopy; + + if (*TotalBytesCopied == DatagramRecv->Len) + { + /* We copied the whole datagram */ + Status = Irp->IoStatus.Status = STATUS_SUCCESS; + } + else + { + /* We only copied part of the datagram */ + Status = Irp->IoStatus.Status = STATUS_BUFFER_OVERFLOW; + } + + Irp->IoStatus.Information = *TotalBytesCopied; if (!(RecvReq->TdiFlags & TDI_RECEIVE_PEEK)) { @@ -464,62 +474,46 @@ Irp, 0 ); } + FCB->EventSelectDisabled &= ~AFD_EVENT_RECEIVE; + if( FCB->Flags & AFD_ENDPOINT_CONNECTIONLESS ) { - if( !IsListEmpty( &FCB->DatagramList ) ) { - ListEntry = RemoveHeadList( &FCB->DatagramList ); - DatagramRecv = CONTAINING_RECORD - ( ListEntry, AFD_STORED_DATAGRAM, ListEntry ); - if( DatagramRecv->Len > RecvReq->BufferArray[0].len && - !(RecvReq->TdiFlags & TDI_RECEIVE_PARTIAL) ) { - InsertHeadList( &FCB->DatagramList, - &DatagramRecv->ListEntry ); - Status = Irp->IoStatus.Status = STATUS_BUFFER_TOO_SMALL; - Irp->IoStatus.Information = DatagramRecv->Len; - - if( !IsListEmpty( &FCB->DatagramList ) ) { - FCB->PollState |= AFD_EVENT_RECEIVE; - FCB->PollStatus[FD_READ_BIT] = STATUS_SUCCESS; - PollReeval( FCB->DeviceExt, FCB->FileObject ); - } else - FCB->PollState &= ~AFD_EVENT_RECEIVE; - - UnlockBuffers( RecvReq->BufferArray, RecvReq->BufferCount, FALSE ); - - AFD_DbgPrint(MIN_TRACE,("Partial datagram not read\n")); - - return UnlockAndMaybeComplete - ( FCB, Status, Irp, Irp->IoStatus.Information ); - } else { - Status = SatisfyPacketRecvRequest - ( FCB, Irp, DatagramRecv, - (PUINT)&Irp->IoStatus.Information ); - - if (RecvReq->TdiFlags & TDI_RECEIVE_PEEK) - { - InsertHeadList(&FCB->DatagramList, - &DatagramRecv->ListEntry); - } - - if( !IsListEmpty( &FCB->DatagramList ) ) { - FCB->PollState |= AFD_EVENT_RECEIVE; - FCB->PollStatus[FD_READ_BIT] = STATUS_SUCCESS; - PollReeval( FCB->DeviceExt, FCB->FileObject ); - } else - FCB->PollState &= ~AFD_EVENT_RECEIVE; - - UnlockBuffers( RecvReq->BufferArray, RecvReq->BufferCount, FALSE ); - - return UnlockAndMaybeComplete - ( FCB, Status, Irp, Irp->IoStatus.Information ); + if (!IsListEmpty(&FCB->DatagramList)) + { + ListEntry = RemoveHeadList(&FCB->DatagramList); + DatagramRecv = CONTAINING_RECORD(ListEntry, AFD_STORED_DATAGRAM, ListEntry); + Status = SatisfyPacketRecvRequest(FCB, Irp, DatagramRecv, + (PUINT)&Irp->IoStatus.Information); + + if (RecvReq->TdiFlags & TDI_RECEIVE_PEEK) + { + InsertHeadList(&FCB->DatagramList, + &DatagramRecv->ListEntry); } - } else if( (RecvReq->AfdFlags & AFD_IMMEDIATE) || (FCB->NonBlocking) ) { + + if (IsListEmpty(&FCB->DatagramList)) + { + FCB->PollState |= AFD_EVENT_RECEIVE; + FCB->PollStatus[FD_READ_BIT] = STATUS_SUCCESS; + PollReeval( FCB->DeviceExt, FCB->FileObject ); + } + else + FCB->PollState &= ~AFD_EVENT_RECEIVE; + + UnlockBuffers(RecvReq->BufferArray, RecvReq->BufferCount, FALSE); + + return UnlockAndMaybeComplete(FCB, Status, Irp, Irp->IoStatus.Information); + } + else if( (RecvReq->AfdFlags & AFD_IMMEDIATE) || (FCB->NonBlocking) ) + { AFD_DbgPrint(MID_TRACE,("Nonblocking\n")); Status = STATUS_CANT_WAIT; FCB->PollState &= ~AFD_EVENT_RECEIVE; UnlockBuffers( RecvReq->BufferArray, RecvReq->BufferCount, FALSE ); return UnlockAndMaybeComplete( FCB, Status, Irp, 0 ); - } else { + } + else + { FCB->PollState &= ~AFD_EVENT_RECEIVE; return LeaveIrpUntilLater( FCB, Irp, FUNCTION_RECV ); } @@ -652,34 +646,26 @@ AFD_DbgPrint(MID_TRACE,("RecvReq: %x, DatagramRecv: %x\n", RecvReq, DatagramRecv)); - if( DatagramRecv->Len > RecvReq->BufferArray[0].len && - !(RecvReq->TdiFlags & TDI_RECEIVE_PARTIAL) ) { - InsertHeadList( &FCB->DatagramList, - &DatagramRecv->ListEntry ); - Status = NextIrp->IoStatus.Status = STATUS_BUFFER_TOO_SMALL; - NextIrp->IoStatus.Information = DatagramRecv->Len; - UnlockBuffers( RecvReq->BufferArray, RecvReq->BufferCount, CheckUnlockExtraBuffers(FCB, NextIrpSp) ); - if ( NextIrp->MdlAddress ) UnlockRequest( NextIrp, IoGetCurrentIrpStackLocation( NextIrp ) ); - (void)IoSetCancelRoutine(NextIrp, NULL); - AFD_DbgPrint(MIN_TRACE,("Partial datagram failed\n")); - IoCompleteRequest( NextIrp, IO_NETWORK_INCREMENT ); - } else { - AFD_DbgPrint(MID_TRACE,("Satisfying\n")); - Status = SatisfyPacketRecvRequest - ( FCB, NextIrp, DatagramRecv, - (PUINT)&NextIrp->IoStatus.Information ); - if (RecvReq->TdiFlags & TDI_RECEIVE_PEEK) - { - InsertHeadList(&FCB->DatagramList, - &DatagramRecv->ListEntry); - } - AFD_DbgPrint(MID_TRACE,("Unlocking\n")); - UnlockBuffers( RecvReq->BufferArray, RecvReq->BufferCount, CheckUnlockExtraBuffers(FCB, NextIrpSp) ); - if ( NextIrp->MdlAddress ) UnlockRequest( NextIrp, IoGetCurrentIrpStackLocation( NextIrp ) ); - AFD_DbgPrint(MID_TRACE,("Completing\n")); - (void)IoSetCancelRoutine(NextIrp, NULL); - IoCompleteRequest( NextIrp, IO_NETWORK_INCREMENT ); - } + AFD_DbgPrint(MID_TRACE,("Satisfying\n")); + Status = SatisfyPacketRecvRequest + ( FCB, NextIrp, DatagramRecv, + (PUINT)&NextIrp->IoStatus.Information ); + + if (RecvReq->TdiFlags & TDI_RECEIVE_PEEK) + { + InsertHeadList(&FCB->DatagramList, + &DatagramRecv->ListEntry); + } + + AFD_DbgPrint(MID_TRACE,("Unlocking\n")); + UnlockBuffers( RecvReq->BufferArray, RecvReq->BufferCount, CheckUnlockExtraBuffers(FCB, NextIrpSp) ); + if ( NextIrp->MdlAddress ) UnlockRequest( NextIrp, IoGetCurrentIrpStackLocation( NextIrp ) ); + + AFD_DbgPrint(MID_TRACE,("Completing\n")); + (void)IoSetCancelRoutine(NextIrp, NULL); + NextIrp->IoStatus.Status = Status; + + IoCompleteRequest( NextIrp, IO_NETWORK_INCREMENT ); } if( !IsListEmpty( &FCB->DatagramList ) && IsListEmpty(&FCB->PendingIrpList[FUNCTION_RECV]) ) { @@ -747,61 +733,45 @@ ( FCB, STATUS_ACCESS_VIOLATION, Irp, 0 ); } - if( !IsListEmpty( &FCB->DatagramList ) ) { - ListEntry = RemoveHeadList( &FCB->DatagramList ); - DatagramRecv = CONTAINING_RECORD - ( ListEntry, AFD_STORED_DATAGRAM, ListEntry ); - if( DatagramRecv->Len > RecvReq->BufferArray[0].len && - !(RecvReq->TdiFlags & TDI_RECEIVE_PARTIAL) ) { - InsertHeadList( &FCB->DatagramList, - &DatagramRecv->ListEntry ); - Status = Irp->IoStatus.Status = STATUS_BUFFER_TOO_SMALL; - Irp->IoStatus.Information = DatagramRecv->Len; - - if( !IsListEmpty( &FCB->DatagramList ) ) { - FCB->PollState |= AFD_EVENT_RECEIVE; - FCB->PollStatus[FD_READ_BIT] = STATUS_SUCCESS; - PollReeval( FCB->DeviceExt, FCB->FileObject ); - } else - FCB->PollState &= ~AFD_EVENT_RECEIVE; - - UnlockBuffers( RecvReq->BufferArray, RecvReq->BufferCount, TRUE ); - - AFD_DbgPrint(MIN_TRACE,("Partial datagram failed\n")); - - return UnlockAndMaybeComplete - ( FCB, Status, Irp, Irp->IoStatus.Information ); - } else { - Status = SatisfyPacketRecvRequest - ( FCB, Irp, DatagramRecv, - (PUINT)&Irp->IoStatus.Information ); - - if (RecvReq->TdiFlags & TDI_RECEIVE_PEEK) - { - InsertHeadList(&FCB->DatagramList, - &DatagramRecv->ListEntry); - } - - if( !IsListEmpty( &FCB->DatagramList ) ) { - FCB->PollState |= AFD_EVENT_RECEIVE; - FCB->PollStatus[FD_READ_BIT] = STATUS_SUCCESS; - PollReeval( FCB->DeviceExt, FCB->FileObject ); - } else - FCB->PollState &= ~AFD_EVENT_RECEIVE; - - UnlockBuffers( RecvReq->BufferArray, RecvReq->BufferCount, TRUE ); - - return UnlockAndMaybeComplete - ( FCB, Status, Irp, Irp->IoStatus.Information ); - } - } else if( (RecvReq->AfdFlags & AFD_IMMEDIATE) || (FCB->NonBlocking) ) { - AFD_DbgPrint(MID_TRACE,("Nonblocking\n")); - Status = STATUS_CANT_WAIT; - FCB->PollState &= ~AFD_EVENT_RECEIVE; - UnlockBuffers( RecvReq->BufferArray, RecvReq->BufferCount, TRUE ); - return UnlockAndMaybeComplete( FCB, Status, Irp, 0 ); - } else { - FCB->PollState &= ~AFD_EVENT_RECEIVE; - return LeaveIrpUntilLater( FCB, Irp, FUNCTION_RECV ); - } -} + FCB->EventSelectDisabled &= ~AFD_EVENT_RECEIVE; + + if (!IsListEmpty(&FCB->DatagramList)) + { + ListEntry = RemoveHeadList(&FCB->DatagramList); + DatagramRecv = CONTAINING_RECORD(ListEntry, AFD_STORED_DATAGRAM, ListEntry); + Status = SatisfyPacketRecvRequest(FCB, Irp, DatagramRecv, + (PUINT)&Irp->IoStatus.Information); + + if (RecvReq->TdiFlags & TDI_RECEIVE_PEEK) + { + InsertHeadList(&FCB->DatagramList, + &DatagramRecv->ListEntry); + } + + if (IsListEmpty(&FCB->DatagramList)) + { + FCB->PollState |= AFD_EVENT_RECEIVE; + FCB->PollStatus[FD_READ_BIT] = STATUS_SUCCESS; + PollReeval( FCB->DeviceExt, FCB->FileObject ); + } + else + FCB->PollState &= ~AFD_EVENT_RECEIVE; + + UnlockBuffers(RecvReq->BufferArray, RecvReq->BufferCount, FALSE); + + return UnlockAndMaybeComplete(FCB, Status, Irp, Irp->IoStatus.Information); + } + else if( (RecvReq->AfdFlags & AFD_IMMEDIATE) || (FCB->NonBlocking) ) + { + AFD_DbgPrint(MID_TRACE,("Nonblocking\n")); + Status = STATUS_CANT_WAIT; + FCB->PollState &= ~AFD_EVENT_RECEIVE; + UnlockBuffers( RecvReq->BufferArray, RecvReq->BufferCount, FALSE ); + return UnlockAndMaybeComplete( FCB, Status, Irp, 0 ); + } + else + { + FCB->PollState &= ~AFD_EVENT_RECEIVE; + return LeaveIrpUntilLater( FCB, Irp, FUNCTION_RECV ); + } +} Modified: trunk/reactos/drivers/network/afd/afd/select.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/afd/afd/se…
============================================================================== --- trunk/reactos/drivers/network/afd/afd/select.c [iso-8859-1] (original) +++ trunk/reactos/drivers/network/afd/afd/select.c [iso-8859-1] Mon Jul 18 04:21:40 2011 @@ -305,8 +305,15 @@ Status = STATUS_SUCCESS; } - if( FCB->EventSelect && (FCB->PollState & FCB->EventSelectTriggers) ) { + if((FCB->EventSelect) && + (FCB->PollState & (FCB->EventSelectTriggers & ~FCB->EventSelectDisabled))) + { AFD_DbgPrint(MID_TRACE,("Setting event %x\n", FCB->EventSelect)); + + /* Disable the events that triggered the select until the reenabling function is called */ + FCB->EventSelectDisabled |= (FCB->PollState & (FCB->EventSelectTriggers & ~FCB->EventSelectDisabled)); + + /* Set the application's event */ KeSetEvent( FCB->EventSelect, IO_NETWORK_INCREMENT, FALSE ); } @@ -408,8 +415,15 @@ KeReleaseSpinLock( &DeviceExt->Lock, OldIrql ); - if( FCB->EventSelect && (FCB->PollState & FCB->EventSelectTriggers) ) { + if((FCB->EventSelect) && + (FCB->PollState & (FCB->EventSelectTriggers & ~FCB->EventSelectDisabled))) + { AFD_DbgPrint(MID_TRACE,("Setting event %x\n", FCB->EventSelect)); + + /* Disable the events that triggered the select until the reenabling function is called */ + FCB->EventSelectDisabled |= (FCB->PollState & (FCB->EventSelectTriggers & ~FCB->EventSelectDisabled)); + + /* Set the application's event */ KeSetEvent( FCB->EventSelect, IO_NETWORK_INCREMENT, FALSE ); } Modified: trunk/reactos/drivers/network/afd/afd/write.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/afd/afd/wr…
============================================================================== --- trunk/reactos/drivers/network/afd/afd/write.c [iso-8859-1] (original) +++ trunk/reactos/drivers/network/afd/afd/write.c [iso-8859-1] Mon Jul 18 04:21:40 2011 @@ -322,6 +322,7 @@ Status = TdiBuildConnectionInfo( &TargetAddress, FCB->RemoteAddress ); if( NT_SUCCESS(Status) ) { + FCB->EventSelectDisabled &= ~AFD_EVENT_SEND; FCB->PollState &= ~AFD_EVENT_SEND; Status = QueueUserModeIrp(FCB, Irp, FUNCTION_SEND); @@ -438,6 +439,8 @@ SpaceAvail -= SendReq->BufferArray[i].len; } + FCB->EventSelectDisabled &= ~AFD_EVENT_SEND; + if( TotalBytesCopied == 0 ) { AFD_DbgPrint(MID_TRACE,("Empty send\n")); UnlockBuffers( SendReq->BufferArray, SendReq->BufferCount, FALSE ); @@ -558,6 +561,7 @@ /* Check the size of the Address given ... */ if( NT_SUCCESS(Status) ) { + FCB->EventSelectDisabled &= ~AFD_EVENT_RECEIVE; FCB->PollState &= ~AFD_EVENT_SEND; Status = QueueUserModeIrp(FCB, Irp, FUNCTION_SEND); Modified: trunk/reactos/drivers/network/afd/include/afd.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/afd/includ…
============================================================================== --- trunk/reactos/drivers/network/afd/include/afd.h [iso-8859-1] (original) +++ trunk/reactos/drivers/network/afd/include/afd.h [iso-8859-1] Mon Jul 18 04:21:40 2011 @@ -193,6 +193,7 @@ KMUTEX Mutex; PKEVENT EventSelect; DWORD EventSelectTriggers; + DWORD EventSelectDisabled; UNICODE_STRING TdiDeviceName; PVOID Context; DWORD PollState;
13 years, 5 months
1
0
0
0
[spetreolle] 52722: [ROSTESTS] Disable urlmon:protocol test since it crashes now. See bug 6381 for more details.
by spetreolle@svn.reactos.org
Author: spetreolle Date: Sun Jul 17 23:22:34 2011 New Revision: 52722 URL:
http://svn.reactos.org/svn/reactos?rev=52722&view=rev
Log: [ROSTESTS] Disable urlmon:protocol test since it crashes now. See bug 6381 for more details. Modified: trunk/rostests/winetests/urlmon/protocol.c Modified: trunk/rostests/winetests/urlmon/protocol.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/urlmon/protocol…
============================================================================== --- trunk/rostests/winetests/urlmon/protocol.c [iso-8859-1] (original) +++ trunk/rostests/winetests/urlmon/protocol.c [iso-8859-1] Sun Jul 17 23:22:34 2011 @@ -3442,6 +3442,12 @@ { HMODULE hurlmon; + if(!winetest_interactive) + { + skip("protocol test skipped, bug 6381\n"); + return; + } + hurlmon = GetModuleHandle("urlmon.dll"); pCoInternetGetSession = (void*) GetProcAddress(hurlmon, "CoInternetGetSession"); pReleaseBindInfo = (void*) GetProcAddress(hurlmon, "ReleaseBindInfo");
13 years, 5 months
1
0
0
0
[osiejka] 52721: [ROSTESTS] - Skip test_enhmetafile to prevent the oleaut_winetest:olepicture crash. See issue #5000 for more details. Test skipping must be diffed, else will be reverted again at w...
by osiejka@svn.reactos.org
Author: osiejka Date: Sun Jul 17 21:30:16 2011 New Revision: 52721 URL:
http://svn.reactos.org/svn/reactos?rev=52721&view=rev
Log: [ROSTESTS] - Skip test_enhmetafile to prevent the oleaut_winetest:olepicture crash. See issue #5000 for more details. Test skipping must be diffed, else will be reverted again at winesync. Modified: trunk/rostests/winetests/oleaut32/olepicture.c Modified: trunk/rostests/winetests/oleaut32/olepicture.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/oleaut32/olepic…
============================================================================== --- trunk/rostests/winetests/oleaut32/olepicture.c [iso-8859-1] (original) +++ trunk/rostests/winetests/oleaut32/olepicture.c [iso-8859-1] Sun Jul 17 21:30:16 2011 @@ -578,6 +578,11 @@ BOOL keep; short type; + if(!winetest_interactive) { + skip("Bug 5000: oleaut_winetest:olepicture crashes with Page Fault.\n"); + return; + } + hglob = GlobalAlloc (0, sizeof(enhmetafile)); data = GlobalLock(hglob); memcpy(data, enhmetafile, sizeof(enhmetafile));
13 years, 5 months
1
0
0
0
[cgutman] 52720: [MSAFD] - Fix several bugs in WSPGetSockName and WSPGetPeerName
by cgutman@svn.reactos.org
Author: cgutman Date: Sun Jul 17 20:19:20 2011 New Revision: 52720 URL:
http://svn.reactos.org/svn/reactos?rev=52720&view=rev
Log: [MSAFD] - Fix several bugs in WSPGetSockName and WSPGetPeerName Modified: trunk/reactos/dll/win32/msafd/misc/dllmain.c Modified: trunk/reactos/dll/win32/msafd/misc/dllmain.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msafd/misc/dllma…
============================================================================== --- trunk/reactos/dll/win32/msafd/misc/dllmain.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/msafd/misc/dllmain.c [iso-8859-1] Sun Jul 17 20:19:20 2011 @@ -1810,13 +1810,13 @@ if (NT_SUCCESS(Status)) { - if (*NameLength >= SocketAddress->Address[0].AddressLength) + if (*NameLength >= Socket->SharedData.SizeOfLocalAddress) { Name->sa_family = SocketAddress->Address[0].AddressType; RtlCopyMemory (Name->sa_data, SocketAddress->Address[0].Address, SocketAddress->Address[0].AddressLength); - *NameLength = 2 + SocketAddress->Address[0].AddressLength; + *NameLength = Socket->SharedData.SizeOfLocalAddress; AFD_DbgPrint (MID_TRACE, ("NameLength %d Address: %x Port %x\n", *NameLength, ((struct sockaddr_in *)Name)->sin_addr.s_addr, ((struct sockaddr_in *)Name)->sin_port)); @@ -1882,7 +1882,7 @@ } /* Allocate a buffer for the address */ - TdiAddressSize = sizeof(TRANSPORT_ADDRESS) + *NameLength; + TdiAddressSize = sizeof(TRANSPORT_ADDRESS) + Socket->SharedData.SizeOfRemoteAddress; SocketAddress = HeapAlloc(GlobalHeap, 0, TdiAddressSize); if ( SocketAddress == NULL ) @@ -1915,13 +1915,13 @@ if (NT_SUCCESS(Status)) { - if (*NameLength >= SocketAddress->Address[0].AddressLength) + if (*NameLength >= Socket->SharedData.SizeOfRemoteAddress) { Name->sa_family = SocketAddress->Address[0].AddressType; RtlCopyMemory (Name->sa_data, SocketAddress->Address[0].Address, SocketAddress->Address[0].AddressLength); - *NameLength = 2 + SocketAddress->Address[0].AddressLength; + *NameLength = Socket->SharedData.SizeOfRemoteAddress; AFD_DbgPrint (MID_TRACE, ("NameLength %d Address: %s Port %x\n", *NameLength, ((struct sockaddr_in *)Name)->sin_addr.s_addr, ((struct sockaddr_in *)Name)->sin_port));
13 years, 5 months
1
0
0
0
[tkreuzer] 52719: [SERVICES] Fix an MSVC warning
by tkreuzer@svn.reactos.org
Author: tkreuzer Date: Sun Jul 17 17:51:52 2011 New Revision: 52719 URL:
http://svn.reactos.org/svn/reactos?rev=52719&view=rev
Log: [SERVICES] Fix an MSVC warning Modified: trunk/reactos/base/system/services/rpcserver.c Modified: trunk/reactos/base/system/services/rpcserver.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/services/rpcse…
============================================================================== --- trunk/reactos/base/system/services/rpcserver.c [iso-8859-1] (original) +++ trunk/reactos/base/system/services/rpcserver.c [iso-8859-1] Sun Jul 17 17:51:52 2011 @@ -586,7 +586,7 @@ lpService = hSvc->ServiceEntry; if (lpService == NULL) { - DPRINT1("lpService == NULL!\n"); + DPRINT1("lpService == NULL!\n"); return ERROR_INVALID_HANDLE; } @@ -973,7 +973,7 @@ TRUE, &hToken); if (!NT_SUCCESS(Status)) - return RtlNtStatusToDosError(Status); + return RtlNtStatusToDosError(Status); RpcRevertToSelf(); @@ -1602,7 +1602,7 @@ } /* Do a real query now */ - LinkTarget.Length = BufferSize; + LinkTarget.Length = (USHORT)BufferSize; LinkTarget.MaximumLength = LinkTarget.Length + sizeof(WCHAR); Status = NtQuerySymbolicLinkObject(SymbolicLinkHandle, &LinkTarget, &BufferSize); @@ -2491,7 +2491,7 @@ dwRequiredSize += dwSize; } - if (dwError == 0) + if (dwError == 0) { *pcbBytesNeeded = 0; if (lpResumeHandle) *lpResumeHandle = 0; @@ -3705,7 +3705,7 @@ lpStatusPtrA = (LPENUM_SERVICE_STATUSA)lpBuffer; lpStringPtrA = (LPSTR)((ULONG_PTR)lpBuffer + *lpServicesReturned * sizeof(ENUM_SERVICE_STATUSA)); - lpStringPtrW = (LPWSTR)((ULONG_PTR)lpStatusPtrW + + lpStringPtrW = (LPWSTR)((ULONG_PTR)lpStatusPtrW + *lpServicesReturned * sizeof(ENUM_SERVICE_STATUSW)); for (dwServiceCount = 0; dwServiceCount < *lpServicesReturned; dwServiceCount++) @@ -4786,7 +4786,7 @@ goto done; } - lpFailureActions->cActions = 0; + lpFailureActions->cActions = 0; lpFailureActions->dwResetPeriod = 0; lpFailureActions->lpCommand = NULL; lpFailureActions->lpRebootMsg = NULL; @@ -4966,7 +4966,7 @@ lpStatusPtrA = (LPENUM_SERVICE_STATUS_PROCESSA)lpBuffer; lpStringPtrA = (LPSTR)((ULONG_PTR)lpBuffer + *lpServicesReturned * sizeof(ENUM_SERVICE_STATUS_PROCESSA)); - lpStringPtrW = (LPWSTR)((ULONG_PTR)lpStatusPtrW + + lpStringPtrW = (LPWSTR)((ULONG_PTR)lpStatusPtrW + *lpServicesReturned * sizeof(ENUM_SERVICE_STATUS_PROCESSW)); for (dwServiceCount = 0; dwServiceCount < *lpServicesReturned; dwServiceCount++) @@ -5286,7 +5286,7 @@ } } - if (dwError == 0) + if (dwError == 0) { *pcbBytesNeeded = 0; if (lpResumeIndex)
13 years, 5 months
1
0
0
0
[cgutman] 52718: [IP/OSKITTCP] - Fix a race condition that occurs when the socket is closed by the remote host while waiting on OSKLock to perform a socket operation and results in accessing freed ...
by cgutman@svn.reactos.org
Author: cgutman Date: Sun Jul 17 17:37:36 2011 New Revision: 52718 URL:
http://svn.reactos.org/svn/reactos?rev=52718&view=rev
Log: [IP/OSKITTCP] - Fix a race condition that occurs when the socket is closed by the remote host while waiting on OSKLock to perform a socket operation and results in accessing freed memory Modified: trunk/reactos/drivers/network/tcpip/include/titypes.h trunk/reactos/lib/drivers/ip/transport/tcp/accept.c trunk/reactos/lib/drivers/ip/transport/tcp/tcp.c trunk/reactos/lib/drivers/oskittcp/CMakeLists.txt trunk/reactos/lib/drivers/oskittcp/include/osenv.h trunk/reactos/lib/drivers/oskittcp/include/oskittcp.h trunk/reactos/lib/drivers/oskittcp/oskittcp.rbuild trunk/reactos/lib/drivers/oskittcp/oskittcp/interface.c trunk/reactos/lib/drivers/oskittcp/oskittcp/sleep.c Modified: trunk/reactos/drivers/network/tcpip/include/titypes.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/tcpip/incl…
============================================================================== --- trunk/reactos/drivers/network/tcpip/include/titypes.h [iso-8859-1] (original) +++ trunk/reactos/drivers/network/tcpip/include/titypes.h [iso-8859-1] Sun Jul 17 17:37:36 2011 @@ -252,6 +252,7 @@ (TCB) in TCP terminology. The FileObject->FsContext2 field holds a pointer to this structure */ typedef struct _CONNECTION_ENDPOINT { + PVOID SocketContext; /* Context for lower layer (MUST be first member in struct) */ LIST_ENTRY ListEntry; /* Entry on list */ LONG RefCount; /* Reference count */ OBJECT_FREE_ROUTINE Free; /* Routine to use to free resources for the object */ @@ -259,7 +260,6 @@ KIRQL OldIrql; /* The old irql is stored here for use in HandleSignalledConnection */ PVOID ClientContext; /* Pointer to client context information */ PADDRESS_FILE AddressFile; /* Associated address file object (NULL if none) */ - PVOID SocketContext; /* Context for lower layer */ /* Requests */ LIST_ENTRY ConnectRequest; /* Queued connect rqueusts */ Modified: trunk/reactos/lib/drivers/ip/transport/tcp/accept.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/ip/transport/t…
============================================================================== --- trunk/reactos/lib/drivers/ip/transport/tcp/accept.c [iso-8859-1] (original) +++ trunk/reactos/lib/drivers/ip/transport/tcp/accept.c [iso-8859-1] Sun Jul 17 17:37:36 2011 @@ -28,7 +28,7 @@ Request->ReturnConnectionInformation; Status = TCPTranslateError - ( OskitTCPAccept( Listener->SocketContext, + ( OskitTCPAccept( Listener, &Connection->SocketContext, Connection, &OutAddr, @@ -75,9 +75,6 @@ TI_DbgPrint(DEBUG_TCP,("TCPListen started\n")); - TI_DbgPrint(DEBUG_TCP,("Connection->SocketContext %x\n", - Connection->SocketContext)); - if (Connection->AddressFile->Port) { AddressToBind.sin_family = AF_INET; @@ -88,7 +85,7 @@ TI_DbgPrint(DEBUG_TCP,("AddressToBind - %x:%x\n", AddressToBind.sin_addr, AddressToBind.sin_port)); /* Perform an explicit bind */ - Status = TCPTranslateError(OskitTCPBind(Connection->SocketContext, + Status = TCPTranslateError(OskitTCPBind(Connection, &AddressToBind, sizeof(AddressToBind))); } @@ -99,7 +96,7 @@ } if (NT_SUCCESS(Status)) - Status = TCPTranslateError( OskitTCPListen( Connection->SocketContext, Backlog ) ); + Status = TCPTranslateError( OskitTCPListen( Connection, Backlog ) ); if (NT_SUCCESS(Status)) { Modified: trunk/reactos/lib/drivers/ip/transport/tcp/tcp.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/ip/transport/t…
============================================================================== --- trunk/reactos/lib/drivers/ip/transport/tcp/tcp.c [iso-8859-1] (original) +++ trunk/reactos/lib/drivers/ip/transport/tcp/tcp.c [iso-8859-1] Sun Jul 17 17:37:36 2011 @@ -56,8 +56,8 @@ if (ClientInfo.Unlocked) LockObjectAtDpcLevel(Connection); - TI_DbgPrint(MID_TRACE,("Handling signalled state on %x (%x)\n", - Connection, Connection->SocketContext)); + TI_DbgPrint(MID_TRACE,("Handling signalled state on %x\n", + Connection)); /* Things that can happen when we try the initial connection */ if( Connection->SignalState & (SEL_CONNECT | SEL_FIN | SEL_ERROR) ) { @@ -68,7 +68,7 @@ if (Connection->SignalState & SEL_ERROR) { - Bucket->Status = TCPTranslateError(OskitTCPGetSocketError(Connection->SocketContext)); + Bucket->Status = TCPTranslateError(OskitTCPGetSocketError(Connection)); } else if (Connection->SignalState & SEL_FIN) { @@ -107,7 +107,7 @@ if (Connection->SignalState & SEL_ERROR) { - Status = TCPTranslateError(OskitTCPGetSocketError(Connection->SocketContext)); + Status = TCPTranslateError(OskitTCPGetSocketError(Connection)); } else if (Connection->SignalState & SEL_FIN) { @@ -161,15 +161,11 @@ ("Reading %d bytes to %x\n", RecvLen, RecvBuffer)); TI_DbgPrint(DEBUG_TCP, ("Connection: %x\n", Connection)); - TI_DbgPrint - (DEBUG_TCP, - ("Connection->SocketContext: %x\n", - Connection->SocketContext)); TI_DbgPrint(DEBUG_TCP, ("RecvBuffer: %x\n", RecvBuffer)); if (Connection->SignalState & SEL_ERROR) { - Status = TCPTranslateError(OskitTCPGetSocketError(Connection->SocketContext)); + Status = TCPTranslateError(OskitTCPGetSocketError(Connection)); } else if (Connection->SignalState & SEL_FIN) { @@ -178,7 +174,7 @@ } else { - Status = TCPTranslateError(OskitTCPRecv(Connection->SocketContext, + Status = TCPTranslateError(OskitTCPRecv(Connection, RecvBuffer, RecvLen, &Received, @@ -227,14 +223,10 @@ ("Writing %d bytes to %x\n", SendLen, SendBuffer)); TI_DbgPrint(DEBUG_TCP, ("Connection: %x\n", Connection)); - TI_DbgPrint - (DEBUG_TCP, - ("Connection->SocketContext: %x\n", - Connection->SocketContext)); if (Connection->SignalState & SEL_ERROR) { - Status = TCPTranslateError(OskitTCPGetSocketError(Connection->SocketContext)); + Status = TCPTranslateError(OskitTCPGetSocketError(Connection)); } else if (Connection->SignalState & SEL_FIN) { @@ -243,7 +235,7 @@ } else { - Status = TCPTranslateError(OskitTCPSend(Connection->SocketContext, + Status = TCPTranslateError(OskitTCPSend(Connection, SendBuffer, SendLen, &Sent, @@ -275,7 +267,7 @@ if (Connection->SignalState & SEL_ERROR) { - Status = TCPTranslateError(OskitTCPGetSocketError(Connection->SocketContext)); + Status = TCPTranslateError(OskitTCPGetSocketError(Connection)); } else if (Connection->SignalState & SEL_FIN) { @@ -288,7 +280,7 @@ if (IsListEmpty(&Connection->SendRequest)) { /* Send queue is empty so we're good to go */ - Status = TCPTranslateError(OskitTCPShutdown(Connection->SocketContext, FWRITE)); + Status = TCPTranslateError(OskitTCPShutdown(Connection, FWRITE)); } else { @@ -341,7 +333,7 @@ LockObjectAtDpcLevel(Connection); /* We timed out waiting for pending sends so force it to shutdown */ - OskitTCPShutdown(Connection->SocketContext, FWRITE); + OskitTCPShutdown(Connection, FWRITE); while (!IsListEmpty(&Connection->SendRequest)) { @@ -438,9 +430,6 @@ Proto ) ); ASSERT_KM_POINTER(Connection->SocketContext); - - TI_DbgPrint(DEBUG_TCP,("Connection->SocketContext %x\n", - Connection->SocketContext)); UnlockObject(Connection, OldIrql); @@ -781,7 +770,7 @@ AddressToBind.sin_port = Connection->AddressFile->Port; /* Perform an explicit bind */ - Status = TCPTranslateError(OskitTCPBind(Connection->SocketContext, + Status = TCPTranslateError(OskitTCPBind(Connection, &AddressToBind, sizeof(AddressToBind))); } @@ -800,7 +789,7 @@ AddressToConnect.sin_port = RemotePort; Status = TCPTranslateError - ( OskitTCPConnect( Connection->SocketContext, + ( OskitTCPConnect( Connection, &AddressToConnect, sizeof(AddressToConnect) ) ); @@ -874,7 +863,7 @@ if (IsListEmpty(&Connection->SendRequest)) { /* Send queue is empty so we're good to go */ - Status = TCPTranslateError(OskitTCPShutdown(Connection->SocketContext, FWRITE)); + Status = TCPTranslateError(OskitTCPShutdown(Connection, FWRITE)); UnlockObject(Connection, OldIrql); @@ -884,7 +873,7 @@ /* Check if the timeout was 0 */ if (Timeout && Timeout->QuadPart == 0) { - OskitTCPShutdown(Connection->SocketContext, FWRITE); + OskitTCPShutdown(Connection, FWRITE); while (!IsListEmpty(&Connection->SendRequest)) { @@ -947,7 +936,7 @@ } /* An abort never pends; we just drop everything and complete */ - Status = TCPTranslateError(OskitTCPShutdown(Connection->SocketContext, FWRITE | FREAD)); + Status = TCPTranslateError(OskitTCPShutdown(Connection, FWRITE | FREAD)); UnlockObject(Connection, OldIrql); @@ -991,41 +980,21 @@ ( PCONNECTION_ENDPOINT Connection ) { KIRQL OldIrql; - NTSTATUS Status; - PVOID Socket; LockObject(Connection, &OldIrql); - Socket = Connection->SocketContext; - Connection->SocketContext = NULL; /* We should not be associated to an address file at this point */ ASSERT(!Connection->AddressFile); - /* Don't try to close again if the other side closed us already */ - if (Socket) - { - /* We need to close here otherwise oskit will never indicate - * SEL_FIN and we will never fully close the connection */ - Status = TCPTranslateError( OskitTCPClose( Socket ) ); - - if (!NT_SUCCESS(Status)) - { - Connection->SocketContext = Socket; - UnlockObject(Connection, OldIrql); - return Status; - } - } - else - { - /* We are already closed by the other end so return success */ - Status = STATUS_SUCCESS; - } + OskitTCPClose(Connection); + + Connection->SocketContext = NULL; UnlockObject(Connection, OldIrql); DereferenceObject(Connection); - return Status; + return STATUS_SUCCESS; } NTSTATUS TCPReceiveData @@ -1042,9 +1011,6 @@ PTDI_BUCKET Bucket; KIRQL OldIrql; - TI_DbgPrint(DEBUG_TCP,("Called for %d bytes (on socket %x)\n", - ReceiveLength, Connection->SocketContext)); - NdisQueryBuffer( Buffer, &DataBuffer, &DataLen ); TI_DbgPrint(DEBUG_TCP,("TCP>|< Got an MDL %x (%x:%d)\n", Buffer, DataBuffer, DataLen)); @@ -1053,7 +1019,7 @@ Status = TCPTranslateError ( OskitTCPRecv - ( Connection->SocketContext, + ( Connection, DataBuffer, DataLen, &Received, @@ -1104,15 +1070,10 @@ LockObject(Connection, &OldIrql); - TI_DbgPrint(DEBUG_TCP,("Called for %d bytes (on socket %x)\n", - SendLength, Connection->SocketContext)); - TI_DbgPrint(DEBUG_TCP,("Connection = %x\n", Connection)); - TI_DbgPrint(DEBUG_TCP,("Connection->SocketContext = %x\n", - Connection->SocketContext)); Status = TCPTranslateError - ( OskitTCPSend( Connection->SocketContext, + ( OskitTCPSend( Connection, (OSK_PCHAR)BufferData, SendLength, &Sent, 0 ) ); @@ -1173,7 +1134,7 @@ LockObject(Connection, &OldIrql); - Status = TCPTranslateError(OskitTCPGetAddress(Connection->SocketContext, + Status = TCPTranslateError(OskitTCPGetAddress(Connection, &LocalAddress, &LocalPort, &RemoteAddress, &RemotePort)); Modified: trunk/reactos/lib/drivers/oskittcp/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/oskittcp/CMake…
============================================================================== --- trunk/reactos/lib/drivers/oskittcp/CMakeLists.txt [iso-8859-1] (original) +++ trunk/reactos/lib/drivers/oskittcp/CMakeLists.txt [iso-8859-1] Sun Jul 17 17:37:36 2011 @@ -5,7 +5,8 @@ include/freebsd/sys/include include/freebsd/dev/include include/freebsd/net/include - include) + include + ${REACTOS_SOURCE_DIR}/drivers/network/tcpip/include) add_definitions( -D__NTDRIVER__ Modified: trunk/reactos/lib/drivers/oskittcp/include/osenv.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/oskittcp/inclu…
============================================================================== --- trunk/reactos/lib/drivers/oskittcp/include/osenv.h [iso-8859-1] (original) +++ trunk/reactos/lib/drivers/oskittcp/include/osenv.h [iso-8859-1] Sun Jul 17 17:37:36 2011 @@ -11,4 +11,12 @@ #define osenv_sleeprec_t void* +/* We can do this safely because SocketContext will always + * be the first member in the real CONNECTION_ENDPOINT struct + */ +typedef struct _FAKE_CONNECTION_ENDPOINT +{ + void *SocketContext; +} *PCONNECTION_ENDPOINT; + #endif Modified: trunk/reactos/lib/drivers/oskittcp/include/oskittcp.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/oskittcp/inclu…
============================================================================== --- trunk/reactos/lib/drivers/oskittcp/include/oskittcp.h [iso-8859-1] (original) +++ trunk/reactos/lib/drivers/oskittcp/include/oskittcp.h [iso-8859-1] Sun Jul 17 17:37:36 2011 @@ -104,67 +104,67 @@ extern void DeinitOskitTCP( void ); extern void TimerOskitTCP( int FastTimer, int SlowTimer ); extern void OskitDumpBuffer( OSK_PCHAR Data, OSK_UINT Len ); -extern int OskitTCPShutdown( void *socket, int disconn_type ); +extern int OskitTCPShutdown( PCONNECTION_ENDPOINT connection, int disconn_type ); extern int OskitTCPSocket( void *Connection, void **ConnectionContext, int Af, int Type, int Proto ); extern void RegisterOskitTCPEventHandlers ( POSKITTCP_EVENT_HANDLERS EventHandlers ); extern void OskitTCPReceiveDatagram( OSK_PCHAR Data, OSK_UINT Len, OSK_UINT IpHeaderLen ); -extern int OskitTCPReceive( void *socket, +extern int OskitTCPReceive( PCONNECTION_ENDPOINT connection, void *Addr, OSK_PCHAR Data, OSK_UINT Len, OSK_UINT *OutLen, OSK_UINT Flags ); -extern int OskitTCPSend( void *socket, +extern int OskitTCPSend( PCONNECTION_ENDPOINT connection, OSK_PCHAR Data, OSK_UINT Len, OSK_UINT *OutLen, OSK_UINT Flags ); -extern int OskitTCPConnect( void *socket, +extern int OskitTCPConnect( PCONNECTION_ENDPOINT connection, void *nam, OSK_UINT namelen ); -extern int OskitTCPClose( void *socket ); - -extern int OskitTCPBind( void *socket, +extern int OskitTCPClose( PCONNECTION_ENDPOINT connection ); + +extern int OskitTCPBind( PCONNECTION_ENDPOINT connection, void *nam, OSK_UINT namelen ); -extern int OskitTCPAccept( void *socket, void **new_socket, +extern int OskitTCPAccept( PCONNECTION_ENDPOINT connection, void **new_socket, void *context, void *addr_out, OSK_UINT addr_len, OSK_UINT *out_addr_len, OSK_UINT finish_accept ); -extern int OskitTCPListen( void *socket, int backlog ); - -extern int OskitTCPRecv( void *connection, +extern int OskitTCPListen( PCONNECTION_ENDPOINT connection, int backlog ); + +extern int OskitTCPRecv( PCONNECTION_ENDPOINT connection, OSK_PCHAR Data, OSK_UINT Len, OSK_UINT *OutLen, OSK_UINT Flags ); -int OskitTCPGetAddress( void *socket, +int OskitTCPGetAddress( PCONNECTION_ENDPOINT connection, OSK_UINT *LocalAddress, OSK_UI16 *LocalPort, OSK_UINT *RemoteAddress, OSK_UI16 *RemotePort ); -int OskitTCPGetSockOpt(void *socket, +int OskitTCPGetSockOpt(PCONNECTION_ENDPOINT connection, int level, int optname, char *buffer, int *size); -int OskitTCPSetSockOpt(void *socket, +int OskitTCPSetSockOpt(PCONNECTION_ENDPOINT connection, int level, int optname, char *buffer, int size); -int OskitTCPDisconnect(void *socket); - -int OskitTCPGetSocketError(void *socket); +int OskitTCPDisconnect(PCONNECTION_ENDPOINT connection); + +int OskitTCPGetSocketError(PCONNECTION_ENDPOINT connection); #undef errno Modified: trunk/reactos/lib/drivers/oskittcp/oskittcp.rbuild URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/oskittcp/oskit…
============================================================================== --- trunk/reactos/lib/drivers/oskittcp/oskittcp.rbuild [iso-8859-1] (original) +++ trunk/reactos/lib/drivers/oskittcp/oskittcp.rbuild [iso-8859-1] Sun Jul 17 17:37:36 2011 @@ -10,6 +10,7 @@ <include base="oskittcp">include/freebsd/dev/include</include> <include base="oskittcp">include/freebsd/net/include</include> <include base="oskittcp">include</include> + <include base="tcpip">include</include> <directory name="oskittcp"> <file>defaults.c</file> <file>in.c</file> Modified: trunk/reactos/lib/drivers/oskittcp/oskittcp/interface.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/oskittcp/oskit…
============================================================================== --- trunk/reactos/lib/drivers/oskittcp/oskittcp/interface.c [iso-8859-1] (original) +++ trunk/reactos/lib/drivers/oskittcp/oskittcp/interface.c [iso-8859-1] Sun Jul 17 17:37:36 2011 @@ -1,3 +1,4 @@ +#include <osenv.h> #include <oskittcp.h> #include <oskitdebug.h> #include <net/raw_cb.h> @@ -136,33 +137,25 @@ OSKLock(); error = socreate(domain, &so, type, proto); if( !error ) { + *aso = so; so->so_connection = context; InitializeSocketFlags(so); - *aso = so; - } - OSKUnlock(); - - return error; -} - -int OskitTCPRecv( void *connection, + } + OSKUnlock(); + + return error; +} + +int OskitTCPRecv( PCONNECTION_ENDPOINT connection, OSK_PCHAR Data, OSK_UINT Len, OSK_UINT *OutLen, - OSK_UINT Flags ) { -#if DBG - struct socket *so = connection; -#endif + OSK_UINT Flags ) +{ struct uio uio = { 0 }; struct iovec iov = { 0 }; int error = 0; int tcp_flags = 0; - - if (!connection) - return OSK_ESHUTDOWN; - - OS_DbgPrint(OSK_MID_TRACE, - ("so->so_state %x\n", so->so_state)); if( Flags & OSK_MSG_OOB ) tcp_flags |= MSG_OOB; if( Flags & OSK_MSG_DONTWAIT ) tcp_flags |= MSG_DONTWAIT; @@ -178,11 +171,16 @@ uio.uio_rw = UIO_READ; uio.uio_procp = NULL; - OS_DbgPrint(OSK_MID_TRACE,("Reading %d bytes from TCP:\n", Len)); - - OSKLock(); - error = soreceive( connection, NULL, &uio, NULL, NULL /* SCM_RIGHTS */, - &tcp_flags ); + OSKLock(); + if (connection->SocketContext) + { + OS_DbgPrint(OSK_MID_TRACE,("Reading %d bytes from TCP:\n", Len)); + error = soreceive(connection->SocketContext, NULL, &uio, NULL, NULL, &tcp_flags); + } + else + { + error = OSK_ESHUTDOWN; + } OSKUnlock(); if (error == 0) *OutLen = Len - uio.uio_resid; @@ -190,17 +188,13 @@ return error; } -int OskitTCPBind( void *socket, - void *nam, OSK_UINT namelen ) { - int error = EFAULT; - struct socket *so = socket; +int OskitTCPBind(PCONNECTION_ENDPOINT connection, void *nam, OSK_UINT namelen) +{ + int error; struct mbuf sabuf; struct sockaddr addr; - OS_DbgPrint(OSK_MID_TRACE,("Called, socket = %08x\n", socket)); - - if (!socket) - return OSK_ESHUTDOWN; + OS_DbgPrint(OSK_MID_TRACE,("Called, socket = %08x\n", connection)); if( nam ) addr = *((struct sockaddr *)nam); @@ -213,23 +207,27 @@ addr.sa_len = sizeof(struct sockaddr); OSKLock(); - error = sobind(so, &sabuf); + if (connection->SocketContext) + { + error = sobind(connection->SocketContext, &sabuf); + } + else + { + error = OSK_ESHUTDOWN; + } OSKUnlock(); OS_DbgPrint(OSK_MID_TRACE,("Ending: %08x\n", error)); return (error); } -int OskitTCPConnect( void *socket, void *nam, OSK_UINT namelen ) { - struct socket *so = socket; - int error = EFAULT; +int OskitTCPConnect( PCONNECTION_ENDPOINT connection, void *nam, OSK_UINT namelen ) +{ + int error; struct mbuf sabuf; struct sockaddr addr; - OS_DbgPrint(OSK_MID_TRACE,("Called, socket = %08x\n", socket)); - - if (!socket) - return OSK_ESHUTDOWN; + OS_DbgPrint(OSK_MID_TRACE,("Called, socket = %08x\n", connection)); OS_DbgPrint(OSK_MIN_TRACE,("Nam: %x\n", nam)); @@ -244,63 +242,78 @@ addr.sa_len = sizeof(struct sockaddr); OSKLock(); - error = soconnect(so, &sabuf); - OSKUnlock(); - - if (error == 0) error = OSK_EINPROGRESS; + if (connection->SocketContext) + { + error = soconnect(connection->SocketContext, &sabuf); + if (!error) error = OSK_EINPROGRESS; + } + else + { + error = OSK_ESHUTDOWN; + } + OSKUnlock(); OS_DbgPrint(OSK_MID_TRACE,("Ending: %08x\n", error)); return (error); } -int OskitTCPDisconnect(void *socket) -{ - int error; - - if (!socket) - return OSK_ESHUTDOWN; - - OSKLock(); - error = sodisconnect(socket); - OSKUnlock(); - - return error; -} - -int OskitTCPShutdown( void *socket, int disconn_type ) { - int error; - - if (!socket) - return OSK_ESHUTDOWN; - - OSKLock(); - error = soshutdown( socket, disconn_type ); - OSKUnlock(); - - return error; -} - -int OskitTCPClose( void *socket ) { - int error; - - if (!socket) - return OSK_ESHUTDOWN; - - OSKLock(); - error = soclose( socket ); - OSKUnlock(); - - return error; -} - -int OskitTCPSend( void *socket, OSK_PCHAR Data, OSK_UINT Len, +int OskitTCPDisconnect(PCONNECTION_ENDPOINT connection) +{ + int error; + + OSKLock(); + if (connection->SocketContext) + { + error = sodisconnect(connection->SocketContext); + } + else + { + error = OSK_ESHUTDOWN; + } + OSKUnlock(); + + return error; +} + +int OskitTCPShutdown(PCONNECTION_ENDPOINT connection, int disconn_type) { + int error; + + OSKLock(); + if (connection->SocketContext) + { + error = soshutdown(connection->SocketContext, disconn_type); + } + else + { + error = OSK_ESHUTDOWN; + } + OSKUnlock(); + + return error; +} + +int OskitTCPClose( PCONNECTION_ENDPOINT connection ) { + int error; + + OSKLock(); + if (connection->SocketContext) + { + error = soclose(connection->SocketContext); + } + else + { + error = OSK_ESHUTDOWN; + } + OSKUnlock(); + + return error; +} + +int OskitTCPSend( PCONNECTION_ENDPOINT connection, OSK_PCHAR Data, OSK_UINT Len, OSK_UINT *OutLen, OSK_UINT flags ) { int error; struct uio uio; struct iovec iov; - - if (!socket) - return OSK_ESHUTDOWN; iov.iov_len = Len; iov.iov_base = (char *)Data; @@ -313,33 +326,36 @@ uio.uio_procp = NULL; OSKLock(); - error = sosend( socket, NULL, &uio, NULL, NULL, 0 ); - OSKUnlock(); - - if (error == 0) *OutLen = Len - uio.uio_resid; - - return error; -} - -int OskitTCPAccept( void *socket, + if (connection->SocketContext) + { + error = sosend( connection->SocketContext, NULL, &uio, NULL, NULL, 0 ); + if (!error) *OutLen = Len - uio.uio_resid; + } + else + { + error = OSK_ESHUTDOWN; + } + OSKUnlock(); + + return error; +} + +int OskitTCPAccept( PCONNECTION_ENDPOINT connection, void **new_socket, void *context, void *AddrOut, OSK_UINT AddrLen, OSK_UINT *OutAddrLen, OSK_UINT FinishAccepting ) { - struct socket *head = (void *)socket; + struct socket *head; struct sockaddr *name = (struct sockaddr *)AddrOut; struct socket **newso = (struct socket **)new_socket; - struct socket *so = socket; + struct socket *so; struct sockaddr_in sa; struct mbuf mnam; struct inpcb *inp; int namelen = 0, error = 0, s; - if (!socket) - return OSK_ESHUTDOWN; - if (!new_socket) return OSK_EINVAL; @@ -351,8 +367,14 @@ namelen = *OutAddrLen; OSKLock(); - s = splnet(); + + head = connection->SocketContext; + if (!head) + { + error = OSK_ESHUTDOWN; + goto out; + } if ((head->so_options & SO_ACCEPTCONN) == 0) { OS_DbgPrint(OSK_MID_TRACE,("OSKITTCP: head->so_options = %x, wanted bit %x\n", @@ -452,7 +474,7 @@ /* The buffer Ip is freed by tcp_input */ } -int OskitTCPSetSockOpt(void *socket, +int OskitTCPSetSockOpt(PCONNECTION_ENDPOINT connection, int level, int optname, char *buffer, @@ -461,32 +483,36 @@ struct mbuf *m; int error; - if (!socket) - return OSK_ESHUTDOWN; - if (size >= MLEN) return OSK_EINVAL; OSKLock(); - m = m_get(M_WAIT, MT_SOOPTS); - if (!m) - { - OSKUnlock(); - return OSK_ENOMEM; - } - - m->m_len = size; - - memcpy(m->m_data, buffer, size); - - /* m is freed by sosetopt */ - error = sosetopt(socket, level, optname, m); + if (connection->SocketContext) + { + m = m_get(M_WAIT, MT_SOOPTS); + if (!m) + { + OSKUnlock(); + return OSK_ENOMEM; + } + + m->m_len = size; + + memcpy(m->m_data, buffer, size); + + /* m is freed by sosetopt */ + error = sosetopt(connection->SocketContext, level, optname, m); + } + else + { + error = OSK_ESHUTDOWN; + } OSKUnlock(); return error; } -int OskitTCPGetSockOpt(void *socket, +int OskitTCPGetSockOpt(PCONNECTION_ENDPOINT connection, int level, int optname, char *buffer, @@ -495,41 +521,49 @@ int error, oldsize = *size; struct mbuf *m; - if (!socket) - return OSK_ESHUTDOWN; - - OSKLock(); - error = sogetopt(socket, level, optname, &m); - if (!error) - { - *size = m->m_len; - - if (!buffer || oldsize < m->m_len) + OSKLock(); + if (connection->SocketContext) + { + error = sogetopt(connection->SocketContext, level, optname, &m); + if (!error) { + *size = m->m_len; + + if (!buffer || oldsize < m->m_len) + { + m_freem(m); + OSKUnlock(); + return OSK_EINVAL; + } + + memcpy(buffer, m->m_data, m->m_len); + m_freem(m); - OSKUnlock(); - return OSK_EINVAL; } - - memcpy(buffer, m->m_data, m->m_len); - - m_freem(m); - } - OSKUnlock(); - - return error; -} - -int OskitTCPListen( void *socket, int backlog ) { - int error; - - if (!socket) - return OSK_ESHUTDOWN; - - OS_DbgPrint(OSK_MID_TRACE,("Called, socket = %08x\n", socket)); - - OSKLock(); - error = solisten( socket, backlog ); + } + else + { + error = OSK_ESHUTDOWN; + } + OSKUnlock(); + + return error; +} + +int OskitTCPListen( PCONNECTION_ENDPOINT connection, int backlog ) { + int error; + + OS_DbgPrint(OSK_MID_TRACE,("Called, socket = %08x\n", connection)); + + OSKLock(); + if (connection->SocketContext) + { + error = solisten(connection->SocketContext, backlog); + } + else + { + error = OSK_ESHUTDOWN; + } OSKUnlock(); OS_DbgPrint(OSK_MID_TRACE,("Ending: %08x\n", error)); @@ -537,18 +571,22 @@ return error; } -int OskitTCPSetAddress( void *socket, +int OskitTCPSetAddress( PCONNECTION_ENDPOINT connection, OSK_UINT LocalAddress, OSK_UI16 LocalPort, OSK_UINT RemoteAddress, OSK_UI16 RemotePort ) { - struct socket *so = socket; + struct socket *so; struct inpcb *inp; - if (!socket) + OSKLock(); + so = connection->SocketContext; + if (!so) + { + OSKUnlock(); return OSK_ESHUTDOWN; - - OSKLock(); + } + inp = (struct inpcb *)so->so_pcb; if (!inp) { @@ -565,18 +603,22 @@ return 0; } -int OskitTCPGetAddress( void *socket, +int OskitTCPGetAddress( PCONNECTION_ENDPOINT connection, OSK_UINT *LocalAddress, OSK_UI16 *LocalPort, OSK_UINT *RemoteAddress, OSK_UI16 *RemotePort ) { - struct socket *so = socket; + struct socket *so; struct inpcb *inp; - if (!socket) + OSKLock(); + so = connection->SocketContext; + if (!so) + { + OSKUnlock(); return OSK_ESHUTDOWN; - - OSKLock(); + } + inp = (struct inpcb *)so->so_pcb; if (!inp) { @@ -593,15 +635,20 @@ return 0; } -int OskitTCPGetSocketError(void *socket) { - struct socket *so = socket; - int error; - - if (!socket) - return OSK_ESHUTDOWN; - - OSKLock(); - error = so->so_error; +int OskitTCPGetSocketError(PCONNECTION_ENDPOINT connection) { + struct socket *so; + int error; + + OSKLock(); + so = connection->SocketContext; + if (so) + { + error = so->so_error; + } + else + { + error = OSK_ESHUTDOWN; + } OSKUnlock(); return error; Modified: trunk/reactos/lib/drivers/oskittcp/oskittcp/sleep.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/oskittcp/oskit…
============================================================================== --- trunk/reactos/lib/drivers/oskittcp/oskittcp/sleep.c [iso-8859-1] (original) +++ trunk/reactos/lib/drivers/oskittcp/oskittcp/sleep.c [iso-8859-1] Sun Jul 17 17:37:36 2011 @@ -1,3 +1,4 @@ +#include <osenv.h> #include <oskittcp.h> #include <sys/callout.h> #include <oskitfreebsd.h>
13 years, 5 months
1
0
0
0
[ekohl] 52717: [SERVICES] Implement service image records. This will enable us to run executables that contain multiple services and control them individually.
by ekohl@svn.reactos.org
Author: ekohl Date: Sun Jul 17 15:45:03 2011 New Revision: 52717 URL:
http://svn.reactos.org/svn/reactos?rev=52717&view=rev
Log: [SERVICES] Implement service image records. This will enable us to run executables that contain multiple services and control them individually. Modified: trunk/reactos/base/system/services/database.c trunk/reactos/base/system/services/rpcserver.c trunk/reactos/base/system/services/services.h Modified: trunk/reactos/base/system/services/database.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/services/datab…
============================================================================== --- trunk/reactos/base/system/services/database.c [iso-8859-1] (original) +++ trunk/reactos/base/system/services/database.c [iso-8859-1] Sun Jul 17 15:45:03 2011 @@ -25,6 +25,7 @@ /* GLOBALS *******************************************************************/ +LIST_ENTRY ImageListHead; LIST_ENTRY ServiceListHead; static RTL_RESOURCE DatabaseLock; @@ -33,6 +34,227 @@ static CRITICAL_SECTION ControlServiceCriticalSection; /* FUNCTIONS *****************************************************************/ + +static DWORD +ScmCreateNewControlPipe(PSERVICE_IMAGE pServiceImage) +{ + WCHAR szControlPipeName[MAX_PATH + 1]; + HKEY hServiceCurrentKey = INVALID_HANDLE_VALUE; + DWORD ServiceCurrent = 0; + DWORD KeyDisposition; + DWORD dwKeySize; + DWORD dwError; + + /* Get the service number */ + /* TODO: Create registry entry with correct write access */ + dwError = RegCreateKeyExW(HKEY_LOCAL_MACHINE, + L"SYSTEM\\CurrentControlSet\\Control\\ServiceCurrent", 0, NULL, + REG_OPTION_VOLATILE, + KEY_WRITE | KEY_READ, + NULL, + &hServiceCurrentKey, + &KeyDisposition); + if (dwError != ERROR_SUCCESS) + { + DPRINT1("RegCreateKeyEx() failed with error %lu\n", dwError); + return dwError; + } + + if (KeyDisposition == REG_OPENED_EXISTING_KEY) + { + dwKeySize = sizeof(DWORD); + dwError = RegQueryValueExW(hServiceCurrentKey, + L"", 0, NULL, (BYTE*)&ServiceCurrent, &dwKeySize); + + if (dwError != ERROR_SUCCESS) + { + RegCloseKey(hServiceCurrentKey); + DPRINT1("RegQueryValueEx() failed with error %lu\n", dwError); + return dwError; + } + + ServiceCurrent++; + } + + dwError = RegSetValueExW(hServiceCurrentKey, L"", 0, REG_DWORD, (BYTE*)&ServiceCurrent, sizeof(ServiceCurrent)); + + RegCloseKey(hServiceCurrentKey); + + if (dwError != ERROR_SUCCESS) + { + DPRINT1("RegSetValueExW() failed (Error %lu)\n", dwError); + return dwError; + } + + /* Create '\\.\pipe\net\NtControlPipeXXX' instance */ + swprintf(szControlPipeName, L"\\\\.\\pipe\\net\\NtControlPipe%u", ServiceCurrent); + + DPRINT("PipeName: %S\n", szControlPipeName); + + pServiceImage->hControlPipe = CreateNamedPipeW(szControlPipeName, + PIPE_ACCESS_DUPLEX, + PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT, + 100, + 8000, + 4, + 30000, + NULL); + DPRINT("CreateNamedPipeW(%S) done\n", szControlPipeName); + if (pServiceImage->hControlPipe == INVALID_HANDLE_VALUE) + { + DPRINT1("Failed to create control pipe!\n"); + return GetLastError(); + } + + return ERROR_SUCCESS; +} + + +static PSERVICE_IMAGE +ScmGetServiceImageByImagePath(LPWSTR lpImagePath) +{ + PLIST_ENTRY ImageEntry; + PSERVICE_IMAGE CurrentImage; + + DPRINT("ScmGetServiceImageByImagePath() called\n"); + + ImageEntry = ImageListHead.Flink; + while (ImageEntry != &ImageListHead) + { + CurrentImage = CONTAINING_RECORD(ImageEntry, + SERVICE_IMAGE, + ImageListEntry); + if (_wcsicmp(CurrentImage->szImagePath, lpImagePath) == 0) + { + DPRINT("Found image: '%S'\n", CurrentImage->szImagePath); + return CurrentImage; + } + + ImageEntry = ImageEntry->Flink; + } + + DPRINT1("Couldn't find a matching image\n"); + + return NULL; + +} + + +static DWORD +ScmCreateOrReferenceServiceImage(PSERVICE pService) +{ + RTL_QUERY_REGISTRY_TABLE QueryTable[2]; + UNICODE_STRING ImagePath; + PSERVICE_IMAGE pServiceImage = NULL; + NTSTATUS Status; + DWORD dwError = ERROR_SUCCESS; + + DPRINT("ScmCreateOrReferenceServiceImage()"); + + RtlInitUnicodeString(&ImagePath, NULL); + + /* Get service data */ + RtlZeroMemory(&QueryTable, + sizeof(QueryTable)); + + QueryTable[0].Name = L"ImagePath"; + QueryTable[0].Flags = RTL_QUERY_REGISTRY_DIRECT | RTL_QUERY_REGISTRY_REQUIRED; + QueryTable[0].EntryContext = &ImagePath; + + Status = RtlQueryRegistryValues(RTL_REGISTRY_SERVICES, + pService->lpServiceName, + QueryTable, + NULL, + NULL); + if (!NT_SUCCESS(Status)) + { + DPRINT1("RtlQueryRegistryValues() failed (Status %lx)\n", Status); + return RtlNtStatusToDosError(Status); + } + + DPRINT("ImagePath: '%wZ'\n", &ImagePath); + + pServiceImage = ScmGetServiceImageByImagePath(ImagePath.Buffer); + if (pServiceImage == NULL) + { + /* Create a new service image */ + pServiceImage = (PSERVICE_IMAGE)HeapAlloc(GetProcessHeap(), + HEAP_ZERO_MEMORY, + sizeof(SERVICE_IMAGE) + ((wcslen(ImagePath.Buffer) + 1) * sizeof(WCHAR))); + if (pServiceImage == NULL) + { + dwError = ERROR_NOT_ENOUGH_MEMORY; + goto done; + } + + pServiceImage->dwImageRunCount = 1; + pServiceImage->hControlPipe = INVALID_HANDLE_VALUE; + pServiceImage->hProcess = INVALID_HANDLE_VALUE; + + /* Set the image path */ + wcscpy(pServiceImage->szImagePath, + ImagePath.Buffer); + + RtlFreeUnicodeString(&ImagePath); + + /* Create the control pipe */ + dwError = ScmCreateNewControlPipe(pServiceImage); + if (dwError != ERROR_SUCCESS) + { + HeapFree(GetProcessHeap(), 0, pServiceImage); + goto done; + } + + /* FIXME: Add more initialization code here */ + + + /* Append service record */ + InsertTailList(&ImageListHead, + &pServiceImage->ImageListEntry); + + pService->lpImage = pServiceImage; + } + else + { + /* Create a new service image */ + pService->lpImage->dwImageRunCount++; + } + +done:; + RtlFreeUnicodeString(&ImagePath); + + return dwError; +} + + +static VOID +ScmDereferenceServiceImage(PSERVICE_IMAGE pServiceImage) +{ + DPRINT1("ScmDereferenceServiceImage() called\n"); + + pServiceImage->dwImageRunCount--; + + if (pServiceImage->dwImageRunCount == 0) + { + DPRINT1("dwImageRunCount == 0\n"); + + /* FIXME: Terminate the process */ + + /* Remove the service image from the list */ + RemoveEntryList(&pServiceImage->ImageListEntry); + + /* Close the control pipe */ + if (pServiceImage->hControlPipe != INVALID_HANDLE_VALUE) + CloseHandle(pServiceImage->hControlPipe); + + /* Close the process handle */ + if (pServiceImage->hProcess != INVALID_HANDLE_VALUE) + CloseHandle(pServiceImage->hProcess); + + /* Release the service image */ + HeapFree(GetProcessHeap(), 0, pServiceImage); + } +} PSERVICE @@ -131,7 +353,7 @@ DPRINT("Service: '%S'\n", lpServiceName); /* Allocate service entry */ - lpService = (SERVICE*) HeapAlloc(GetProcessHeap(), + lpService = (SERVICE*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(SERVICE) + ((wcslen(lpServiceName) + 1) * sizeof(WCHAR))); if (lpService == NULL) @@ -173,9 +395,9 @@ lpService->lpDisplayName != lpService->lpServiceName) HeapFree(GetProcessHeap(), 0, lpService->lpDisplayName); - /* Decrement the image reference counter */ + /* Dereference the service image */ if (lpService->lpImage) - lpService->lpImage->dwServiceRefCount--; + ScmDereferenceServiceImage(lpService->lpImage); /* Decrement the group reference counter */ if (lpService->lpGroup) @@ -183,9 +405,6 @@ /* FIXME: SecurityDescriptor */ - /* Close the control pipe */ - if (lpService->ControlPipeHandle != INVALID_HANDLE_VALUE) - CloseHandle(lpService->ControlPipeHandle); /* Remove the Service from the List */ RemoveEntryList(&lpService->ServiceListEntry); @@ -329,6 +548,12 @@ if (lpDisplayName != NULL) HeapFree(GetProcessHeap(), 0, lpDisplayName); + + if (lpService != NULL) + { + if (lpService->lpImage != NULL) + ScmDereferenceServiceImage(lpService->lpImage); + } return dwError; } @@ -479,6 +704,7 @@ return dwError; /* Initialize basic variables */ + InitializeListHead(&ImageListHead); InitializeListHead(&ServiceListHead); /* Initialize the database lock */ @@ -711,14 +937,14 @@ wcscpy(&ControlPacket->szArguments[0], Service->lpServiceName); /* Send the control packet */ - WriteFile(Service->ControlPipeHandle, + WriteFile(Service->lpImage->hControlPipe, ControlPacket, sizeof(SCM_CONTROL_PACKET) + (TotalLength * sizeof(WCHAR)), &dwWriteCount, NULL); /* Read the reply */ - ReadFile(Service->ControlPipeHandle, + ReadFile(Service->lpImage->hControlPipe, &ReplyPacket, sizeof(SCM_REPLY_PACKET), &dwReadCount, @@ -732,6 +958,12 @@ if (dwReadCount == sizeof(SCM_REPLY_PACKET)) { dwError = ReplyPacket.dwError; + } + + if (dwError == ERROR_SUCCESS && + dwControl == SERVICE_CONTROL_STOP) + { + ScmDereferenceServiceImage(Service->lpImage); } LeaveCriticalSection(&ControlServiceCriticalSection); @@ -804,14 +1036,14 @@ *Ptr = 0; /* Send the start command */ - WriteFile(Service->ControlPipeHandle, + WriteFile(Service->lpImage->hControlPipe, ControlPacket, sizeof(SCM_CONTROL_PACKET) + (TotalLength - 1) * sizeof(WCHAR), &dwWriteCount, NULL); /* Read the reply */ - ReadFile(Service->ControlPipeHandle, + ReadFile(Service->lpImage->hControlPipe, &ReplyPacket, sizeof(SCM_REPLY_PACKET), &dwReadCount, @@ -838,107 +1070,11 @@ DWORD argc, LPWSTR *argv) { - RTL_QUERY_REGISTRY_TABLE QueryTable[3]; PROCESS_INFORMATION ProcessInformation; STARTUPINFOW StartupInfo; - UNICODE_STRING ImagePath; - ULONG Type; - DWORD ServiceCurrent = 0; BOOL Result; - NTSTATUS Status; DWORD dwError = ERROR_SUCCESS; - WCHAR NtControlPipeName[MAX_PATH + 1]; - HKEY hServiceCurrentKey = INVALID_HANDLE_VALUE; - DWORD KeyDisposition; DWORD dwProcessId; - - RtlInitUnicodeString(&ImagePath, NULL); - - /* Get service data */ - RtlZeroMemory(&QueryTable, - sizeof(QueryTable)); - - QueryTable[0].Name = L"Type"; - QueryTable[0].Flags = RTL_QUERY_REGISTRY_DIRECT | RTL_QUERY_REGISTRY_REQUIRED; - QueryTable[0].EntryContext = &Type; - - QueryTable[1].Name = L"ImagePath"; - QueryTable[1].Flags = RTL_QUERY_REGISTRY_DIRECT | RTL_QUERY_REGISTRY_REQUIRED; - QueryTable[1].EntryContext = &ImagePath; - - Status = RtlQueryRegistryValues(RTL_REGISTRY_SERVICES, - Service->lpServiceName, - QueryTable, - NULL, - NULL); - if (!NT_SUCCESS(Status)) - { - DPRINT1("RtlQueryRegistryValues() failed (Status %lx)\n", Status); - return RtlNtStatusToDosError(Status); - } - DPRINT("ImagePath: '%S'\n", ImagePath.Buffer); - DPRINT("Type: %lx\n", Type); - - /* Get the service number */ - /* TODO: Create registry entry with correct write access */ - Status = RegCreateKeyExW(HKEY_LOCAL_MACHINE, - L"SYSTEM\\CurrentControlSet\\Control\\ServiceCurrent", 0, NULL, - REG_OPTION_VOLATILE, - KEY_WRITE | KEY_READ, - NULL, - &hServiceCurrentKey, - &KeyDisposition); - - if (ERROR_SUCCESS != Status) - { - DPRINT1("RegCreateKeyEx() failed with status %u\n", Status); - return Status; - } - - if (REG_OPENED_EXISTING_KEY == KeyDisposition) - { - DWORD KeySize = sizeof(ServiceCurrent); - Status = RegQueryValueExW(hServiceCurrentKey, L"", 0, NULL, (BYTE*)&ServiceCurrent, &KeySize); - - if (ERROR_SUCCESS != Status) - { - RegCloseKey(hServiceCurrentKey); - DPRINT1("RegQueryValueEx() failed with status %u\n", Status); - return Status; - } - - ServiceCurrent++; - } - - Status = RegSetValueExW(hServiceCurrentKey, L"", 0, REG_DWORD, (BYTE*)&ServiceCurrent, sizeof(ServiceCurrent)); - - RegCloseKey(hServiceCurrentKey); - - if (ERROR_SUCCESS != Status) - { - DPRINT1("RegSetValueExW() failed (Status %lx)\n", Status); - return Status; - } - - /* Create '\\.\pipe\net\NtControlPipeXXX' instance */ - swprintf(NtControlPipeName, L"\\\\.\\pipe\\net\\NtControlPipe%u", ServiceCurrent); - - DPRINT("Service: %p ImagePath: %wZ PipeName: %S\n", Service, &ImagePath, NtControlPipeName); - - Service->ControlPipeHandle = CreateNamedPipeW(NtControlPipeName, - PIPE_ACCESS_DUPLEX, - PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT, - 100, - 8000, - 4, - 30000, - NULL); - DPRINT("CreateNamedPipeW(%S) done\n", NtControlPipeName); - if (Service->ControlPipeHandle == INVALID_HANDLE_VALUE) - { - DPRINT1("Failed to create control pipe!\n"); - return GetLastError(); - } StartupInfo.cb = sizeof(StartupInfo); StartupInfo.lpReserved = NULL; @@ -949,7 +1085,7 @@ StartupInfo.lpReserved2 = 0; Result = CreateProcessW(NULL, - ImagePath.Buffer, + Service->lpImage->szImagePath, NULL, NULL, FALSE, @@ -958,15 +1094,9 @@ NULL, &StartupInfo, &ProcessInformation); - RtlFreeUnicodeString(&ImagePath); - if (!Result) { dwError = GetLastError(); - /* Close control pipe */ - CloseHandle(Service->ControlPipeHandle); - Service->ControlPipeHandle = INVALID_HANDLE_VALUE; - DPRINT1("Starting '%S' failed!\n", Service->lpServiceName); return dwError; } @@ -978,15 +1108,15 @@ ProcessInformation.dwThreadId, ProcessInformation.hThread); - /* Get process and thread ids */ - Service->ProcessId = ProcessInformation.dwProcessId; - Service->ThreadId = ProcessInformation.dwThreadId; + /* Get process handle and id */ + Service->lpImage->dwProcessId = ProcessInformation.dwProcessId; + Service->lpImage->hProcess = ProcessInformation.hProcess; /* Resume Thread */ ResumeThread(ProcessInformation.hThread); /* Connect control pipe */ - if (ConnectNamedPipe(Service->ControlPipeHandle, NULL) ? + if (ConnectNamedPipe(Service->lpImage->hControlPipe, NULL) ? TRUE : (dwError = GetLastError()) == ERROR_PIPE_CONNECTED) { DWORD dwRead = 0; @@ -994,7 +1124,7 @@ DPRINT("Control pipe connected!\n"); /* Read SERVICE_STATUS_HANDLE from pipe */ - if (!ReadFile(Service->ControlPipeHandle, + if (!ReadFile(Service->lpImage->hControlPipe, (LPVOID)&dwProcessId, sizeof(DWORD), &dwRead, @@ -1015,17 +1145,10 @@ else { DPRINT1("Connecting control pipe failed! (Error %lu)\n", dwError); - - /* Close control pipe */ - CloseHandle(Service->ControlPipeHandle); - Service->ControlPipeHandle = INVALID_HANDLE_VALUE; - Service->ProcessId = 0; - Service->ThreadId = 0; - } - - /* Close process and thread handle */ + } + + /* Close thread handle */ CloseHandle(ProcessInformation.hThread); - CloseHandle(ProcessInformation.hProcess); return dwError; } @@ -1051,7 +1174,6 @@ return ERROR_SERVICE_ALREADY_RUNNING; } - Service->ControlPipeHandle = INVALID_HANDLE_VALUE; DPRINT("Service->Type: %lu\n", Service->Status.dwServiceType); if (Service->Status.dwServiceType & SERVICE_DRIVER) @@ -1067,14 +1189,23 @@ else { /* Start user-mode service */ - dwError = ScmStartUserModeService(Service, argc, argv); + dwError = ScmCreateOrReferenceServiceImage(Service); if (dwError == ERROR_SUCCESS) { + dwError = ScmStartUserModeService(Service, argc, argv); + if (dwError == ERROR_SUCCESS) + { #ifdef USE_SERVICE_START_PENDING - Service->Status.dwCurrentState = SERVICE_START_PENDING; + Service->Status.dwCurrentState = SERVICE_START_PENDING; #else - Service->Status.dwCurrentState = SERVICE_RUNNING; + Service->Status.dwCurrentState = SERVICE_RUNNING; #endif + } + else + { + ScmDereferenceServiceImage(Service->lpImage); + Service->lpImage = NULL; + } } } Modified: trunk/reactos/base/system/services/rpcserver.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/services/rpcse…
============================================================================== --- trunk/reactos/base/system/services/rpcserver.c [iso-8859-1] (original) +++ trunk/reactos/base/system/services/rpcserver.c [iso-8859-1] Sun Jul 17 15:45:03 2011 @@ -722,15 +722,6 @@ if ((dwError == ERROR_SUCCESS) && (pcbBytesNeeded)) dwError = ERROR_DEPENDENT_SERVICES_RUNNING; - - if (dwError == ERROR_SUCCESS && - dwControl == SERVICE_CONTROL_STOP && - lpServiceStatus->dwCurrentState == SERVICE_STOPPED) - { - lpService->ProcessId = 0; /* FIXME */ - lpService->ThreadId = 0; - } - return dwError; } @@ -4897,7 +4888,7 @@ &lpService->Status, sizeof(SERVICE_STATUS)); - lpStatus->dwProcessId = lpService->ProcessId; /* FIXME */ + lpStatus->dwProcessId = (lpService->lpImage != NULL) ? lpService->lpImage->dwProcessId : 0; /* FIXME */ lpStatus->dwServiceFlags = 0; /* FIXME */ /* Unlock the service database */ @@ -5282,7 +5273,8 @@ memcpy(&lpStatusPtr->ServiceStatusProcess, &CurrentService->Status, sizeof(SERVICE_STATUS)); - lpStatusPtr->ServiceStatusProcess.dwProcessId = CurrentService->ProcessId; /* FIXME */ + lpStatusPtr->ServiceStatusProcess.dwProcessId = + (CurrentService->lpImage != NULL) ? CurrentService->lpImage->dwProcessId : 0; /* FIXME */ lpStatusPtr->ServiceStatusProcess.dwServiceFlags = 0; /* FIXME */ lpStatusPtr++; Modified: trunk/reactos/base/system/services/services.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/services/servi…
============================================================================== --- trunk/reactos/base/system/services/services.h [iso-8859-1] (original) +++ trunk/reactos/base/system/services/services.h [iso-8859-1] Sun Jul 17 15:45:03 2011 @@ -27,8 +27,14 @@ typedef struct _SERVICE_IMAGE { - DWORD dwServiceRefCount; // Number of running services of this image - DWORD Dummy; + LIST_ENTRY ImageListEntry; + DWORD dwImageRunCount; + + HANDLE hControlPipe; + HANDLE hProcess; + DWORD dwProcessId; + + WCHAR szImagePath[1]; } SERVICE_IMAGE, *PSERVICE_IMAGE; @@ -54,10 +60,6 @@ BOOLEAN ServiceVisited; - HANDLE ControlPipeHandle; - ULONG ProcessId; - ULONG ThreadId; - WCHAR szServiceName[1]; } SERVICE, *PSERVICE; @@ -66,6 +68,7 @@ extern LIST_ENTRY ServiceListHead; extern LIST_ENTRY GroupListHead; +extern LIST_ENTRY ImageListHead; extern BOOL ScmShutdown;
13 years, 5 months
1
0
0
0
[gadamopoulos] 52716: [win32k] - Fix TrackMouseEvent. Now hot tracking really works
by gadamopoulos@svn.reactos.org
Author: gadamopoulos Date: Sun Jul 17 15:30:12 2011 New Revision: 52716 URL:
http://svn.reactos.org/svn/reactos?rev=52716&view=rev
Log: [win32k] - Fix TrackMouseEvent. Now hot tracking really works Modified: branches/GSoC_2011/ThemesSupport/subsystems/win32/win32k/ntuser/input.c branches/GSoC_2011/ThemesSupport/subsystems/win32/win32k/ntuser/msgqueue.c branches/GSoC_2011/ThemesSupport/subsystems/win32/win32k/ntuser/timer.c Modified: branches/GSoC_2011/ThemesSupport/subsystems/win32/win32k/ntuser/input.c URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/ThemesSupport/subsyst…
============================================================================== --- branches/GSoC_2011/ThemesSupport/subsystems/win32/win32k/ntuser/input.c [iso-8859-1] (original) +++ branches/GSoC_2011/ThemesSupport/subsystems/win32/win32k/ntuser/input.c [iso-8859-1] Sun Jul 17 15:30:12 2011 @@ -1612,19 +1612,6 @@ if (!(pWnd = UserGetWindowObject(lpEventTrack->hwndTrack))) return FALSE; - if ( pDesk->spwndTrack != pWnd || - (pDesk->htEx != HTCLIENT) ^ !!(lpEventTrack->dwFlags & TME_NONCLIENT) ) - { - if ( lpEventTrack->dwFlags & TME_LEAVE && !(lpEventTrack->dwFlags & TME_CANCEL) ) - { - UserPostMessage( lpEventTrack->hwndTrack, - lpEventTrack->dwFlags & TME_NONCLIENT ? WM_NCMOUSELEAVE : WM_MOUSELEAVE, - 0, 0); - } - DPRINT("IntTrackMouseEvent spwndTrack 0x%x pwnd 0x%x\n", pDesk->spwndTrack,pWnd); - return TRUE; - } - /* Tracking spwndTrack same as pWnd */ if ( lpEventTrack->dwFlags & TME_CANCEL ) // Canceled mode. { @@ -1642,6 +1629,7 @@ } else // Not Canceled. { + pDesk->spwndTrack = pWnd; if ( lpEventTrack->dwFlags & TME_LEAVE ) pDesk->dwDTFlags |= DF_TME_LEAVE; @@ -1657,6 +1645,7 @@ IntSetTimer( pWnd, ID_EVENT_SYSTIMER_MOUSEHOVER, pDesk->dwMouseHoverTime, SystemTimerProc, TMRF_SYSTEM); // Get windows thread message points. point = pWnd->head.pti->ptLast; + DPRINT1("point: %d, %d\n", point.x, point.y); // Set desktop mouse hover from the system default hover rectangle. RECTL_vSetRect(&pDesk->rcMouseHover, point.x - gspv.iMouseHoverWidth / 2, Modified: branches/GSoC_2011/ThemesSupport/subsystems/win32/win32k/ntuser/msgqueue.c URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/ThemesSupport/subsyst…
============================================================================== --- branches/GSoC_2011/ThemesSupport/subsystems/win32/win32k/ntuser/msgqueue.c [iso-8859-1] (original) +++ branches/GSoC_2011/ThemesSupport/subsystems/win32/win32k/ntuser/msgqueue.c [iso-8859-1] Sun Jul 17 15:30:12 2011 @@ -540,22 +540,35 @@ if (pwnd) { - PWND pwndTrack = IntChildrenWindowFromPoint(pwnd, Msg->pt.x, Msg->pt.y); - - if ( pDesk->spwndTrack != pwndTrack && pDesk->dwDTFlags & (DF_TME_LEAVE|DF_TME_HOVER) ) - { - if ( pDesk->dwDTFlags & DF_TME_LEAVE ) - UserPostMessage( UserHMGetHandle(pDesk->spwndTrack), - (pDesk->htEx != HTCLIENT) ? WM_NCMOUSELEAVE : WM_MOUSELEAVE, - 0, 0); - - if ( pDesk->dwDTFlags & DF_TME_HOVER ) - IntKillTimer(UserHMGetHandle(pDesk->spwndTrack), ID_EVENT_SYSTIMER_MOUSEHOVER, TRUE); - - pDesk->dwDTFlags &= ~(DF_TME_LEAVE|DF_TME_HOVER); - } - pDesk->spwndTrack = pwndTrack; - pDesk->htEx = GetNCHitEx(pDesk->spwndTrack, Msg->pt); + /* If we a re tracking the mouse and it moves to another top level window */ + if(pDesk->spwndTrack && + UserGetAncestor(pDesk->spwndTrack, GA_ROOT) != pwnd) + { + /* Generate a WM_MOUSELEAVE message */ + if ( pDesk->dwDTFlags & DF_TME_LEAVE ) + { + MSG msgMouseLeave; + + DPRINT1("co_MsqInsertMouseMessage: generating WM_MOUSELEAVE\n"); + + msgMouseLeave.hwnd = UserHMGetHandle(pDesk->spwndTrack); + msgMouseLeave.message = WM_MOUSELEAVE; + msgMouseLeave.pt = Msg->pt; + msgMouseLeave.time = Msg->time; + msgMouseLeave.lParam = msgMouseLeave.wParam = 0; + + MsqPostMessage(pwnd->head.pti->MessageQueue, Msg, TRUE, QS_MOUSE); + } + + /* Stop tracking */ + if ( pDesk->dwDTFlags & DF_TME_HOVER ) + { + IntKillTimer(pDesk->spwndTrack, ID_EVENT_SYSTIMER_MOUSEHOVER, TRUE); + } + + pDesk->spwndTrack = NULL; + pDesk->htEx = 0; + } } hdcScreen = IntGetScreenDC(); @@ -1287,6 +1300,7 @@ PUSER_MESSAGE_QUEUE MessageQueue; PTHREADINFO pti; PSYSTEM_CURSORINFO CurInfo; + PDESKTOP pDesk; DECLARE_RETURN(BOOL); pti = PsGetCurrentThreadWin32Thread(); @@ -1295,6 +1309,7 @@ CurInfo = IntGetSysCursorInfo(); pwndMsg = UserGetWindowObject(msg->hwnd); clk_msg = MessageQueue->msgDblClk; + pDesk = pwndDesktop->head.rpdesk; /* find the window to dispatch this mouse message to */ if (MessageQueue->CaptureWindow) @@ -1314,6 +1329,45 @@ /* Remove and ignore the message */ *RemoveMessages = TRUE; RETURN(FALSE); + } + + /* If we a re tracking the mouse and it moves to another window */ + if(pDesk->spwndTrack && + pDesk->spwndTrack != pwndMsg && + msg->message != WM_MOUSELEAVE) + { + /* Generate a WM_MOUSELEAVE message */ + if ( pDesk->dwDTFlags & DF_TME_LEAVE ) + { + MSG msgMouseLeave; + + DPRINT1("co_IntProcessMouseMessage: generating WM_MOUSELEAVE\n"); + + msgMouseLeave.hwnd = UserHMGetHandle(pDesk->spwndTrack); + msgMouseLeave.message = WM_MOUSELEAVE; + msgMouseLeave.pt = msg->pt; + msgMouseLeave.time = msg->time; + msgMouseLeave.lParam = msgMouseLeave.wParam = 0; + + MsqPostMessage(pwndMsg->head.pti->MessageQueue, + &msgMouseLeave, + TRUE, + QS_MOUSE); + } + + /* Stop tracking */ + if ( pDesk->dwDTFlags & DF_TME_HOVER ) + { + IntKillTimer(pDesk->spwndTrack, ID_EVENT_SYSTIMER_MOUSEHOVER, TRUE); + } + + pDesk->spwndTrack = NULL; + pDesk->htEx = 0; + } + + if(pDesk->spwndTrack) + { + pDesk->htEx = hittest; } msg->hwnd = UserHMGetHandle(pwndMsg); Modified: branches/GSoC_2011/ThemesSupport/subsystems/win32/win32k/ntuser/timer.c URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/ThemesSupport/subsyst…
============================================================================== --- branches/GSoC_2011/ThemesSupport/subsystems/win32/win32k/ntuser/timer.c [iso-8859-1] (original) +++ branches/GSoC_2011/ThemesSupport/subsystems/win32/win32k/ntuser/timer.c [iso-8859-1] Sun Jul 17 15:30:12 2011 @@ -320,12 +320,13 @@ POINT Point; UINT Msg; WPARAM wParam; - + pDesk = pWnd->head.rpdesk; if ( pDesk->dwDTFlags & DF_TME_HOVER && pWnd == pDesk->spwndTrack ) { - Point = gpsi->ptCursor; + Point = pWnd->head.pti->MessageQueue->MouseMoveMsg.pt; + DPRINT1("point: %d, %d\n", Point.x, Point.y); if ( IntPtInRect(&pDesk->rcMouseHover, Point) ) { if (pDesk->htEx == HTCLIENT) // In a client area. @@ -346,9 +347,18 @@ wParam = pDesk->htEx; // Need to support all HTXYZ hits. Msg = WM_NCMOUSEHOVER; } + DPRINT1("Generating WM_NCMOUSEHOVER\n"); UserPostMessage(hwnd, Msg, wParam, MAKELPARAM(Point.x, Point.y)); pDesk->dwDTFlags &= ~DF_TME_HOVER; break; // Kill this timer. + } + else + { + RECTL_vSetRect(&pDesk->rcMouseHover, + Point.x - gspv.iMouseHoverWidth / 2, + Point.y - gspv.iMouseHoverHeight / 2, + Point.x + gspv.iMouseHoverWidth / 2, + Point.y + gspv.iMouseHoverHeight / 2); } } }
13 years, 5 months
1
0
0
0
[gadamopoulos] 52715: [user32] - Partly sync button handling with wine. Needed for hot tracking
by gadamopoulos@svn.reactos.org
Author: gadamopoulos Date: Sun Jul 17 15:18:11 2011 New Revision: 52715 URL:
http://svn.reactos.org/svn/reactos?rev=52715&view=rev
Log: [user32] - Partly sync button handling with wine. Needed for hot tracking Modified: branches/GSoC_2011/ThemesSupport/dll/win32/user32/controls/button.c Modified: branches/GSoC_2011/ThemesSupport/dll/win32/user32/controls/button.c URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/ThemesSupport/dll/win…
============================================================================== --- branches/GSoC_2011/ThemesSupport/dll/win32/user32/controls/button.c [iso-8859-1] (original) +++ branches/GSoC_2011/ThemesSupport/dll/win32/user32/controls/button.c [iso-8859-1] Sun Jul 17 15:18:11 2011 @@ -31,7 +31,6 @@ * Styles * - BS_NOTIFY: is it complete? * - BS_RIGHTBUTTON: same as BS_LEFTTEXT - * - BS_TYPEMASK * * Messages * - WM_CHAR: Checks a (manual or automatic) check box on '+' or '=', clears it on '-' key. @@ -72,17 +71,10 @@ #define STATE_GWL_OFFSET 0 #define HFONT_GWL_OFFSET (sizeof(LONG)) #define HIMAGE_GWL_OFFSET (HFONT_GWL_OFFSET+sizeof(HFONT)) -#define UISTATE_GWL_OFFSET (HIMAGE_GWL_OFFSET+sizeof(HFONT)) -#define NB_EXTRA_BYTES (UISTATE_GWL_OFFSET+sizeof(LONG)) - - /* Button state values */ -#define BUTTON_UNCHECKED 0x00 -#define BUTTON_CHECKED 0x01 -#define BUTTON_3STATE 0x02 -#define BUTTON_HIGHLIGHTED 0x04 -#define BUTTON_HASFOCUS 0x08 +#define NB_EXTRA_BYTES (HIMAGE_GWL_OFFSET+sizeof(HANDLE)) + +/* undocumented flags */ #define BUTTON_NSTATES 0x0F - /* undocumented flags */ #define BUTTON_BTNPRESSED 0x40 #define BUTTON_UNKNOWN2 0x20 #define BUTTON_UNKNOWN3 0x10 @@ -103,22 +95,22 @@ static void OB_Paint( HWND hwnd, HDC hDC, UINT action ); static void BUTTON_CheckAutoRadioButton( HWND hwnd ); -#define MAX_BTN_TYPE 12 +#define MAX_BTN_TYPE 16 static const WORD maxCheckState[MAX_BTN_TYPE] = { - BUTTON_UNCHECKED, /* BS_PUSHBUTTON */ - BUTTON_UNCHECKED, /* BS_DEFPUSHBUTTON */ - BUTTON_CHECKED, /* BS_CHECKBOX */ - BUTTON_CHECKED, /* BS_AUTOCHECKBOX */ - BUTTON_CHECKED, /* BS_RADIOBUTTON */ - BUTTON_3STATE, /* BS_3STATE */ - BUTTON_3STATE, /* BS_AUTO3STATE */ - BUTTON_UNCHECKED, /* BS_GROUPBOX */ - BUTTON_UNCHECKED, /* BS_USERBUTTON */ - BUTTON_CHECKED, /* BS_AUTORADIOBUTTON */ - BUTTON_UNCHECKED, /* Not defined */ - BUTTON_UNCHECKED /* BS_OWNERDRAW */ + BST_UNCHECKED, /* BS_PUSHBUTTON */ + BST_UNCHECKED, /* BS_DEFPUSHBUTTON */ + BST_CHECKED, /* BS_CHECKBOX */ + BST_CHECKED, /* BS_AUTOCHECKBOX */ + BST_CHECKED, /* BS_RADIOBUTTON */ + BST_INDETERMINATE, /* BS_3STATE */ + BST_INDETERMINATE, /* BS_AUTO3STATE */ + BST_UNCHECKED, /* BS_GROUPBOX */ + BST_UNCHECKED, /* BS_USERBUTTON */ + BST_CHECKED, /* BS_AUTORADIOBUTTON */ + BST_UNCHECKED, /* BS_PUSHBOX */ + BST_UNCHECKED /* BS_OWNERDRAW */ }; typedef void (*pfPaint)( HWND hwnd, HDC hdc, UINT action ); @@ -135,7 +127,7 @@ GB_Paint, /* BS_GROUPBOX */ UB_Paint, /* BS_USERBUTTON */ CB_Paint, /* BS_AUTORADIOBUTTON */ - NULL, /* Not defined */ + NULL, /* BS_PUSHBOX */ OB_Paint /* BS_OWNERDRAW */ }; @@ -169,17 +161,7 @@ SetWindowLongPtrW( hwnd, STATE_GWL_OFFSET, state ); } -static __inline void set_ui_state( HWND hwnd, LONG flags ) -{ - SetWindowLongPtrW( hwnd, UISTATE_GWL_OFFSET, flags ); -} - -static __inline LONG get_ui_state( HWND hwnd ) -{ - return GetWindowLongPtrW( hwnd, UISTATE_GWL_OFFSET ); -} - -__inline static HFONT get_button_font( HWND hwnd ) +static inline HFONT get_button_font( HWND hwnd ) { return (HFONT)GetWindowLongPtrW( hwnd, HFONT_GWL_OFFSET ); } @@ -191,7 +173,7 @@ static inline UINT get_button_type( LONG window_style ) { - return (window_style & 0x0f); + return (window_style & BS_TYPEMASK); } /* paint a button of any type */ @@ -221,27 +203,6 @@ GetClientRect( hwnd, &rc ); DPtoLP( hdc, (POINT *)&rc, 2 ); IntersectClipRect( hdc, rc.left, rc.top, rc.right, rc.bottom ); -} - -/* Retrieve the UI state for the control */ -static BOOL button_update_uistate(HWND hwnd, BOOL unicode) -{ - LONG flags, prevflags; - - if (unicode) - flags = DefWindowProcW(hwnd, WM_QUERYUISTATE, 0, 0); - else - flags = DefWindowProcA(hwnd, WM_QUERYUISTATE, 0, 0); - - prevflags = get_ui_state(hwnd); - - if (prevflags != flags) - { - set_ui_state(hwnd, flags); - return TRUE; - } - - return FALSE; } /*********************************************************************** @@ -256,6 +217,7 @@ UINT btn_type = get_button_type( style ); LONG state; HANDLE oldHbitmap; + #ifdef __REACTOS__ PWND pWnd; @@ -268,6 +230,8 @@ } } #endif + + if (!IsWindow( hWnd )) return 0; pt.x = (short)LOWORD(lParam); pt.y = (short)HIWORD(lParam); @@ -305,11 +269,10 @@ /* XP turns a BS_USERBUTTON into BS_PUSHBUTTON */ if (btn_type == BS_USERBUTTON ) { - style = (style & ~0x0f) | BS_PUSHBUTTON; + style = (style & ~BS_TYPEMASK) | BS_PUSHBUTTON; SetWindowLongPtrW( hWnd, GWL_STYLE, style ); } - set_button_state( hWnd, BUTTON_UNCHECKED ); - button_update_uistate( hWnd, unicode ); + set_button_state( hWnd, BST_UNCHECKED ); return 0; #ifdef __REACTOS__ @@ -384,7 +347,7 @@ if (!(state & BUTTON_BTNPRESSED)) break; state &= BUTTON_NSTATES; set_button_state( hWnd, state ); - if (!(state & BUTTON_HIGHLIGHTED)) + if (!(state & BST_PUSHED)) { ReleaseCapture(); break; @@ -398,14 +361,14 @@ switch(btn_type) { case BS_AUTOCHECKBOX: - SendMessageW( hWnd, BM_SETCHECK, !(state & BUTTON_CHECKED), 0 ); + SendMessageW( hWnd, BM_SETCHECK, !(state & BST_CHECKED), 0 ); break; case BS_AUTORADIOBUTTON: SendMessageW( hWnd, BM_SETCHECK, TRUE, 0 ); break; case BS_AUTO3STATE: SendMessageW( hWnd, BM_SETCHECK, - (state & BUTTON_3STATE) ? 0 : ((state & 3) + 1), 0 ); + (state & BST_INDETERMINATE) ? 0 : ((state & 3) + 1), 0 ); break; } BUTTON_NOTIFY_PARENT(hWnd, BN_CLICKED); @@ -419,7 +382,7 @@ { state &= BUTTON_NSTATES; set_button_state( hWnd, state ); - if (state & BUTTON_HIGHLIGHTED) SendMessageW( hWnd, BM_SETSTATE, FALSE, 0 ); + if (state & BST_PUSHED) SendMessageW( hWnd, BM_SETSTATE, FALSE, 0 ); } break; @@ -474,7 +437,7 @@ case WM_SETFOCUS: TRACE("WM_SETFOCUS %p\n",hWnd); - set_button_state( hWnd, get_button_state(hWnd) | BUTTON_HASFOCUS ); + set_button_state( hWnd, get_button_state(hWnd) | BST_FOCUS ); paint_button( hWnd, btn_type, ODA_FOCUS ); if (style & BS_NOTIFY) BUTTON_NOTIFY_PARENT(hWnd, BN_SETFOCUS); @@ -483,7 +446,7 @@ case WM_KILLFOCUS: TRACE("WM_KILLFOCUS %p\n",hWnd); state = get_button_state( hWnd ); - set_button_state( hWnd, state & ~BUTTON_HASFOCUS ); + set_button_state( hWnd, state & ~BST_FOCUS ); paint_button( hWnd, btn_type, ODA_FOCUS ); if ((state & BUTTON_BTNPRESSED) && GetCapture() == hWnd) @@ -499,9 +462,9 @@ break; case BM_SETSTYLE: - if ((wParam & 0x0f) >= MAX_BTN_TYPE) break; - btn_type = wParam & 0x0f; - style = (style & ~0x0f) | btn_type; + if ((wParam & BS_TYPEMASK) >= MAX_BTN_TYPE) break; + btn_type = wParam & BS_TYPEMASK; + style = (style & ~BS_TYPEMASK) | btn_type; SetWindowLongPtrW( hWnd, GWL_STYLE, style ); /* Only redraw if lParam flag is set.*/ @@ -552,7 +515,7 @@ set_button_state( hWnd, (state & ~3) | wParam ); paint_button( hWnd, btn_type, ODA_SELECT ); } - if ((btn_type == BS_AUTORADIOBUTTON) && (wParam == BUTTON_CHECKED) && (style & WS_CHILD)) + if ((btn_type == BS_AUTORADIOBUTTON) && (wParam == BST_CHECKED) && (style & WS_CHILD)) BUTTON_CheckAutoRadioButton( hWnd ); break; @@ -562,26 +525,11 @@ case BM_SETSTATE: state = get_button_state( hWnd ); if (wParam) - { - if (state & BUTTON_HIGHLIGHTED) break; - set_button_state( hWnd, state | BUTTON_HIGHLIGHTED ); - } + set_button_state( hWnd, state | BST_PUSHED ); else - { - if (!(state & BUTTON_HIGHLIGHTED)) break; - set_button_state( hWnd, state & ~BUTTON_HIGHLIGHTED ); - } + set_button_state( hWnd, state & ~BST_PUSHED ); + paint_button( hWnd, btn_type, ODA_SELECT ); - break; - - case WM_UPDATEUISTATE: - if (unicode) - DefWindowProcW(hWnd, uMsg, wParam, lParam); - else - DefWindowProcA(hWnd, uMsg, wParam, lParam); - - if (button_update_uistate(hWnd, unicode)) - paint_button( hWnd, btn_type, ODA_DRAWENTIRE ); break; case WM_NCHITTEST: @@ -626,7 +574,7 @@ /* "Convert" pushlike buttons to pushbuttons */ if (style & BS_PUSHLIKE) - style &= ~0x0F; + style &= ~BS_TYPEMASK; if (!(style & BS_MULTILINE)) dtStyle |= DT_SINGLELINE; @@ -699,9 +647,6 @@ } DrawTextW(hdc, text, -1, &r, dtStyle | DT_CALCRECT); HeapFree( GetProcessHeap(), 0, text ); - - if (get_ui_state( hwnd ) & UISF_HIDEACCEL) - dtStyle |= DT_HIDEPREFIX; break; case BS_ICON: @@ -805,7 +750,7 @@ * I don't have Win31 on hand to verify that, so I leave it as is. */ - if ((style & BS_PUSHLIKE) && (state & BUTTON_3STATE)) + if ((style & BS_PUSHLIKE) && (state & BST_INDETERMINATE)) { hbr = GetSysColorBrush(COLOR_GRAYTEXT); flags |= DSS_MONO; @@ -818,10 +763,7 @@ lpOutputProc = BUTTON_DrawTextCallback; if (!(text = get_button_text( hwnd ))) return; lp = (LPARAM)text; - wp = (WPARAM)dtFlags; - - if (dtFlags & DT_HIDEPREFIX) - flags |= DSS_HIDEPREFIX; + wp = dtFlags; break; case BS_ICON: @@ -857,7 +799,7 @@ HFONT hFont; LONG state = get_button_state( hwnd ); LONG style = GetWindowLongPtrW( hwnd, GWL_STYLE ); - BOOL pushedState = (state & BUTTON_HIGHLIGHTED); + BOOL pushedState = (state & BST_PUSHED); HWND parent; GetClientRect( hwnd, &rc ); @@ -900,7 +842,7 @@ uState |= DFCS_PUSHED; } - if (state & (BUTTON_CHECKED | BUTTON_3STATE)) + if (state & (BST_CHECKED | BST_INDETERMINATE)) uState |= DFCS_CHECKED; DrawFrameControl( hDC, &rc, DFC_BUTTON, uState ); @@ -922,14 +864,10 @@ SetTextColor( hDC, oldTxtColor ); draw_focus: - if ((action == ODA_FOCUS) || - ((action == ODA_DRAWENTIRE) && (state & BUTTON_HASFOCUS))) - { - if (!(get_ui_state(hwnd) & UISF_HIDEFOCUS)) - { - InflateRect( &rc, -2, -2 ); - DrawFocusRect( hDC, &rc ); - } + if (action == ODA_FOCUS || (state & BST_FOCUS)) + { + InflateRect( &rc, -2, -2 ); + DrawFocusRect( hDC, &rc ); } cleanup: @@ -1008,11 +946,11 @@ if ((get_button_type(style) == BS_RADIOBUTTON) || (get_button_type(style) == BS_AUTORADIOBUTTON)) flags = DFCS_BUTTONRADIO; - else if (state & BUTTON_3STATE) flags = DFCS_BUTTON3STATE; + else if (state & BST_INDETERMINATE) flags = DFCS_BUTTON3STATE; else flags = DFCS_BUTTONCHECK; - if (state & (BUTTON_CHECKED | BUTTON_3STATE)) flags |= DFCS_CHECKED; - if (state & BUTTON_HIGHLIGHTED) flags |= DFCS_PUSHED; + if (state & (BST_CHECKED | BST_INDETERMINATE)) flags |= DFCS_CHECKED; + if (state & BST_PUSHED) flags |= DFCS_PUSHED; if (style & WS_DISABLED) flags |= DFCS_INACTIVE; @@ -1055,16 +993,12 @@ BUTTON_DrawLabel(hwnd, hDC, dtFlags, &rtext); /* ... and focus */ - if ((action == ODA_FOCUS) || - ((action == ODA_DRAWENTIRE) && (state & BUTTON_HASFOCUS))) - { - if (!(get_ui_state(hwnd) & UISF_HIDEFOCUS)) - { - rtext.left--; - rtext.right++; - IntersectRect(&rtext, &rtext, &client); - DrawFocusRect( hDC, &rtext ); - } + if (action == ODA_FOCUS || (state & BST_FOCUS)) + { + rtext.left--; + rtext.right++; + IntersectRect(&rtext, &rtext, &client); + DrawFocusRect( hDC, &rtext ); } } @@ -1085,8 +1019,8 @@ { if (!sibling) break; if ((hwnd != sibling) && - ((GetWindowLongPtrW( sibling, GWL_STYLE) & 0x0f) == BS_AUTORADIOBUTTON)) - SendMessageW( sibling, BM_SETCHECK, BUTTON_UNCHECKED, 0 ); + ((GetWindowLongPtrW( sibling, GWL_STYLE) & BS_TYPEMASK) == BS_AUTORADIOBUTTON)) + SendMessageW( sibling, BM_SETCHECK, BST_UNCHECKED, 0 ); sibling = GetNextDlgGroupItem( parent, sibling, FALSE ); } while (sibling != start); } @@ -1155,8 +1089,6 @@ LONG state = get_button_state( hwnd ); HWND parent; - if (action == ODA_SELECT) return; - GetClientRect( hwnd, &rc); if ((hFont = get_button_font( hwnd ))) SelectObject( hDC, hFont ); @@ -1169,14 +1101,23 @@ (WPARAM)hDC, (LPARAM)hwnd); FillRect( hDC, &rc, hBrush ); - if ((action == ODA_FOCUS) || - ((action == ODA_DRAWENTIRE) && (state & BUTTON_HASFOCUS))) - { - if (!(get_ui_state(hwnd) & UISF_HIDEFOCUS)) - DrawFocusRect( hDC, &rc ); - } - - BUTTON_NOTIFY_PARENT( hwnd, BN_PAINT ); + if (action == ODA_FOCUS || (state & BST_FOCUS)) + DrawFocusRect( hDC, &rc ); + + switch (action) + { + case ODA_FOCUS: + BUTTON_NOTIFY_PARENT( hwnd, (state & BST_FOCUS) ? BN_SETFOCUS : BN_KILLFOCUS ); + break; + + case ODA_SELECT: + BUTTON_NOTIFY_PARENT( hwnd, (state & BST_PUSHED) ? BN_HILITE : BN_UNHILITE ); + break; + + default: + BUTTON_NOTIFY_PARENT( hwnd, BN_PAINT ); + break; + } } @@ -1196,8 +1137,8 @@ dis.CtlID = id; dis.itemID = 0; dis.itemAction = action; - dis.itemState = ((state & BUTTON_HASFOCUS) ? ODS_FOCUS : 0) | - ((state & BUTTON_HIGHLIGHTED) ? ODS_SELECTED : 0) | + dis.itemState = ((state & BST_FOCUS) ? ODS_FOCUS : 0) | + ((state & BST_PUSHED) ? ODS_SELECTED : 0) | (IsWindowEnabled(hwnd) ? 0: ODS_DISABLED); dis.hwndItem = hwnd; dis.hDC = hDC;
13 years, 5 months
1
0
0
0
[gadamopoulos] 52714: [comctl32] - Sync comctl32 with wine. Among it's improvements are reduced flicker in the listview and hot tracking support for themed buttons
by gadamopoulos@svn.reactos.org
Author: gadamopoulos Date: Sun Jul 17 15:16:59 2011 New Revision: 52714 URL:
http://svn.reactos.org/svn/reactos?rev=52714&view=rev
Log: [comctl32] - Sync comctl32 with wine. Among it's improvements are reduced flicker in the listview and hot tracking support for themed buttons Modified: branches/GSoC_2011/ThemesSupport/dll/win32/comctl32/comboex.c branches/GSoC_2011/ThemesSupport/dll/win32/comctl32/comctl32undoc.c branches/GSoC_2011/ThemesSupport/dll/win32/comctl32/datetime.c branches/GSoC_2011/ThemesSupport/dll/win32/comctl32/ipaddress.c branches/GSoC_2011/ThemesSupport/dll/win32/comctl32/listview.c branches/GSoC_2011/ThemesSupport/dll/win32/comctl32/monthcal.c branches/GSoC_2011/ThemesSupport/dll/win32/comctl32/propsheet.c branches/GSoC_2011/ThemesSupport/dll/win32/comctl32/status.c branches/GSoC_2011/ThemesSupport/dll/win32/comctl32/syslink.c branches/GSoC_2011/ThemesSupport/dll/win32/comctl32/tab.c branches/GSoC_2011/ThemesSupport/dll/win32/comctl32/theme_button.c branches/GSoC_2011/ThemesSupport/dll/win32/comctl32/theme_dialog.c branches/GSoC_2011/ThemesSupport/dll/win32/comctl32/theming.c branches/GSoC_2011/ThemesSupport/dll/win32/comctl32/toolbar.c branches/GSoC_2011/ThemesSupport/dll/win32/comctl32/tooltips.c Modified: branches/GSoC_2011/ThemesSupport/dll/win32/comctl32/comboex.c URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/ThemesSupport/dll/win…
============================================================================== --- branches/GSoC_2011/ThemesSupport/dll/win32/comctl32/comboex.c [iso-8859-1] (original) +++ branches/GSoC_2011/ThemesSupport/dll/win32/comctl32/comboex.c [iso-8859-1] Sun Jul 17 15:16:59 2011 @@ -1120,10 +1120,10 @@ switch (command) { case CBN_DROPDOWN: - SetFocus (infoPtr->hwndCombo); - ShowWindow (infoPtr->hwndEdit, SW_HIDE); - return SendMessageW (parent, WM_COMMAND, wParam, (LPARAM)infoPtr->hwndSelf); - + SetFocus (infoPtr->hwndCombo); + ShowWindow (infoPtr->hwndEdit, SW_HIDE); + infoPtr->flags |= WCBE_ACTEDIT; + return SendMessageW (parent, WM_COMMAND, wParam, (LPARAM)infoPtr->hwndSelf); case CBN_CLOSEUP: SendMessageW (parent, WM_COMMAND, wParam, (LPARAM)infoPtr->hwndSelf); /* @@ -1741,7 +1741,7 @@ return DefSubclassProc(hwnd, uMsg, wParam, lParam); case WM_KEYDOWN: { - INT_PTR oldItem, selected, step = 1; + INT_PTR oldItem, selected; CBE_ITEMDATA *item; switch ((INT)wParam) @@ -1851,13 +1851,15 @@ break; case VK_UP: - step = -1; case VK_DOWN: - /* by default, step is 1 */ + { + INT step = wParam == VK_DOWN ? 1 : -1; + oldItem = SendMessageW (infoPtr->hwndSelf, CB_GETCURSEL, 0, 0); if (oldItem >= 0 && oldItem + step >= 0) SendMessageW (infoPtr->hwndSelf, CB_SETCURSEL, oldItem + step, 0); return 0; + } default: return DefSubclassProc(hwnd, uMsg, wParam, lParam); } Modified: branches/GSoC_2011/ThemesSupport/dll/win32/comctl32/comctl32undoc.c URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/ThemesSupport/dll/win…
============================================================================== --- branches/GSoC_2011/ThemesSupport/dll/win32/comctl32/comctl32undoc.c [iso-8859-1] (original) +++ branches/GSoC_2011/ThemesSupport/dll/win32/comctl32/comctl32undoc.c [iso-8859-1] Sun Jul 17 15:16:59 2011 @@ -168,23 +168,23 @@ *|typedef INT (CALLBACK *MRUStringCmpFn)(LPCTSTR lhs, LPCTSTR rhs); *|typedef INT (CALLBACK *MRUBinaryCmpFn)(LPCVOID lhs, LPCVOID rhs, DWORD length); *| - *|typedef struct tagCREATEMRULIST + *|typedef struct tagMRUINFO *|{ *| DWORD cbSize; - *| DWORD nMaxItems; - *| DWORD dwFlags; + *| UINT uMax; + *| UINT fFlags; *| HKEY hKey; *| LPTSTR lpszSubKey; *| PROC lpfnCompare; - *|} CREATEMRULIST, *LPCREATEMRULIST; + *|} MRUINFO, *LPMRUINFO; * * MEMBERS - * cbSize [I] The size of the CREATEMRULIST structure. This must be set - * to sizeof(CREATEMRULIST) by the caller. - * nMaxItems [I] The maximum number of items allowed in the list. Because + * cbSize [I] The size of the MRUINFO structure. This must be set + * to sizeof(MRUINFO) by the caller. + * uMax [I] The maximum number of items allowed in the list. Because * of the limited number of identifiers, this should be set to * a value from 1 to 30 by the caller. - * dwFlags [I] If bit 0 is set, the list will be used to store binary + * fFlags [I] If bit 0 is set, the list will be used to store binary * data, otherwise it is assumed to store strings. If bit 1 * is set, every change made to the list will be reflected in * the registry immediately, otherwise changes will only be @@ -210,11 +210,11 @@ typedef INT (CALLBACK *MRUStringCmpFnW)(LPCWSTR lhs, LPCWSTR rhs); typedef INT (CALLBACK *MRUBinaryCmpFn)(LPCVOID lhs, LPCVOID rhs, DWORD length); -typedef struct tagCREATEMRULISTA +typedef struct tagMRUINFOA { DWORD cbSize; - DWORD nMaxItems; - DWORD dwFlags; + UINT uMax; + UINT fFlags; HKEY hKey; LPSTR lpszSubKey; union @@ -222,13 +222,13 @@ MRUStringCmpFnA string_cmpfn; MRUBinaryCmpFn binary_cmpfn; } u; -} CREATEMRULISTA, *LPCREATEMRULISTA; - -typedef struct tagCREATEMRULISTW +} MRUINFOA, *LPMRUINFOA; + +typedef struct tagMRUINFOW { DWORD cbSize; - DWORD nMaxItems; - DWORD dwFlags; + UINT uMax; + UINT fFlags; HKEY hKey; LPWSTR lpszSubKey; union @@ -236,12 +236,12 @@ MRUStringCmpFnW string_cmpfn; MRUBinaryCmpFn binary_cmpfn; } u; -} CREATEMRULISTW, *LPCREATEMRULISTW; - -/* dwFlags */ -#define MRUF_STRING_LIST 0 /* list will contain strings */ -#define MRUF_BINARY_LIST 1 /* list will contain binary data */ -#define MRUF_DELAYED_SAVE 2 /* only save list order to reg. is FreeMRUList */ +} MRUINFOW, *LPMRUINFOW; + +/* MRUINFO.fFlags */ +#define MRU_STRING 0 /* list will contain strings */ +#define MRU_BINARY 1 /* list will contain binary data */ +#define MRU_CACHEWRITE 2 /* only save list order to reg. is FreeMRUList */ /* If list is a string list lpfnCompare has the following prototype * int CALLBACK MRUCompareString(LPCSTR s1, LPCSTR s2) @@ -263,7 +263,7 @@ typedef struct tagWINEMRULIST { - CREATEMRULISTW extview; /* original create information */ + MRUINFOW extview; /* original create information */ BOOL isUnicode; /* is compare fn Unicode */ DWORD wineFlags; /* internal flags */ DWORD cursize; /* current size of realMRU */ @@ -325,7 +325,7 @@ witem->itemFlag &= ~WMRUIF_CHANGED; realname[0] = 'a' + i; err = RegSetValueExW(newkey, realname, 0, - (mp->extview.dwFlags & MRUF_BINARY_LIST) ? + (mp->extview.fFlags & MRU_BINARY) ? REG_BINARY : REG_SZ, &witem->datastart, witem->size); if (err) { @@ -363,7 +363,7 @@ MRU_SaveChanged( mp ); } - for(i=0; i<mp->extview.nMaxItems; i++) + for(i=0; i<mp->extview.uMax; i++) Free(mp->array[i]); Free(mp->realMRU); @@ -400,7 +400,7 @@ if (!mp || !mp->extview.u.string_cmpfn) return -1; - if(!(mp->extview.dwFlags & MRUF_BINARY_LIST) && !mp->isUnicode) { + if(!(mp->extview.fFlags & MRU_BINARY) && !mp->isUnicode) { DWORD len = WideCharToMultiByte(CP_ACP, 0, lpData, -1, NULL, 0, NULL, NULL); dataA = Alloc(len); @@ -408,7 +408,7 @@ } for(i=0; i<mp->cursize; i++) { - if (mp->extview.dwFlags & MRUF_BINARY_LIST) { + if (mp->extview.fFlags & MRU_BINARY) { if (!mp->extview.u.binary_cmpfn(lpData, &mp->array[i]->datastart, cbData)) break; } @@ -480,7 +480,7 @@ } else { /* either add a new entry or replace oldest */ - if (mp->cursize < mp->extview.nMaxItems) { + if (mp->cursize < mp->extview.uMax) { /* Add in a new item */ replace = mp->cursize; mp->cursize++; @@ -509,7 +509,7 @@ TRACE("(%p, %p, %d) adding data, /%c/ now most current\n", hList, lpData, cbData, replace+'a'); - if (!(mp->extview.dwFlags & MRUF_DELAYED_SAVE)) { + if (!(mp->extview.fFlags & MRU_CACHEWRITE)) { /* save changed stuff right now */ MRU_SaveChanged( mp ); } @@ -649,9 +649,9 @@ } /************************************************************************* - * CreateMRUListLazy_common (internal) - */ -static HANDLE CreateMRUListLazy_common(LPWINEMRULIST mp) + * create_mru_list (internal) + */ +static HANDLE create_mru_list(LPWINEMRULIST mp) { UINT i, err; HKEY newkey; @@ -663,12 +663,12 @@ /* get space to save indices that will turn into names * but in order of most to least recently used */ - mp->realMRU = Alloc((mp->extview.nMaxItems + 2) * sizeof(WCHAR)); + mp->realMRU = Alloc((mp->extview.uMax + 2) * sizeof(WCHAR)); /* get space to save pointers to actual data in order of * 'a' to 'z' (0 to n). */ - mp->array = Alloc(mp->extview.nMaxItems * sizeof(LPVOID)); + mp->array = Alloc(mp->extview.uMax * sizeof(LPVOID)); /* open the sub key */ if ((err = RegCreateKeyExW( mp->extview.hKey, mp->extview.lpszSubKey, @@ -681,7 +681,7 @@ &dwdisp))) { /* error - what to do ??? */ ERR("(%u %u %x %p %s %p): Could not open key, error=%d\n", - mp->extview.cbSize, mp->extview.nMaxItems, mp->extview.dwFlags, + mp->extview.cbSize, mp->extview.uMax, mp->extview.fFlags, mp->extview.hKey, debugstr_w(mp->extview.lpszSubKey), mp->extview.u.string_cmpfn, err); return 0; @@ -689,7 +689,7 @@ /* get values from key 'MRUList' */ if (newkey) { - datasize = (mp->extview.nMaxItems + 1) * sizeof(WCHAR); + datasize = (mp->extview.uMax + 1) * sizeof(WCHAR); if((err=RegQueryValueExW( newkey, strMRUList, 0, &type, (LPBYTE)mp->realMRU, &datasize))) { /* not present - set size to 1 (will become 0 later) */ @@ -726,7 +726,7 @@ mp->cursize = 0; TRACE("(%u %u %x %p %s %p): Current Size = %d\n", - mp->extview.cbSize, mp->extview.nMaxItems, mp->extview.dwFlags, + mp->extview.cbSize, mp->extview.uMax, mp->extview.fFlags, mp->extview.hKey, debugstr_w(mp->extview.lpszSubKey), mp->extview.u.string_cmpfn, mp->cursize); return mp; @@ -737,24 +737,22 @@ * * See CreateMRUListLazyA. */ -HANDLE WINAPI CreateMRUListLazyW (const CREATEMRULISTW *lpcml, DWORD dwParam2, +HANDLE WINAPI CreateMRUListLazyW (const MRUINFOW *infoW, DWORD dwParam2, DWORD dwParam3, DWORD dwParam4) { LPWINEMRULIST mp; /* Native does not check for a NULL lpcml */ - - if (lpcml->cbSize != sizeof(CREATEMRULISTW) || !lpcml->hKey || - IsBadStringPtrW(lpcml->lpszSubKey, -1)) + if (!infoW->hKey || IsBadStringPtrW(infoW->lpszSubKey, -1)) return NULL; mp = Alloc(sizeof(WINEMRULIST)); - memcpy(&mp->extview, lpcml, sizeof(CREATEMRULISTW)); - mp->extview.lpszSubKey = Alloc((strlenW(lpcml->lpszSubKey) + 1) * sizeof(WCHAR)); - strcpyW(mp->extview.lpszSubKey, lpcml->lpszSubKey); + memcpy(&mp->extview, infoW, sizeof(MRUINFOW)); + mp->extview.lpszSubKey = Alloc((strlenW(infoW->lpszSubKey) + 1) * sizeof(WCHAR)); + strcpyW(mp->extview.lpszSubKey, infoW->lpszSubKey); mp->isUnicode = TRUE; - return CreateMRUListLazy_common(mp); + return create_mru_list(mp); } /************************************************************************** @@ -771,7 +769,7 @@ * RETURNS * Handle to MRU list. */ -HANDLE WINAPI CreateMRUListLazyA (const CREATEMRULISTA *lpcml, DWORD dwParam2, +HANDLE WINAPI CreateMRUListLazyA (const MRUINFOA *lpcml, DWORD dwParam2, DWORD dwParam3, DWORD dwParam4) { LPWINEMRULIST mp; @@ -779,18 +777,18 @@ /* Native does not check for a NULL lpcml */ - if (lpcml->cbSize != sizeof(CREATEMRULISTA) || !lpcml->hKey || + if (lpcml->cbSize != sizeof(MRUINFOA) || !lpcml->hKey || IsBadStringPtrA(lpcml->lpszSubKey, -1)) return 0; mp = Alloc(sizeof(WINEMRULIST)); - memcpy(&mp->extview, lpcml, sizeof(CREATEMRULISTW)); + memcpy(&mp->extview, lpcml, sizeof(MRUINFOA)); len = MultiByteToWideChar(CP_ACP, 0, lpcml->lpszSubKey, -1, NULL, 0); mp->extview.lpszSubKey = Alloc(len * sizeof(WCHAR)); MultiByteToWideChar(CP_ACP, 0, lpcml->lpszSubKey, -1, mp->extview.lpszSubKey, len); mp->isUnicode = FALSE; - return CreateMRUListLazy_common(mp); + return create_mru_list(mp); } /************************************************************************** @@ -798,9 +796,9 @@ * * See CreateMRUListA. */ -HANDLE WINAPI CreateMRUListW (const CREATEMRULISTW *lpcml) -{ - return CreateMRUListLazyW(lpcml, 0, 0, 0); +HANDLE WINAPI CreateMRUListW (const MRUINFOW *infoW) +{ + return CreateMRUListLazyW(infoW, 0, 0, 0); } /************************************************************************** @@ -814,7 +812,7 @@ * RETURNS * Handle to MRU list. */ -HANDLE WINAPI CreateMRUListA (const CREATEMRULISTA *lpcml) +HANDLE WINAPI CreateMRUListA (const MRUINFOA *lpcml) { return CreateMRUListLazyA (lpcml, 0, 0, 0); } @@ -879,7 +877,7 @@ desired -= 'a'; TRACE("nItemPos=%d, desired=%d\n", nItemPos, desired); witem = mp->array[desired]; - if(mp->extview.dwFlags & MRUF_BINARY_LIST) { + if(mp->extview.fFlags & MRU_BINARY) { datasize = min( witem->size, nBufferSize ); memcpy( lpBuffer, &witem->datastart, datasize); } else { Modified: branches/GSoC_2011/ThemesSupport/dll/win32/comctl32/datetime.c URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/ThemesSupport/dll/win…
============================================================================== --- branches/GSoC_2011/ThemesSupport/dll/win32/comctl32/datetime.c [iso-8859-1] (original) +++ branches/GSoC_2011/ThemesSupport/dll/win32/comctl32/datetime.c [iso-8859-1] Sun Jul 17 15:16:59 2011 @@ -73,6 +73,8 @@ BOOL bCalDepressed; /* TRUE = cal button is depressed */ int bDropdownEnabled; int select; + WCHAR charsEntered[4]; + int nCharsEntered; HFONT hFont; int nrFieldsAllocated; int nrFields; @@ -165,7 +167,8 @@ if (flag == GDT_VALID) { if (systime->wYear < 1601 || systime->wYear > 30827 || systime->wMonth < 1 || systime->wMonth > 12 || - systime->wDay < 1 || systime->wDay > 31 || + systime->wDay < 1 || + systime->wDay > MONTHCAL_MonthLength(systime->wMonth, systime->wYear) || systime->wHour > 23 || systime->wMinute > 59 || systime->wSecond > 59 || @@ -277,10 +280,11 @@ static BOOL -DATETIME_SetFormatW (DATETIME_INFO *infoPtr, LPCWSTR lpszFormat) -{ - if (!lpszFormat) { - WCHAR format_buf[80]; +DATETIME_SetFormatW (DATETIME_INFO *infoPtr, LPCWSTR format) +{ + WCHAR format_buf[80]; + + if (!format) { DWORD format_item; if (infoPtr->dwStyle & DTS_LONGDATEFORMAT) @@ -290,13 +294,13 @@ else /* DTS_SHORTDATEFORMAT */ format_item = LOCALE_SSHORTDATE; GetLocaleInfoW(LOCALE_USER_DEFAULT, format_item, format_buf, sizeof(format_buf)/sizeof(format_buf[0])); - lpszFormat = format_buf; - } - - DATETIME_UseFormat (infoPtr, lpszFormat); + format = format_buf; + } + + DATETIME_UseFormat (infoPtr, format); InvalidateRect (infoPtr->hwndSelf, NULL, TRUE); - return 1; + return TRUE; } @@ -470,6 +474,9 @@ case TWODIGITYEAR: case FULLYEAR: date->wYear = wrap(date->wYear, delta, 1752, 9999); + if (date->wDay > MONTHCAL_MonthLength(date->wMonth, date->wYear)) + /* This can happen when moving away from a leap year. */ + date->wDay = MONTHCAL_MonthLength(date->wMonth, date->wYear); MONTHCAL_CalculateDayOfWeek(date, TRUE); break; case ONEDIGITMONTH: @@ -696,6 +703,13 @@ /* fill if focused */ HBRUSH hbr = CreateSolidBrush (comctl32_color.clrActiveCaption); + if (infoPtr->nCharsEntered) + { + memcpy(txt, infoPtr->charsEntered, infoPtr->nCharsEntered * sizeof(WCHAR)); + txt[infoPtr->nCharsEntered] = 0; + GetTextExtentPoint32W (hdc, txt, strlenW(txt), &size); + } + selection.left = 0; selection.top = 0; selection.right = size.cx; @@ -753,6 +767,74 @@ if (infoPtr->fieldspec[i] & DTHT_DATEFIELD) return i; } return -1; +} + +static void +DATETIME_ApplySelectedField (DATETIME_INFO *infoPtr) +{ + int fieldNum = infoPtr->select & DTHT_DATEFIELD; + int i, val=0, clamp_day=0; + SYSTEMTIME date = infoPtr->date; + + if (infoPtr->select == -1 || infoPtr->nCharsEntered == 0) + return; + + for (i=0; i<infoPtr->nCharsEntered; i++) + val = val * 10 + infoPtr->charsEntered[i] - '0'; + + infoPtr->nCharsEntered = 0; + + switch (infoPtr->fieldspec[fieldNum]) { + case ONEDIGITYEAR: + case TWODIGITYEAR: + date.wYear = date.wYear - (date.wYear%100) + val; + clamp_day = 1; + break; + case INVALIDFULLYEAR: + case FULLYEAR: + date.wYear = val; + clamp_day = 1; + break; + case ONEDIGITMONTH: + case TWODIGITMONTH: + date.wMonth = val; + clamp_day = 1; + break; + case ONEDIGITDAY: + case TWODIGITDAY: + date.wDay = val; + break; + case ONEDIGIT12HOUR: + case TWODIGIT12HOUR: + case ONEDIGIT24HOUR: + case TWODIGIT24HOUR: + /* FIXME: Preserve AM/PM for 12HOUR? */ + date.wHour = val; + break; + case ONEDIGITMINUTE: + case TWODIGITMINUTE: + date.wMinute = val; + break; + case ONEDIGITSECOND: + case TWODIGITSECOND: + date.wSecond = val; + break; + } + + if (clamp_day && date.wDay > MONTHCAL_MonthLength(date.wMonth, date.wYear)) + date.wDay = MONTHCAL_MonthLength(date.wMonth, date.wYear); + + if (DATETIME_SetSystemTime(infoPtr, GDT_VALID, &date)) + DATETIME_SendDateTimeChangeNotify (infoPtr); +} + +static void +DATETIME_SetSelectedField (DATETIME_INFO *infoPtr, int select) +{ + DATETIME_ApplySelectedField(infoPtr); + + infoPtr->select = select; + infoPtr->nCharsEntered = 0; } static LRESULT @@ -783,7 +865,8 @@ if (infoPtr->fieldspec[new] == FULLDAY) return 0; } } - infoPtr->select = new; + + DATETIME_SetSelectedField(infoPtr, new); if (infoPtr->select == DTHT_MCPOPUP) { RECT rcMonthCal; @@ -961,6 +1044,7 @@ { int fieldNum = infoPtr->select & DTHT_DATEFIELD; int wrap = 0; + int new; if (!(infoPtr->haveFocus)) return 0; if ((fieldNum==0) && (infoPtr->select)) return 0; @@ -972,40 +1056,50 @@ switch (vkCode) { case VK_ADD: case VK_UP: + infoPtr->nCharsEntered = 0; DATETIME_IncreaseField (infoPtr, fieldNum, 1); DATETIME_SendDateTimeChangeNotify (infoPtr); break; case VK_SUBTRACT: case VK_DOWN: + infoPtr->nCharsEntered = 0; DATETIME_IncreaseField (infoPtr, fieldNum, -1); DATETIME_SendDateTimeChangeNotify (infoPtr); break; case VK_HOME: + infoPtr->nCharsEntered = 0; DATETIME_IncreaseField (infoPtr, fieldNum, INT_MIN); DATETIME_SendDateTimeChangeNotify (infoPtr); break; case VK_END: + infoPtr->nCharsEntered = 0; DATETIME_IncreaseField (infoPtr, fieldNum, INT_MAX); DATETIME_SendDateTimeChangeNotify (infoPtr); break; case VK_LEFT: + new = infoPtr->select; do { - if (infoPtr->select == 0) { - infoPtr->select = infoPtr->nrFields - 1; + if (new == 0) { + new = new - 1; wrap++; } else { - infoPtr->select--; + new--; } - } while ((infoPtr->fieldspec[infoPtr->select] & DT_STRING) && (wrap<2)); + } while ((infoPtr->fieldspec[new] & DT_STRING) && (wrap<2)); + if (new != infoPtr->select) + DATETIME_SetSelectedField(infoPtr, new); break; case VK_RIGHT: + new = infoPtr->select; do { - infoPtr->select++; - if (infoPtr->select==infoPtr->nrFields) { - infoPtr->select = 0; + new++; + if (new==infoPtr->nrFields) { + new = 0; wrap++; } - } while ((infoPtr->fieldspec[infoPtr->select] & DT_STRING) && (wrap<2)); + } while ((infoPtr->fieldspec[new] & DT_STRING) && (wrap<2)); + if (new != infoPtr->select) + DATETIME_SetSelectedField(infoPtr, new); break; } @@ -1021,80 +1115,20 @@ int fieldNum = infoPtr->select & DTHT_DATEFIELD; if (vkCode >= '0' && vkCode <= '9') { - int num = vkCode-'0'; - int newDays; - - /* this is a somewhat simplified version of what Windows does */ - SYSTEMTIME *date = &infoPtr->date; - switch (infoPtr->fieldspec[fieldNum]) { - case ONEDIGITYEAR: - case TWODIGITYEAR: - date->wYear = date->wYear - (date->wYear%100) + - (date->wYear%10)*10 + num; - MONTHCAL_CalculateDayOfWeek(date, TRUE); - DATETIME_SendDateTimeChangeNotify (infoPtr); - break; - case INVALIDFULLYEAR: - case FULLYEAR: - /* reset current year initialy */ - date->wYear = ((date->wYear/1000) ? 0 : 1)*(date->wYear%1000)*10 + num; - MONTHCAL_CalculateDayOfWeek(date, TRUE); - DATETIME_SendDateTimeChangeNotify (infoPtr); - break; - case ONEDIGITMONTH: - case TWODIGITMONTH: - if ((date->wMonth%10) > 1 || num > 2) - date->wMonth = num; - else - date->wMonth = (date->wMonth%10)*10+num; - MONTHCAL_CalculateDayOfWeek(date, TRUE); - DATETIME_SendDateTimeChangeNotify (infoPtr); - break; - case ONEDIGITDAY: - case TWODIGITDAY: - newDays = (date->wDay%10)*10+num; - if (newDays > MONTHCAL_MonthLength(date->wMonth, date->wYear)) - date->wDay = num; - else - date->wDay = newDays; - MONTHCAL_CalculateDayOfWeek(date, TRUE); - DATETIME_SendDateTimeChangeNotify (infoPtr); - break; - case ONEDIGIT12HOUR: - case TWODIGIT12HOUR: - if ((date->wHour%10) > 1 || num > 2) - date->wHour = num; - else - date->wHour = (date->wHour%10)*10+num; - DATETIME_SendDateTimeChangeNotify (infoPtr); - break; - case ONEDIGIT24HOUR: - case TWODIGIT24HOUR: - if ((date->wHour%10) > 2) - date->wHour = num; - else if ((date->wHour%10) == 2 && num > 3) - date->wHour = num; - else - date->wHour = (date->wHour%10)*10+num; - DATETIME_SendDateTimeChangeNotify (infoPtr); - break; - case ONEDIGITMINUTE: - case TWODIGITMINUTE: - if ((date->wMinute%10) > 5) - date->wMinute = num; - else - date->wMinute = (date->wMinute%10)*10+num; - DATETIME_SendDateTimeChangeNotify (infoPtr); - break; - case ONEDIGITSECOND: - case TWODIGITSECOND: - if ((date->wSecond%10) > 5) - date->wSecond = num; - else - date->wSecond = (date->wSecond%10)*10+num; - DATETIME_SendDateTimeChangeNotify (infoPtr); - break; - } + int maxChars; + int fieldSpec; + + infoPtr->charsEntered[infoPtr->nCharsEntered++] = vkCode; + + fieldSpec = infoPtr->fieldspec[fieldNum]; + + if (fieldSpec == INVALIDFULLYEAR || fieldSpec == FULLYEAR) + maxChars = 4; + else + maxChars = 2; + + if (maxChars == infoPtr->nCharsEntered) + DATETIME_ApplySelectedField(infoPtr); } return 0; } @@ -1132,6 +1166,7 @@ if (infoPtr->haveFocus) { DATETIME_SendSimpleNotify (infoPtr, NM_KILLFOCUS); infoPtr->haveFocus = 0; + DATETIME_SetSelectedField (infoPtr, -1); } InvalidateRect (infoPtr->hwndSelf, NULL, TRUE); Modified: branches/GSoC_2011/ThemesSupport/dll/win32/comctl32/ipaddress.c URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/ThemesSupport/dll/win…
============================================================================== --- branches/GSoC_2011/ThemesSupport/dll/win32/comctl32/ipaddress.c [iso-8859-1] (original) +++ branches/GSoC_2011/ThemesSupport/dll/win32/comctl32/ipaddress.c [iso-8859-1] Sun Jul 17 15:16:59 2011 @@ -384,15 +384,16 @@ static BOOL IPADDRESS_ConstrainField (const IPADDRESS_INFO *infoPtr, int currentfield) { - const IPPART_INFO *part = &infoPtr->Part[currentfield]; + static const WCHAR fmt[] = { '%', 'd', 0 }; + const IPPART_INFO *part; + int curValue, newValue; WCHAR field[10]; - static const WCHAR fmt[] = { '%', 'd', 0 }; - int curValue, newValue; TRACE("(currentfield=%d)\n", currentfield); if (currentfield < 0 || currentfield > 3) return FALSE; + part = &infoPtr->Part[currentfield]; if (!GetWindowTextW (part->EditHwnd, field, 4)) return FALSE; curValue = atoiW(field); Modified: branches/GSoC_2011/ThemesSupport/dll/win32/comctl32/listview.c URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/ThemesSupport/dll/win…
============================================================================== --- branches/GSoC_2011/ThemesSupport/dll/win32/comctl32/listview.c [iso-8859-1] (original) +++ branches/GSoC_2011/ThemesSupport/dll/win32/comctl32/listview.c [iso-8859-1] Sun Jul 17 15:16:59 2011 @@ -315,7 +315,6 @@ COLORREF clrBk; COLORREF clrText; COLORREF clrTextBk; - BOOL bDefaultBkColor; /* font */ HFONT hDefaultFont; @@ -1498,6 +1497,70 @@ return TRUE; } +/* Remove common elements from two iterators */ +/* Passed iterators have to point on the first elements */ +static BOOL iterator_remove_common_items(ITERATOR *iter1, ITERATOR *iter2) +{ + if(!iter1->ranges || !iter2->ranges) { + int lower, upper; + + if(iter1->ranges || iter2->ranges || + (iter1->range.lower<iter2->range.lower && iter1->range.upper>iter2->range.upper) || + (iter1->range.lower>iter2->range.lower && iter1->range.upper<iter2->range.upper)) { + ERR("result is not a one range iterator\n"); + return FALSE; + } + + if(iter1->range.lower==-1 || iter2->range.lower==-1) + return TRUE; + + lower = iter1->range.lower; + upper = iter1->range.upper; + + if(lower < iter2->range.lower) + iter1->range.upper = iter2->range.lower; + else if(upper > iter2->range.upper) + iter1->range.lower = iter2->range.upper; + else + iter1->range.lower = iter1->range.upper = -1; + + if(iter2->range.lower < lower) + iter2->range.upper = lower; + else if(iter2->range.upper > upper) + iter2->range.lower = upper; + else + iter2->range.lower = iter2->range.upper = -1; + + return TRUE; + } + + iterator_next(iter1); + iterator_next(iter2); + + while(1) { + if(iter1->nItem==-1 || iter2->nItem==-1) + break; + + if(iter1->nItem == iter2->nItem) { + int delete = iter1->nItem; + + iterator_prev(iter1); + iterator_prev(iter2); + ranges_delitem(iter1->ranges, delete); + ranges_delitem(iter2->ranges, delete); + iterator_next(iter1); + iterator_next(iter2); + } else if(iter1->nItem > iter2->nItem) + iterator_next(iter2); + else + iterator_next(iter1); + } + + iter1->nItem = iter1->range.lower = iter1->range.upper = -1; + iter2->nItem = iter2->range.lower = iter2->range.upper = -1; + return TRUE; +} + /******** Misc helper functions ************************************/ static inline LRESULT CallWindowProcT(WNDPROC proc, HWND hwnd, UINT uMsg, @@ -1636,19 +1699,8 @@ /* used to handle collapse main item column case */ static inline BOOL LISTVIEW_DrawFocusRect(const LISTVIEW_INFO *infoPtr, HDC hdc) { - BOOL Ret = FALSE; - - if (infoPtr->rcFocus.left < infoPtr->rcFocus.right) - { - DWORD dwOldBkColor, dwOldTextColor; - - dwOldBkColor = SetBkColor(hdc, RGB(255, 255, 255)); - dwOldTextColor = SetBkColor(hdc, RGB(0, 0, 0)); - Ret = DrawFocusRect(hdc, &infoPtr->rcFocus); - SetBkColor(hdc, dwOldBkColor); - SetBkColor(hdc, dwOldTextColor); - } - return Ret; + return (infoPtr->rcFocus.left < infoPtr->rcFocus.right) ? + DrawFocusRect(hdc, &infoPtr->rcFocus) : FALSE; } /* Listview invalidation functions: use _only_ these functions to invalidate */ @@ -3745,7 +3797,7 @@ { BOOL controlDown = FALSE; LVITEMW item; - ITERATOR i; + ITERATOR old_elems, new_elems; RECT rect; if (coords_offs->x > infoPtr->marqueeOrigin.x) @@ -3788,54 +3840,55 @@ if ((scroll & SCROLL_DOWN) && (coords_orig->y >= infoPtr->rcList.bottom)) LISTVIEW_Scroll(infoPtr, 0, (coords_orig->y - infoPtr->rcList.bottom)); - /* Invert the items in the old marquee rectangle */ - iterator_frameditems_absolute(&i, infoPtr, &infoPtr->marqueeRect); - - while (iterator_next(&i)) - { - if (i.nItem > -1) + iterator_frameditems_absolute(&old_elems, infoPtr, &infoPtr->marqueeRect); + + CopyRect(&infoPtr->marqueeRect, &rect); + + CopyRect(&infoPtr->marqueeDrawRect, &rect); + OffsetRect(&infoPtr->marqueeDrawRect, offset->x, offset->y); + + iterator_frameditems_absolute(&new_elems, infoPtr, &infoPtr->marqueeRect); + iterator_remove_common_items(&old_elems, &new_elems); + + /* Iterate over no longer selected items */ + while (iterator_next(&old_elems)) + { + if (old_elems.nItem > -1) { - if (LISTVIEW_GetItemState(infoPtr, i.nItem, LVIS_SELECTED) == LVIS_SELECTED) + if (LISTVIEW_GetItemState(infoPtr, old_elems.nItem, LVIS_SELECTED) == LVIS_SELECTED) item.state = 0; else item.state = LVIS_SELECTED; item.stateMask = LVIS_SELECTED; - LISTVIEW_SetItemState(infoPtr, i.nItem, &item); + LISTVIEW_SetItemState(infoPtr, old_elems.nItem, &item); } } - - iterator_destroy(&i); - - CopyRect(&infoPtr->marqueeRect, &rect); - - CopyRect(&infoPtr->marqueeDrawRect, &rect); - OffsetRect(&infoPtr->marqueeDrawRect, offset->x, offset->y); - - /* Iterate over the items within our marquee rectangle */ - iterator_frameditems_absolute(&i, infoPtr, &infoPtr->marqueeRect); - + iterator_destroy(&old_elems); + + + /* Iterate over newly selected items */ if (GetKeyState(VK_CONTROL) & 0x8000) controlDown = TRUE; - while (iterator_next(&i)) - { - if (i.nItem > -1) + while (iterator_next(&new_elems)) + { + if (new_elems.nItem > -1) { /* If CTRL is pressed, invert. If not, always select the item. */ - if ((controlDown) && (LISTVIEW_GetItemState(infoPtr, i.nItem, LVIS_SELECTED))) + if ((controlDown) && (LISTVIEW_GetItemState(infoPtr, new_elems.nItem, LVIS_SELECTED))) item.state = 0; else item.state = LVIS_SELECTED; item.stateMask = LVIS_SELECTED; - LISTVIEW_SetItemState(infoPtr, i.nItem, &item); + LISTVIEW_SetItemState(infoPtr, new_elems.nItem, &item); } } - - iterator_destroy(&i); + iterator_destroy(&new_elems); + LISTVIEW_InvalidateRect(infoPtr, &rect); } @@ -4284,9 +4337,9 @@ particularly useful. We currently do not actually do anything with the flag on subitems. */ - if (lpLVItem->mask & ~(LVIF_TEXT | LVIF_IMAGE | LVIF_STATE)) return FALSE; + if (lpLVItem->mask & ~(LVIF_TEXT | LVIF_IMAGE | LVIF_STATE | LVIF_DI_SETITEM)) return FALSE; if (!(lpLVItem->mask & (LVIF_TEXT | LVIF_IMAGE | LVIF_STATE))) return TRUE; - + /* get the subitem structure, and create it if not there */ hdpaSubItems = DPA_GetPtr(infoPtr->hdpaItems, lpLVItem->iItem); assert (hdpaSubItems); @@ -4353,6 +4406,9 @@ if (!lpLVItem || lpLVItem->iItem < 0 || lpLVItem->iItem >= infoPtr->nItemCount) return FALSE; + + /* Invalidate old item area */ + LISTVIEW_InvalidateItem(infoPtr, lpLVItem->iItem); /* For efficiency, we transform the lpLVItem->pszText to Unicode here */ if ((lpLVItem->mask & LVIF_TEXT) && is_text(lpLVItem->pszText)) @@ -4973,6 +5029,9 @@ SelectObject(hdc, hbmp); SelectObject(hdc, infoPtr->hFont); + + if(GetClipBox(hdcOrig, &rcClient)) + IntersectClipRect(hdc, rcClient.left, rcClient.top, rcClient.right, rcClient.bottom); } else { /* Save dc values we're gonna trash while drawing * FIXME: Should be done in LISTVIEW_DrawItem() */ @@ -5054,11 +5113,7 @@ /* Draw marquee rectangle if appropriate */ if (infoPtr->bMarqueeSelect) - { - SetBkColor(hdc, RGB(255, 255, 255)); - SetTextColor(hdc, RGB(0, 0, 0)); DrawFocusRect(hdc, &infoPtr->marqueeDrawRect); - } if (cdmode & CDRF_NOTIFYPOSTPAINT) notify_postpaint(infoPtr, &nmlvcd); @@ -5678,7 +5733,7 @@ WCHAR szDispText[DISP_TEXT_SIZE] = { 0 }; NMLVDISPINFOW dispInfo; INT editedItem = infoPtr->nEditLabelItem; - BOOL bSame; + BOOL same; WCHAR *pszText = NULL; BOOL res; @@ -5698,9 +5753,6 @@ TRACE("(pszText=%s, isW=%d)\n", debugtext_t(pszText, isW), isW); - infoPtr->nEditLabelItem = -1; - infoPtr->hwndEdit = 0; - ZeroMemory(&dispInfo, sizeof(dispInfo)); dispInfo.item.mask = LVIF_PARAM | LVIF_STATE | LVIF_TEXT; dispInfo.item.iItem = editedItem; @@ -5715,32 +5767,34 @@ } if (isW) - bSame = (lstrcmpW(dispInfo.item.pszText, pszText) == 0); + same = (lstrcmpW(dispInfo.item.pszText, pszText) == 0); else { LPWSTR tmp = textdupTtoW(pszText, FALSE); - bSame = (lstrcmpW(dispInfo.item.pszText, tmp) == 0); + same = (lstrcmpW(dispInfo.item.pszText, tmp) == 0); textfreeT(tmp, FALSE); } /* add the text from the edit in */ dispInfo.item.mask |= LVIF_TEXT; - dispInfo.item.pszText = bSame ? NULL : pszText; - dispInfo.item.cchTextMax = bSame ? 0 : textlenT(pszText, isW); + dispInfo.item.pszText = same ? NULL : pszText; + dispInfo.item.cchTextMax = textlenT(dispInfo.item.pszText, isW); /* Do we need to update the Item Text */ - if (!notify_dispinfoT(infoPtr, LVN_ENDLABELEDITW, &dispInfo, isW)) - { - res = FALSE; - goto cleanup; - } + res = notify_dispinfoT(infoPtr, LVN_ENDLABELEDITW, &dispInfo, isW); + + infoPtr->nEditLabelItem = -1; + infoPtr->hwndEdit = 0; + + if (!res) goto cleanup; + if (!IsWindow(hwndSelf)) { res = FALSE; goto cleanup; } if (!pszText) return TRUE; - if (bSame) + if (same) { res = TRUE; goto cleanup; @@ -7823,10 +7877,8 @@ * is passed, then the scroll will be 0. (per MSDN 7/2002) * * For: (per experimentation with native control and CSpy ListView) - * LV_VIEW_ICON dy=1 = 1 pixel (vertical only) - * dx ignored - * LV_VIEW_SMALLICON dy=1 = 1 pixel (vertical only) - * dx ignored + * LV_VIEW_ICON scrolling in any direction is allowed + * LV_VIEW_SMALLICON scrolling in any direction is allowed * LV_VIEW_LIST dx=1 = 1 column (horizontal only) * but will only scroll 1 column per message * no matter what the value. @@ -7846,7 +7898,6 @@ if (dy != 0) return FALSE; break; default: /* icon */ - dx = 0; break; } @@ -7872,7 +7923,6 @@ { TRACE("(clrBk=%x)\n", clrBk); - infoPtr->bDefaultBkColor = FALSE; if(infoPtr->clrBk != clrBk) { if (infoPtr->clrBk != CLR_NONE) DeleteObject(infoPtr->hBkBrush); infoPtr->clrBk = clrBk; @@ -8803,8 +8853,8 @@ { LVITEMW lvItem; - if (nItem < 0 && nItem >= infoPtr->nItemCount) return FALSE; - + if (!lpLVItem || nItem < 0 || nItem >= infoPtr->nItemCount) return FALSE; + lvItem.iItem = nItem; lvItem.iSubItem = lpLVItem->iSubItem; lvItem.mask = LVIF_TEXT; @@ -9116,9 +9166,7 @@ /* I believe nHotItem should be left alone, see LISTVIEW_ShiftIndices */ /* refresh the display */ - if (infoPtr->uView != LV_VIEW_ICON && infoPtr->uView != LV_VIEW_SMALLICON) - LISTVIEW_InvalidateList(infoPtr); - + LISTVIEW_InvalidateList(infoPtr); return TRUE; } @@ -9265,7 +9313,6 @@ infoPtr->clrText = CLR_DEFAULT; infoPtr->clrTextBk = CLR_DEFAULT; LISTVIEW_SetBkColor(infoPtr, comctl32_color.clrWindow); - infoPtr->bDefaultBkColor = TRUE; /* set default values */ infoPtr->nFocusedItem = -1; @@ -9595,6 +9642,7 @@ { INT nOldScrollPos, nNewScrollPos; SCROLLINFO scrollInfo; + BOOL is_an_icon; TRACE("(nScrollCode=%d(%s), nScrollDiff=%d)\n", nScrollCode, debugscrollcode(nScrollCode), nScrollDiff); @@ -9604,6 +9652,8 @@ scrollInfo.cbSize = sizeof(SCROLLINFO); scrollInfo.fMask = SIF_PAGE | SIF_POS | SIF_RANGE | SIF_TRACKPOS; + is_an_icon = ((infoPtr->uView == LV_VIEW_ICON) || (infoPtr->uView == LV_VIEW_SMALLICON)); + if (!GetScrollInfo(infoPtr->hwndSelf, SB_HORZ, &scrollInfo)) return 1; nOldScrollPos = scrollInfo.nPos; @@ -9614,11 +9664,11 @@ break; case SB_LINELEFT: - nScrollDiff = -1; + nScrollDiff = (is_an_icon) ? -LISTVIEW_SCROLL_ICON_LINE_SIZE : -1; break; case SB_LINERIGHT: - nScrollDiff = 1; + nScrollDiff = (is_an_icon) ? LISTVIEW_SCROLL_ICON_LINE_SIZE : 1; break; case SB_PAGELEFT: @@ -10160,7 +10210,6 @@ */ static LRESULT LISTVIEW_Notify(LISTVIEW_INFO *infoPtr, const NMHDR *lpnmhdr) { - HWND hwndSelf = infoPtr->hwndSelf; const NMHEADERW *lpnmh; TRACE("(lpnmhdr=%p)\n", lpnmhdr); @@ -10213,10 +10262,6 @@ LISTVIEW_InvalidateList(infoPtr); notify_forward_header(infoPtr, lpnmh); return FALSE; - - case HDN_ITEMCHANGINGW: - case HDN_ITEMCHANGINGA: - return notify_forward_header(infoPtr, lpnmh); case HDN_ITEMCHANGEDW: case HDN_ITEMCHANGEDA: @@ -10224,10 +10269,6 @@ COLUMN_INFO *lpColumnInfo; HDITEMW hdi; INT dx, cxy; - - notify_forward_header(infoPtr, lpnmh); - if (!IsWindow(hwndSelf)) - break; if (!lpnmh->pitem || !(lpnmh->pitem->mask & HDI_WIDTH)) { @@ -11528,11 +11569,6 @@ case WM_SYSCOLORCHANGE: COMCTL32_RefreshSysColors(); - if (infoPtr->bDefaultBkColor) - { - LISTVIEW_SetBkColor(infoPtr, comctl32_color.clrWindow); - infoPtr->bDefaultBkColor = TRUE; - } return 0; /* case WM_TIMER: */ Modified: branches/GSoC_2011/ThemesSupport/dll/win32/comctl32/monthcal.c URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/ThemesSupport/dll/win…
============================================================================== --- branches/GSoC_2011/ThemesSupport/dll/win32/comctl32/monthcal.c [iso-8859-1] (original) +++ branches/GSoC_2011/ThemesSupport/dll/win32/comctl32/monthcal.c [iso-8859-1] Sun Jul 17 15:16:59 2011 @@ -6,7 +6,7 @@ * Copyright 1999 Chris Morgan <cmorgan(a)wpi.edu> and * James Abbatiello <abbeyj(a)wpi.edu> * Copyright 2000 Uwe Bonnes <bon(a)elektron.ikp.physik.tu-darmstadt.de> - * Copyright 2009, 2010 Nikolay Sivov + * Copyright 2009-2011 Nikolay Sivov * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -33,7 +33,6 @@ * * TODO: * -- MCM_[GS]ETUNICODEFORMAT - * -- MONTHCAL_GetMonthRange * -- handle resources better (doesn't work now); * -- take care of internationalization. * -- keyboard handling. @@ -77,6 +76,21 @@ /* convert from days to 100 nanoseconds unit - used as FILETIME unit */ #define DAYSTO100NSECS(days) (((ULONGLONG)(days))*24*60*60*10000000) +enum CachedPen +{ + PenRed = 0, + PenText, + PenLast +}; + +enum CachedBrush +{ + BrushTitle = 0, + BrushMonth, + BrushBackground, + BrushLast +}; + /* single calendar data */ typedef struct _CALENDAR_INFO { @@ -96,6 +110,8 @@ DWORD dwStyle; /* cached GWL_STYLE */ COLORREF colors[MCSC_TRAILINGTEXT+1]; + HBRUSH brushes[BrushLast]; + HPEN pens[PenLast]; HFONT hFont; HFONT hBoldFont; @@ -143,8 +159,8 @@ /* empty SYSTEMTIME const */ static const SYSTEMTIME st_null; /* valid date limits */ -static const SYSTEMTIME max_allowed_date = { 9999, 12, 0, 31, 0, 0, 0, 0 }; -static const SYSTEMTIME min_allowed_date = { 1752, 9, 0, 14, 0, 0, 0, 0 }; +static const SYSTEMTIME max_allowed_date = { .wYear = 9999, .wMonth = 12, .wDay = 31 }; +static const SYSTEMTIME min_allowed_date = { .wYear = 1752, .wMonth = 9, .wDay = 14 }; /* Prev/Next buttons */ enum nav_direction @@ -449,7 +465,7 @@ return st.wDayOfWeek; } -/* add/substract 'months' from date */ +/* add/subtract 'months' from date */ static inline void MONTHCAL_GetMonth(SYSTEMTIME *date, INT months) { INT length, m = date->wMonth + months; @@ -636,28 +652,31 @@ return TRUE; } +/* draw today boundary box for specified rectangle */ +static void MONTHCAL_Circle(const MONTHCAL_INFO *infoPtr, HDC hdc, const RECT *r) +{ + HPEN old_pen = SelectObject(hdc, infoPtr->pens[PenRed]); + HBRUSH old_brush; + + old_brush = SelectObject(hdc, GetStockObject(NULL_BRUSH)); + Rectangle(hdc, r->left, r->top, r->right, r->bottom); + + SelectObject(hdc, old_brush); + SelectObject(hdc, old_pen); +} + /* Draw today day mark rectangle * - * [I] hdc : context to draw in - * [I] day : day to mark with rectangle + * [I] hdc : context to draw in + * [I] date : day to mark with rectangle * */ static void MONTHCAL_CircleDay(const MONTHCAL_INFO *infoPtr, HDC hdc, const SYSTEMTIME *date) { - HPEN hRedPen = CreatePen(PS_SOLID, 1, RGB(255, 0, 0)); - HPEN hOldPen2 = SelectObject(hdc, hRedPen); - HBRUSH hOldBrush; RECT day_rect; - MONTHCAL_CalcPosFromDay(infoPtr, date, &day_rect); - - hOldBrush = SelectObject(hdc, GetStockObject(NULL_BRUSH)); - Rectangle(hdc, day_rect.left, day_rect.top, day_rect.right, day_rect.bottom); - - SelectObject(hdc, hOldBrush); - DeleteObject(hRedPen); - SelectObject(hdc, hOldPen2); + MONTHCAL_Circle(infoPtr, hdc, &day_rect); } static void MONTHCAL_DrawDay(const MONTHCAL_INFO *infoPtr, HDC hdc, const SYSTEMTIME *st, @@ -666,46 +685,39 @@ static const WCHAR fmtW[] = { '%','d',0 }; WCHAR buf[10]; RECT r, r_temp; - static BOOL bold_selected; - BOOL selected_day = FALSE; - HBRUSH hbr; COLORREF oldCol = 0; COLORREF oldBk = 0; - -/* No need to check styles: when selection is not valid, it is set to zero. - * 1<day<31, so everything is OK. - */ - + INT old_bkmode, selection; + + /* no need to check styles: when selection is not valid, it is set to zero. + 1 < day < 31, so everything is OK */ MONTHCAL_CalcPosFromDay(infoPtr, st, &r); if(!IntersectRect(&r_temp, &(ps->rcPaint), &r)) return; if ((MONTHCAL_CompareDate(st, &infoPtr->minSel) >= 0) && - (MONTHCAL_CompareDate(st, &infoPtr->maxSel) <= 0)) { + (MONTHCAL_CompareDate(st, &infoPtr->maxSel) <= 0)) + { TRACE("%d %d %d\n", st->wDay, infoPtr->minSel.wDay, infoPtr->maxSel.wDay); TRACE("%s\n", wine_dbgstr_rect(&r)); oldCol = SetTextColor(hdc, infoPtr->colors[MCSC_MONTHBK]); oldBk = SetBkColor(hdc, infoPtr->colors[MCSC_TRAILINGTEXT]); - hbr = GetSysColorBrush(COLOR_HIGHLIGHT); - FillRect(hdc, &r, hbr); - - selected_day = TRUE; - } - - if(bold && !bold_selected) { - SelectObject(hdc, infoPtr->hBoldFont); - bold_selected = TRUE; - } - if(!bold && bold_selected) { - SelectObject(hdc, infoPtr->hFont); - bold_selected = FALSE; - } - - SetBkMode(hdc,TRANSPARENT); + FillRect(hdc, &r, infoPtr->brushes[BrushTitle]); + + selection = 1; + } + else + selection = 0; + + SelectObject(hdc, bold ? infoPtr->hBoldFont : infoPtr->hFont); + + old_bkmode = SetBkMode(hdc, TRANSPARENT); wsprintfW(buf, fmtW, st->wDay); DrawTextW(hdc, buf, -1, &r, DT_CENTER | DT_VCENTER | DT_SINGLELINE ); - - if(selected_day) { + SetBkMode(hdc, old_bkmode); + + if (selection) + { SetTextColor(hdc, oldCol); SetBkColor(hdc, oldBk); } @@ -755,13 +767,10 @@ RECT *title = &infoPtr->calendars[calIdx].title; const SYSTEMTIME *st = &infoPtr->calendars[calIdx].month; WCHAR buf_month[80], buf_fmt[80]; - HBRUSH hbr; SIZE sz; /* fill header box */ - hbr = CreateSolidBrush(infoPtr->colors[MCSC_TITLEBK]); - FillRect(hdc, title, hbr); - DeleteObject(hbr); + FillRect(hdc, title, infoPtr->brushes[BrushTitle]); /* month/year string */ SetBkColor(hdc, infoPtr->colors[MCSC_TITLEBK]); @@ -793,7 +802,7 @@ INT i, prev_month; SYSTEMTIME st; WCHAR buf[80]; - HBRUSH hbr; + HPEN old_pen; RECT r; if (!(infoPtr->dwStyle & MCS_WEEKNUMBERS)) return; @@ -865,9 +874,8 @@ r = infoPtr->calendars[calIdx].weeknums; /* erase whole week numbers area */ - hbr = CreateSolidBrush(infoPtr->colors[MCSC_MONTHBK]); - FillRect(hdc, &r, hbr); - DeleteObject(hbr); + FillRect(hdc, &r, infoPtr->brushes[BrushTitle]); + SetTextColor(hdc, infoPtr->colors[MCSC_TITLEBK]); /* reduce rectangle to one week number */ r.bottom = r.top + infoPtr->height_increment; @@ -890,43 +898,50 @@ } /* line separator for week numbers column */ + old_pen = SelectObject(hdc, infoPtr->pens[PenText]); MoveToEx(hdc, infoPtr->calendars[calIdx].weeknums.right, infoPtr->calendars[calIdx].weeknums.top + 3 , NULL); LineTo(hdc, infoPtr->calendars[calIdx].weeknums.right, infoPtr->calendars[calIdx].weeknums.bottom); + SelectObject(hdc, old_pen); } /* bottom today date */ static void MONTHCAL_PaintTodayTitle(const MONTHCAL_INFO *infoPtr, HDC hdc, const PAINTSTRUCT *ps) { - if(!(infoPtr->dwStyle & MCS_NOTODAY)) { + static const WCHAR fmt_todayW[] = { '%','s',' ','%','s',0 }; + WCHAR buf_todayW[30], buf_dateW[20], buf[80]; + RECT text_rect, box_rect; + HFONT old_font; + INT col; + + if(infoPtr->dwStyle & MCS_NOTODAY) return; + + if (!LoadStringW(COMCTL32_hModule, IDM_TODAY, buf_todayW, countof(buf_todayW))) + { static const WCHAR todayW[] = { 'T','o','d','a','y',':',0 }; - static const WCHAR fmt_todayW[] = { '%','s',' ','%','s',0 }; - WCHAR buf_todayW[30], buf_dateW[20], buf[80]; - RECT rtoday; - - if(!(infoPtr->dwStyle & MCS_NOTODAYCIRCLE)) { - SYSTEMTIME fake_st; - - MONTHCAL_GetMaxDate(infoPtr, &fake_st); - /* this is always safe cause next month will never fully fit calendar */ - fake_st.wDay += 1; - MONTHCAL_CircleDay(infoPtr, hdc, &fake_st); - } - if (!LoadStringW(COMCTL32_hModule, IDM_TODAY, buf_todayW, countof(buf_todayW))) - { - WARN("Can't load resource\n"); - strcpyW(buf_todayW, todayW); - } - MONTHCAL_CalcDayRect(infoPtr, &rtoday, 1, 6); - GetDateFormatW(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &infoPtr->todaysDate, NULL, - buf_dateW, countof(buf_dateW)); - SelectObject(hdc, infoPtr->hBoldFont); - - wsprintfW(buf, fmt_todayW, buf_todayW, buf_dateW); - DrawTextW(hdc, buf, -1, &rtoday, DT_CALCRECT | DT_LEFT | DT_VCENTER | DT_SINGLELINE); - DrawTextW(hdc, buf, -1, &rtoday, DT_LEFT | DT_VCENTER | DT_SINGLELINE); - - SelectObject(hdc, infoPtr->hFont); - } + WARN("Can't load resource\n"); + strcpyW(buf_todayW, todayW); + } + + col = infoPtr->dwStyle & MCS_NOTODAYCIRCLE ? 0 : 1; + if (infoPtr->dwStyle & MCS_WEEKNUMBERS) col--; + MONTHCAL_CalcDayRect(infoPtr, &text_rect, col, 6); + box_rect = text_rect; + + GetDateFormatW(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &infoPtr->todaysDate, NULL, + buf_dateW, countof(buf_dateW)); + old_font = SelectObject(hdc, infoPtr->hBoldFont); + SetTextColor(hdc, infoPtr->colors[MCSC_TEXT]); + + wsprintfW(buf, fmt_todayW, buf_todayW, buf_dateW); + DrawTextW(hdc, buf, -1, &text_rect, DT_CALCRECT | DT_LEFT | DT_VCENTER | DT_SINGLELINE); + DrawTextW(hdc, buf, -1, &text_rect, DT_LEFT | DT_VCENTER | DT_SINGLELINE); + + if(!(infoPtr->dwStyle & MCS_NOTODAYCIRCLE)) { + OffsetRect(&box_rect, -infoPtr->width_increment, 0); + MONTHCAL_Circle(infoPtr, hdc, &box_rect); + } + + SelectObject(hdc, old_font); } /* today mark + focus */ @@ -947,15 +962,53 @@ } } +/* months before first calendar month and after last calendar month */ +static void MONTHCAL_PaintLeadTrailMonths(const MONTHCAL_INFO *infoPtr, HDC hdc, const PAINTSTRUCT *ps) +{ + INT mask, length; + SYSTEMTIME st_max, st; + + if (infoPtr->dwStyle & MCS_NOTRAILINGDATES) return; + + SetTextColor(hdc, infoPtr->colors[MCSC_TRAILINGTEXT]); + + /* draw prev month */ + MONTHCAL_GetMinDate(infoPtr, &st); + mask = 1 << (st.wDay-1); + /* December and January both 31 days long, so no worries if wrapped */ + length = MONTHCAL_MonthLength(infoPtr->calendars[0].month.wMonth - 1, + infoPtr->calendars[0].month.wYear); + while(st.wDay <= length) + { + MONTHCAL_DrawDay(infoPtr, hdc, &st, infoPtr->monthdayState[0] & mask, ps); + mask <<= 1; + st.wDay++; + } + + /* draw next month */ + st = infoPtr->calendars[infoPtr->cal_num-1].month; + st.wDay = 1; + MONTHCAL_GetNextMonth(&st); + MONTHCAL_GetMaxDate(infoPtr, &st_max); + mask = 1; + + while(st.wDay <= st_max.wDay) + { + MONTHCAL_DrawDay(infoPtr, hdc, &st, infoPtr->monthdayState[2] & mask, ps); + mask <<= 1; + st.wDay++; + } +} + /* paint a calendar area */ static void MONTHCAL_PaintCalendar(const MONTHCAL_INFO *infoPtr, HDC hdc, const PAINTSTRUCT *ps, INT calIdx) { const SYSTEMTIME *date = &infoPtr->calendars[calIdx].month; - INT prev_month, i, j, length; + INT i, j, length; RECT r, fill_bk_rect; SYSTEMTIME st; WCHAR buf[80]; - HBRUSH hbr; + HPEN old_pen; int mask; /* fill whole days area - from week days area to today note rectangle */ @@ -963,26 +1016,23 @@ fill_bk_rect.bottom = infoPtr->calendars[calIdx].days.bottom + (infoPtr->todayrect.bottom - infoPtr->todayrect.top); - hbr = CreateSolidBrush(infoPtr->colors[MCSC_MONTHBK]); - FillRect(hdc, &fill_bk_rect, hbr); - DeleteObject(hbr); + FillRect(hdc, &fill_bk_rect, infoPtr->brushes[BrushMonth]); /* draw line under day abbreviations */ + old_pen = SelectObject(hdc, infoPtr->pens[PenText]); MoveToEx(hdc, infoPtr->calendars[calIdx].days.left + 3, infoPtr->calendars[calIdx].title.bottom + infoPtr->textHeight + 1, NULL); LineTo(hdc, infoPtr->calendars[calIdx].days.right - 3, infoPtr->calendars[calIdx].title.bottom + infoPtr->textHeight + 1); - - prev_month = date->wMonth - 1; - if (prev_month == 0) prev_month = 12; + SelectObject(hdc, old_pen); infoPtr->calendars[calIdx].wdays.left = infoPtr->calendars[calIdx].days.left = infoPtr->calendars[calIdx].weeknums.right; - /* 1. draw day abbreviations */ + /* draw day abbreviations */ SelectObject(hdc, infoPtr->hFont); SetBkColor(hdc, infoPtr->colors[MCSC_MONTHBK]); - SetTextColor(hdc, infoPtr->colors[MCSC_TRAILINGTEXT]); + SetTextColor(hdc, infoPtr->colors[MCSC_TITLEBK]); /* rectangle to draw a single day abbreviation within */ r = infoPtr->calendars[calIdx].wdays; r.right = r.left + infoPtr->width_increment; @@ -994,47 +1044,7 @@ OffsetRect(&r, infoPtr->width_increment, 0); } - /* 2. previous and next months */ - if (!(infoPtr->dwStyle & MCS_NOTRAILINGDATES) && (calIdx == 0 || calIdx == infoPtr->cal_num - 1)) - { - SYSTEMTIME st_max; - - SetTextColor(hdc, infoPtr->colors[MCSC_TRAILINGTEXT]); - - /* draw prev month */ - if (calIdx == 0) - { - MONTHCAL_GetMinDate(infoPtr, &st); - mask = 1 << (st.wDay-1); - length = MONTHCAL_MonthLength(prev_month, date->wYear); - - while(st.wDay <= length) - { - MONTHCAL_DrawDay(infoPtr, hdc, &st, infoPtr->monthdayState[0] & mask, ps); - mask <<= 1; - st.wDay++; - } - } - - /* draw next month */ - if (calIdx == infoPtr->cal_num - 1) - { - st = *date; - st.wDay = 1; - MONTHCAL_GetNextMonth(&st); - MONTHCAL_GetMaxDate(infoPtr, &st_max); - mask = 1; - - while(st.wDay <= st_max.wDay) - { - MONTHCAL_DrawDay(infoPtr, hdc, &st, infoPtr->monthdayState[2] & mask, ps); - mask <<= 1; - st.wDay++; - } - } - } - - /* 3. current month */ + /* draw current month */ SetTextColor(hdc, infoPtr->colors[MCSC_TEXT]); st = *date; st.wDay = 1; @@ -1076,6 +1086,9 @@ MONTHCAL_PaintWeeknumbers(infoPtr, hdc, ps, i); } + /* partially visible months */ + MONTHCAL_PaintLeadTrailMonths(infoPtr, hdc, ps); + /* focus and today rectangle */ MONTHCAL_PaintFocusAndCircle(infoPtr, hdc, ps); @@ -1125,6 +1138,7 @@ static LRESULT MONTHCAL_SetColor(MONTHCAL_INFO *infoPtr, UINT index, COLORREF color) { + enum CachedBrush type; COLORREF prev; TRACE("%p, %d: color %08x\n", infoPtr, index, color); @@ -1133,6 +1147,35 @@ prev = infoPtr->colors[index]; infoPtr->colors[index] = color; + + /* update cached brush */ + switch (index) + { + case MCSC_BACKGROUND: + type = BrushBackground; + break; + case MCSC_TITLEBK: + type = BrushTitle; + break; + case MCSC_MONTHBK: + type = BrushMonth; + break; + default: + type = BrushLast; + } + + if (type != BrushLast) + { + DeleteObject(infoPtr->brushes[type]); + infoPtr->brushes[type] = CreateSolidBrush(color); + } + + /* update cached pen */ + if (index == MCSC_TEXT) + { + DeleteObject(infoPtr->pens[PenText]); + infoPtr->pens[PenText] = CreatePen(PS_SOLID, 1, infoPtr->colors[index]); + } InvalidateRect(infoPtr->hwndSelf, NULL, index == MCSC_BACKGROUND ? TRUE : FALSE); return prev; @@ -1265,8 +1308,6 @@ } case GMR_DAYSTATE: { - /*FIXME: currently multicalendar feature isn't implemented, - min date from previous month and max date from next one returned */ MONTHCAL_GetMinDate(infoPtr, &st[0]); MONTHCAL_GetMaxDate(infoPtr, &st[1]); break; @@ -1727,7 +1768,7 @@ { htinfo.uHit = MCHT_CALENDARDATEPREV; MONTHCAL_GetPrevMonth(&htinfo.st); - htinfo.st.wDay = MONTHCAL_MonthLength(lpht->st.wMonth, lpht->st.wYear) + day; + htinfo.st.wDay = MONTHCAL_MonthLength(htinfo.st.wMonth, htinfo.st.wYear) + day; } else if (day > MONTHCAL_MonthLength(ht_month.wMonth, ht_month.wYear)) { @@ -2237,15 +2278,11 @@ static LRESULT MONTHCAL_EraseBkgnd(const MONTHCAL_INFO *infoPtr, HDC hdc) { - HBRUSH hbr; RECT rc; if (!GetClipBox(hdc, &rc)) return FALSE; - /* fill background */ - hbr = CreateSolidBrush (infoPtr->colors[MCSC_BACKGROUND]); - FillRect(hdc, &rc, hbr); - DeleteObject(hbr); + FillRect(hdc, &rc, infoPtr->brushes[BrushBackground]); return TRUE; } @@ -2520,7 +2557,7 @@ MONTHCAL_SetFont(infoPtr, GetStockObject(DEFAULT_GUI_FONT), FALSE); /* initialize info structure */ - /* FIXME: calculate systemtime ->> localtime(substract timezoneinfo) */ + /* FIXME: calculate systemtime ->> localtime(subtract timezoneinfo) */ GetLocalTime(&infoPtr->todaysDate); MONTHCAL_SetFirstDayOfWeek(infoPtr, -1); @@ -2538,6 +2575,13 @@ infoPtr->colors[MCSC_MONTHBK] = comctl32_color.clrWindow; infoPtr->colors[MCSC_TRAILINGTEXT] = comctl32_color.clrGrayText; + infoPtr->brushes[BrushBackground] = CreateSolidBrush(infoPtr->colors[MCSC_BACKGROUND]); + infoPtr->brushes[BrushTitle] = CreateSolidBrush(infoPtr->colors[MCSC_TITLEBK]); + infoPtr->brushes[BrushMonth] = CreateSolidBrush(infoPtr->colors[MCSC_MONTHBK]); + + infoPtr->pens[PenRed] = CreatePen(PS_SOLID, 1, RGB(255, 0, 0)); + infoPtr->pens[PenText] = CreatePen(PS_SOLID, 1, infoPtr->colors[MCSC_TEXT]); + infoPtr->minSel = infoPtr->todaysDate; infoPtr->maxSel = infoPtr->todaysDate; infoPtr->calendars[0].month = infoPtr->todaysDate; @@ -2564,13 +2608,18 @@ static LRESULT MONTHCAL_Destroy(MONTHCAL_INFO *infoPtr) { + INT i; + /* free month calendar info data */ Free(infoPtr->monthdayState); Free(infoPtr->calendars); SetWindowLongPtrW(infoPtr->hwndSelf, 0, 0); CloseThemeData (GetWindowTheme (infoPtr->hwndSelf)); - + + for (i = 0; i < BrushLast; i++) DeleteObject(infoPtr->brushes[i]); + for (i = 0; i < PenLast; i++) DeleteObject(infoPtr->pens[i]); + Free(infoPtr); return 0; } Modified: branches/GSoC_2011/ThemesSupport/dll/win32/comctl32/propsheet.c URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/ThemesSupport/dll/win…
============================================================================== --- branches/GSoC_2011/ThemesSupport/dll/win32/comctl32/propsheet.c [iso-8859-1] (original) +++ branches/GSoC_2011/ThemesSupport/dll/win32/comctl32/propsheet.c [iso-8859-1] Sun Jul 17 15:16:59 2011 @@ -2490,7 +2490,7 @@ { SendMessageW(hwndDlg, DM_SETDEFID, IDC_FINISH_BUTTON, 0); SetFocus(hwndFinish); - } +} else if (dwFlags & PSWIZB_NEXT) { SendMessageW(hwndDlg, DM_SETDEFID, IDC_NEXT_BUTTON, 0); Modified: branches/GSoC_2011/ThemesSupport/dll/win32/comctl32/status.c URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/ThemesSupport/dll/win…
============================================================================== --- branches/GSoC_2011/ThemesSupport/dll/win32/comctl32/status.c [iso-8859-1] (original) +++ branches/GSoC_2011/ThemesSupport/dll/win32/comctl32/status.c [iso-8859-1] Sun Jul 17 15:16:59 2011 @@ -661,9 +661,11 @@ STATUSBAR_SetParts (STATUS_INFO *infoPtr, INT count, LPINT parts) { STATUSWINDOWPART *tmp; - UINT i, oldNumParts; + INT i, oldNumParts; TRACE("(%d,%p)\n", count, parts); + + if(!count) return FALSE; oldNumParts = infoPtr->numParts; infoPtr->numParts = count; @@ -693,7 +695,7 @@ infoPtr->parts[i].x = parts[i]; if (infoPtr->hwndToolTip) { - UINT nTipCount; + INT nTipCount; TTTOOLINFOW ti; ZeroMemory (&ti, sizeof(TTTOOLINFOW)); Modified: branches/GSoC_2011/ThemesSupport/dll/win32/comctl32/syslink.c URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/ThemesSupport/dll/win…
============================================================================== --- branches/GSoC_2011/ThemesSupport/dll/win32/comctl32/syslink.c [iso-8859-1] (original) +++ branches/GSoC_2011/ThemesSupport/dll/win32/comctl32/syslink.c [iso-8859-1] Sun Jul 17 15:16:59 2011 @@ -529,7 +529,7 @@ while(Current != NULL) { - if((Current->Type == slLink)) + if(Current->Type == slLink) { if(Current->u.Link.state & LIS_FOCUSED) { @@ -1564,7 +1564,7 @@ infoPtr = (SYSLINK_INFO *)GetWindowLongPtrW(hwnd, 0); if (!infoPtr && message != WM_CREATE) - goto HandleDefaultMessage; + return DefWindowProcW(hwnd, message, wParam, lParam); switch(message) { case WM_PRINTCLIENT: @@ -1588,8 +1588,8 @@ SetCursor(LoadCursorW(0, (LPCWSTR)IDC_HAND)); return TRUE; } - /* let the default window proc handle this message */ - goto HandleDefaultMessage; + + return DefWindowProcW(hwnd, message, wParam, lParam); } case WM_SIZE: @@ -1615,7 +1615,7 @@ case WM_SETTEXT: SYSLINK_SetText(infoPtr, (LPWSTR)lParam); - goto HandleDefaultMessage; + return DefWindowProcW(hwnd, message, wParam, lParam); case WM_LBUTTONDOWN: { @@ -1645,8 +1645,9 @@ SYSKEY_SelectNextPrevLink(infoPtr, shift); return 0; } - } - goto HandleDefaultMessage; + default: + return DefWindowProcW(hwnd, message, wParam, lParam); + } } case WM_GETDLGCODE: @@ -1777,7 +1778,6 @@ return 0; default: -HandleDefaultMessage: if ((message >= WM_USER) && (message < WM_APP) && !COMCTL32_IsReflectedMessage(message)) { ERR("unknown msg %04x wp=%04lx lp=%08lx\n", message, wParam, lParam ); Modified: branches/GSoC_2011/ThemesSupport/dll/win32/comctl32/tab.c URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/ThemesSupport/dll/win…
============================================================================== --- branches/GSoC_2011/ThemesSupport/dll/win32/comctl32/tab.c [iso-8859-1] (original) +++ branches/GSoC_2011/ThemesSupport/dll/win32/comctl32/tab.c [iso-8859-1] Sun Jul 17 15:16:59 2011 @@ -52,6 +52,7 @@ * */ +#include <assert.h> #include <stdarg.h> #include <string.h> @@ -110,7 +111,6 @@ INT iSelected; /* the currently selected item */ INT iHotTracked; /* the highlighted item under the mouse */ INT uFocus; /* item which has the focus */ - TAB_ITEM* items; /* pointer to an array of TAB_ITEM's */ BOOL DoRedraw; /* flag for redrawing when tab contents is changed*/ BOOL needsScrolling; /* TRUE if the size of the tabs is greater than * the size of the control */ @@ -122,6 +122,8 @@ DWORD exStyle; /* Extended style used, currently: TCS_EX_FLATSEPARATORS, TCS_EX_REGISTERDROP */ DWORD dwStyle; /* the cached window GWL_STYLE */ + + HDPA items; /* dynamic array of TAB_ITEM* pointers */ } TAB_INFO; /****************************************************************************** @@ -141,9 +143,6 @@ #define EXTRA_ICON_PADDING 3 #define TAB_GetInfoPtr(hwnd) ((TAB_INFO *)GetWindowLongPtrW(hwnd,0)) -/* Since items are variable sized, cannot directly access them */ -#define TAB_GetItem(info,i) \ - ((TAB_ITEM*)((LPBYTE)info->items + (i) * TAB_ITEM_SIZE(info))) #define GET_DEFAULT_MIN_TAB_WIDTH(infoPtr) (DEFAULT_MIN_TAB_WIDTH - (DEFAULT_PADDING_X - (infoPtr)->uHItemPadding) * 2) @@ -154,6 +153,12 @@ #define TAB_HOTTRACK_TIMER_INTERVAL 100 /* milliseconds */ static const WCHAR themeClass[] = { 'T','a','b',0 }; + +static inline TAB_ITEM* TAB_GetItem(const TAB_INFO *infoPtr, INT i) +{ + assert(i >= 0 && i < infoPtr->uNumItem); + return DPA_GetPtr(infoPtr->items, i); +} /****************************************************************************** * Prototypes @@ -209,9 +214,8 @@ TAB_DumpItemInternal(const TAB_INFO *infoPtr, UINT iItem) { if (TRACE_ON(tab)) { - TAB_ITEM *ti; - - ti = TAB_GetItem(infoPtr, iItem); + TAB_ITEM *ti = TAB_GetItem(infoPtr, iItem); + TRACE("tab %d, dwState=0x%08x, pszText=%s, iImage=%d\n", iItem, ti->dwState, debugstr_w(ti->pszText), ti->iImage); TRACE("tab %d, rect.left=%d, rect.top(row)=%d\n", @@ -702,11 +706,10 @@ return 0; } -static inline LRESULT -TAB_RButtonDown (const TAB_INFO *infoPtr) +static inline void +TAB_RButtonUp (const TAB_INFO *infoPtr) { TAB_SendSimpleNotify(infoPtr, NM_RCLICK); - return 0; } /****************************************************************************** @@ -1766,6 +1769,7 @@ { /* this could be considered broken on 64 bit, but that's how it works - only first 4 bytes are copied */ + dis.itemData = 0; memcpy(&dis.itemData, (ULONG_PTR*)TAB_GetItem(infoPtr, iItem)->extra, 4); } @@ -2113,9 +2117,10 @@ partIndex += 4; /* The part also differs on the position of a tab on a line. * "Visually" determining the position works well enough. */ + GetClientRect(infoPtr->hwnd, &r1); if(selectedRect.left == 0) partIndex += 1; - if(selectedRect.right == clRight) + if(selectedRect.right == r1.right) partIndex += 2; if (iItem == infoPtr->iSelected) @@ -2436,6 +2441,9 @@ INT iSelected = infoPtr->iSelected; INT iOrigLeftmostVisible = infoPtr->leftmostVisible; + if (iSelected < 0) + return; + /* set the items row to the bottommost row or topmost row depending on * style */ if ((infoPtr->uNumRows > 1) && !(infoPtr->dwStyle & TCS_BUTTONS)) @@ -2640,42 +2648,21 @@ TAB_DumpItemExternalT(pti, iItem, bUnicode); - - if (infoPtr->uNumItem == 0) { - infoPtr->items = Alloc (TAB_ITEM_SIZE(infoPtr)); - infoPtr->uNumItem++; - infoPtr->iSelected = 0; - } - else { - LPBYTE oldItems = (LPBYTE)infoPtr->items; - - infoPtr->uNumItem++; - infoPtr->items = Alloc (TAB_ITEM_SIZE(infoPtr) * infoPtr->uNumItem); - - /* pre insert copy */ - if (iItem > 0) { - memcpy (infoPtr->items, oldItems, - iItem * TAB_ITEM_SIZE(infoPtr)); - } - - /* post insert copy */ - if (iItem < infoPtr->uNumItem - 1) { - memcpy (TAB_GetItem(infoPtr, iItem + 1), - oldItems + iItem * TAB_ITEM_SIZE(infoPtr), - (infoPtr->uNumItem - iItem - 1) * TAB_ITEM_SIZE(infoPtr)); - - } - - if (iItem <= infoPtr->iSelected) + if (!(item = Alloc(TAB_ITEM_SIZE(infoPtr)))) return FALSE; + if (DPA_InsertPtr(infoPtr->items, iItem, item) == -1) + { + Free(item); + return FALSE; + } + + if (infoPtr->uNumItem == 0) + infoPtr->iSelected = 0; + else if (iItem <= infoPtr->iSelected) infoPtr->iSelected++; - Free (oldItems); - } - - item = TAB_GetItem(infoPtr, iItem); + infoPtr->uNumItem++; item->pszText = NULL; - if (pti->mask & TCIF_TEXT) { if (bUnicode) @@ -2885,64 +2872,49 @@ static LRESULT TAB_DeleteItem (TAB_INFO *infoPtr, INT iItem) { - BOOL bResult = FALSE; + TAB_ITEM *item; TRACE("(%p, %d)\n", infoPtr, iItem); - if ((iItem >= 0) && (iItem < infoPtr->uNumItem)) - { - TAB_ITEM *item = TAB_GetItem(infoPtr, iItem); - LPBYTE oldItems = (LPBYTE)infoPtr->items; - - TAB_InvalidateTabArea(infoPtr); - Free(item->pszText); - infoPtr->uNumItem--; - - if (!infoPtr->uNumItem) + if (iItem < 0 || iItem >= infoPtr->uNumItem) return FALSE; + + item = TAB_GetItem(infoPtr, iItem); + Free(item->pszText); + Free(item); + infoPtr->uNumItem--; + DPA_DeletePtr(infoPtr->items, iItem); + + TAB_InvalidateTabArea(infoPtr); + + if (infoPtr->uNumItem == 0) + { + if (infoPtr->iHotTracked >= 0) { - infoPtr->items = NULL; - if (infoPtr->iHotTracked >= 0) - { - KillTimer(infoPtr->hwnd, TAB_HOTTRACK_TIMER); - infoPtr->iHotTracked = -1; - } + KillTimer(infoPtr->hwnd, TAB_HOTTRACK_TIMER); + infoPtr->iHotTracked = -1; } - else - { - infoPtr->items = Alloc(TAB_ITEM_SIZE(infoPtr) * infoPtr->uNumItem); - - if (iItem > 0) - memcpy(infoPtr->items, oldItems, iItem * TAB_ITEM_SIZE(infoPtr)); - - if (iItem < infoPtr->uNumItem) - memcpy(TAB_GetItem(infoPtr, iItem), - oldItems + (iItem + 1) * TAB_ITEM_SIZE(infoPtr), - (infoPtr->uNumItem - iItem) * TAB_ITEM_SIZE(infoPtr)); - - if (iItem <= infoPtr->iHotTracked) - { - /* When tabs move left/up, the hot track item may change */ - FIXME("Recalc hot track\n"); - } - } - Free(oldItems); - - /* Readjust the selected index */ - if (iItem == infoPtr->iSelected) - infoPtr->iSelected = -1; - else if (iItem < infoPtr->iSelected) - infoPtr->iSelected--; - - if (infoPtr->uNumItem == 0) - infoPtr->iSelected = -1; - - /* Reposition and repaint tabs */ - TAB_SetItemBounds(infoPtr); - - bResult = TRUE; - } - - return bResult; + + infoPtr->iSelected = -1; + } + else + { + if (iItem <= infoPtr->iHotTracked) + { + /* When tabs move left/up, the hot track item may change */ + FIXME("Recalc hot track\n"); + } + } + + /* adjust the selected index */ + if (iItem == infoPtr->iSelected) + infoPtr->iSelected = -1; + else if (iItem < infoPtr->iSelected) + infoPtr->iSelected--; + + /* reposition and repaint tabs */ + TAB_SetItemBounds(infoPtr); + + return TRUE; } static inline LRESULT TAB_DeleteAllItems (TAB_INFO *infoPtr) @@ -3063,7 +3035,7 @@ infoPtr->uHItemPadding_s = 6; infoPtr->uVItemPadding_s = 3; infoPtr->hFont = 0; - infoPtr->items = 0; + infoPtr->items = DPA_Create(8); infoPtr->hcurArrow = LoadCursorW (0, (LPWSTR)IDC_ARROW); infoPtr->iSelected = -1; infoPtr->iHotTracked = -1; @@ -3147,16 +3119,22 @@ static LRESULT TAB_Destroy (TAB_INFO *infoPtr) { - UINT iItem; + INT iItem; SetWindowLongPtrW(infoPtr->hwnd, 0, 0); - if (infoPtr->items) { - for (iItem = 0; iItem < infoPtr->uNumItem; iItem++) { - Free (TAB_GetItem(infoPtr, iItem)->pszText); - } - Free (infoPtr->items); - } + for (iItem = infoPtr->uNumItem - 1; iItem >= 0; iItem--) + { + TAB_ITEM *tab = TAB_GetItem(infoPtr, iItem); + + DPA_DeletePtr(infoPtr->items, iItem); + infoPtr->uNumItem--; + + Free(tab->pszText); + Free(tab); + } + DPA_Destroy(infoPtr->items); + infoPtr->items = NULL; if (infoPtr->hwndToolTip) DestroyWindow (infoPtr->hwndToolTip); @@ -3450,8 +3428,9 @@ case WM_NOTIFY: return SendMessageW(infoPtr->hwndNotify, WM_NOTIFY, wParam, lParam); - case WM_RBUTTONDOWN: - return TAB_RButtonDown (infoPtr); + case WM_RBUTTONUP: + TAB_RButtonUp (infoPtr); + return DefWindowProcW (hwnd, uMsg, wParam, lParam); case WM_MOUSEMOVE: return TAB_MouseMove (infoPtr, wParam, lParam); Modified: branches/GSoC_2011/ThemesSupport/dll/win32/comctl32/theme_button.c URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/ThemesSupport/dll/win…
============================================================================== --- branches/GSoC_2011/ThemesSupport/dll/win32/comctl32/theme_button.c [iso-8859-1] (original) +++ branches/GSoC_2011/ThemesSupport/dll/win32/comctl32/theme_button.c [iso-8859-1] Sun Jul 17 15:16:59 2011 @@ -246,18 +246,26 @@ DWORD dwStyle = GetWindowLongW(hwnd, GWL_STYLE); DWORD dwStyleEx = GetWindowLongW(hwnd, GWL_EXSTYLE); UINT dtFlags = get_drawtext_flags(dwStyle, dwStyleEx); - ButtonState drawState = IsWindowEnabled(hwnd) ? STATE_NORMAL : STATE_DISABLED; + int state = (int)SendMessageW(hwnd, BM_GETSTATE, 0, 0); + ButtonState drawState; pfThemedPaint paint = btnThemedPaintFunc[ dwStyle & BUTTON_TYPE ]; - if (paint) - { - hDC = hParamDC ? hParamDC : BeginPaint(hwnd, &ps); - paint(theme, hwnd, hDC, drawState, dtFlags); - if (!hParamDC) EndPaint(hwnd, &ps); - return TRUE; - } - - return FALSE; /* Delegate drawing to the non-themed code. */ + if(!paint) + return FALSE; + + if(IsWindowEnabled(hwnd)) + { + if(state & BST_PUSHED) drawState = STATE_PRESSED; + else if(state & BST_HOT) drawState = STATE_HOT; + else if(state & BST_FOCUS) drawState = STATE_DEFAULTED; + else drawState = STATE_NORMAL; + } + else drawState = STATE_DISABLED; + + hDC = hParamDC ? hParamDC : BeginPaint(hwnd, &ps); + paint(theme, hwnd, hDC, drawState, dtFlags); + if (!hParamDC) EndPaint(hwnd, &ps); + return TRUE; } /********************************************************************** @@ -309,6 +317,37 @@ RDW_FRAME | RDW_INVALIDATE | RDW_UPDATENOW); return THEMING_CallOriginalClass(hwnd, msg, wParam, lParam); + case WM_MOUSEMOVE: + { + TRACKMOUSEEVENT mouse_event; + mouse_event.cbSize = sizeof(TRACKMOUSEEVENT); + mouse_event.dwFlags = TME_QUERY; + if(!TrackMouseEvent(&mouse_event) || !(mouse_event.dwFlags&(TME_HOVER|TME_LEAVE))) + { + mouse_event.dwFlags = TME_HOVER|TME_LEAVE; + mouse_event.hwndTrack = hwnd; + mouse_event.dwHoverTime = 1; + TrackMouseEvent(&mouse_event); + } + break; + } + + case WM_MOUSEHOVER: + { + int state = (int)SendMessageW(hwnd, BM_GETSTATE, 0, 0); + SetWindowLongW(hwnd, 0, state|BST_HOT); + InvalidateRect(hwnd, NULL, FALSE); + break; + } + + case WM_MOUSELEAVE: + { + int state = (int)SendMessageW(hwnd, BM_GETSTATE, 0, 0); + SetWindowLongW(hwnd, 0, state&(~BST_HOT)); + InvalidateRect(hwnd, NULL, FALSE); + break; + } + default: /* Call old proc */ return THEMING_CallOriginalClass(hwnd, msg, wParam, lParam); Modified: branches/GSoC_2011/ThemesSupport/dll/win32/comctl32/theme_dialog.c URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/ThemesSupport/dll/win…
============================================================================== --- branches/GSoC_2011/ThemesSupport/dll/win32/comctl32/theme_dialog.c [iso-8859-1] (original) +++ branches/GSoC_2011/ThemesSupport/dll/win32/comctl32/theme_dialog.c [iso-8859-1] Sun Jul 17 15:16:59 2011 @@ -54,7 +54,9 @@ case WM_DESTROY: CloseThemeData ( theme ); - return THEMING_CallOriginalClass (hWnd, msg, wParam, lParam); + SetWindowTheme( hWnd, NULL, NULL ); + OpenThemeData( hWnd, NULL ); + return THEMING_CallOriginalClass (hWnd, msg, wParam, lParam); case WM_THEMECHANGED: CloseThemeData ( theme ); Modified: branches/GSoC_2011/ThemesSupport/dll/win32/comctl32/theming.c URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/ThemesSupport/dll/win…
============================================================================== --- branches/GSoC_2011/ThemesSupport/dll/win32/comctl32/theming.c [iso-8859-1] (original) +++ branches/GSoC_2011/ThemesSupport/dll/win32/comctl32/theming.c [iso-8859-1] Sun Jul 17 15:16:59 2011 @@ -35,15 +35,15 @@ ULONG_PTR); extern LRESULT CALLBACK THEMING_ButtonSubclassProc (HWND, UINT, WPARAM, LPARAM, - ULONG_PTR); + ULONG_PTR) DECLSPEC_HIDDEN; extern LRESULT CALLBACK THEMING_ComboSubclassProc (HWND, UINT, WPARAM, LPARAM, - ULONG_PTR); + ULONG_PTR) DECLSPEC_HIDDEN; extern LRESULT CALLBACK THEMING_DialogSubclassProc (HWND, UINT, WPARAM, LPARAM, - ULONG_PTR); + ULONG_PTR) DECLSPEC_HIDDEN; extern LRESULT CALLBACK THEMING_EditSubclassProc (HWND, UINT, WPARAM, LPARAM, - ULONG_PTR); + ULONG_PTR) DECLSPEC_HIDDEN; extern LRESULT CALLBACK THEMING_ListBoxSubclassProc (HWND, UINT, WPARAM, LPARAM, - ULONG_PTR); + ULONG_PTR) DECLSPEC_HIDDEN; static const WCHAR dialogClass[] = {'#','3','2','7','7','0',0}; static const WCHAR comboLboxClass[] = {'C','o','m','b','o','L','b','o','x',0}; Modified: branches/GSoC_2011/ThemesSupport/dll/win32/comctl32/toolbar.c URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/ThemesSupport/dll/win…
============================================================================== --- branches/GSoC_2011/ThemesSupport/dll/win32/comctl32/toolbar.c [iso-8859-1] (original) +++ branches/GSoC_2011/ThemesSupport/dll/win32/comctl32/toolbar.c [iso-8859-1] Sun Jul 17 15:16:59 2011 @@ -574,7 +574,7 @@ UINT state = tbcd->nmcd.uItemState; /* draw text */ - if (lpText) { + if (lpText && infoPtr->nMaxTextRows > 0) { TRACE("string=%s rect=(%s)\n", debugstr_w(lpText), wine_dbgstr_rect(rcText)); @@ -2305,7 +2305,7 @@ return 0; } -extern UINT uDragListMessage; +extern UINT uDragListMessage DECLSPEC_HIDDEN; /*********************************************************************** * TOOLBAR_CustomizeDialogProc Modified: branches/GSoC_2011/ThemesSupport/dll/win32/comctl32/tooltips.c URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/ThemesSupport/dll/win…
============================================================================== --- branches/GSoC_2011/ThemesSupport/dll/win32/comctl32/tooltips.c [iso-8859-1] (original) +++ branches/GSoC_2011/ThemesSupport/dll/win32/comctl32/tooltips.c [iso-8859-1] Sun Jul 17 15:16:59 2011 @@ -1979,35 +1979,11 @@ static LRESULT TOOLTIPS_NotifyFormat (TOOLTIPS_INFO *infoPtr, WPARAM wParam, LPARAM lParam) { - TTTOOL_INFO *toolPtr = infoPtr->tools; - LRESULT nResult; - - TRACE("infoPtr=%p wParam=%lx lParam=%p\n", infoPtr, wParam, (PVOID)lParam); - - if (lParam == NF_QUERY) { - if (toolPtr->bNotifyUnicode) { - return NFR_UNICODE; - } else { - return NFR_ANSI; - } - } - else if (lParam == NF_REQUERY) { - nResult = SendMessageW (toolPtr->hwnd, WM_NOTIFYFORMAT, - (WPARAM)infoPtr->hwndSelf, (LPARAM)NF_QUERY); - if (nResult == NFR_ANSI) { - toolPtr->bNotifyUnicode = FALSE; - TRACE(" -- WM_NOTIFYFORMAT returns: NFR_ANSI\n"); - } else if (nResult == NFR_UNICODE) { - toolPtr->bNotifyUnicode = TRUE; - TRACE(" -- WM_NOTIFYFORMAT returns: NFR_UNICODE\n"); - } else { - TRACE (" -- WM_NOTIFYFORMAT returns: error!\n"); - } - return nResult; - } + FIXME ("hwnd=%p wParam=%lx lParam=%lx\n", infoPtr->hwndSelf, wParam, lParam); return 0; } + static LRESULT @@ -2076,7 +2052,7 @@ { LRESULT res; - if(!infoPtr->szTipText || !size) + if(!size) return 0; res = min(strlenW(infoPtr->szTipText)+1, size);
13 years, 5 months
1
0
0
0
← Newer
1
...
27
28
29
30
31
32
33
...
52
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
Results per page:
10
25
50
100
200